Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux installation nginx tutorial

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

# system selection: centos6.6

1. Add nginx service process users

Groupadd-r nginx

Useradd-r-g nginx nginx

Download and extract the installation package

Wget http://nginx.org/download/nginx-1.9.9.tar.gz

Tar xvf nginx-1.9.9.tar.gz-C / usr/local/src

Third, install the appropriate developer tools

Yum groupinstall "Development tools"

Yum-y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel

4. Enter the nginx directory to compile

Cd / usr/local/src/nginx-1.9.9/

. / configure\

-- prefix=/usr/local/nginx\

-- sbin-path=/usr/sbin/nginx\

-- conf-path=/etc/nginx/nginx.conf\

-- error-log-path=/var/log/nginx/error.log\

-- http-log-path=/var/log/nginx/access.log\

-- pid-path=/var/run/nginx.pid\

-- lock-path=/var/run/nginx.lock\

-- http-client-body-temp-path=/var/tmp/nginx/client\

-- http-proxy-temp-path=/var/tmp/nginx/proxy\

-- http-fastcgi-temp-path=/var/tmp/nginx/fcgi\

-- http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\

-- http-scgi-temp-path=/var/tmp/nginx/scgi\

-- user=nginx\

-- group=nginx\

-- with-pcre\

-- with-http_ssl_module\

-- with-http_realip_module\

-- with-http_addition_module\

-- with-http_sub_module\

-- with-http_dav_module\

-- with-http_flv_module\

-- with-http_mp4_module\

-- with-http_gunzip_module\

-- with-http_gzip_static_module\

-- with-http_random_index_module\

-- with-http_secure_link_module\

-- with-http_stub_status_module\

-- with-http_auth_request_module\

-- with-mail\

-- with-mail_ssl_module\

-- with-file-aio\

-- with-ipv6\

-- with-threads\

Fifth, complete the compilation

Make&&make install

Make-pv / var/tmp/nginx/client

Add SysV startup script 1. Create a file

Vim / etc/init.d/nginx

two。 Enter the editing state

#! / bin/sh

Nginx-this script starts and stops the nginx daemon

Chkconfig:-85 15

Description: Nginx is an HTTP (S) server, HTTP (S) reverse\

Proxy and IMAP/POP3 proxy server

Processname: nginx

Config: / etc/nginx/nginx.conf

Config: / etc/sysconfig/nginx

Pidfile: / var/run/nginx.pid

Source function library.

. / etc/rc.d/init.d/functions

Source networking configuration.

. / etc/sysconfig/network

Check that networking is up.

["$NETWORKING" = "no"] & & exit 0

Nginx= "/ usr/sbin/nginx"

Prog=$ (basename $nginx)

NGINX_CONF_FILE= "/ etc/nginx/nginx.conf"

[- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginx

Lockfile=/var/lock/subsys/nginx

Start () {

[- x $nginx] | | exit 5

[- f $NGINX_CONF_FILE] | | exit 6

Echo-n $"Starting $prog:"

Daemon $nginx-c $NGINX_CONF_FILE

Retval=$?

Echo

[$retval-eq 0] & & touch $lockfile

Return $retval

}

Stop () {

Echo-n $"Stopping $prog:"

Killproc $prog-QUIT

Retval=$?

Echo

[$retval-eq 0] & & rm-f $lockfile

Return $retval

Killall-9 nginx

}

Restart () {

Configtest | | return $?

Stop

Sleep 1

Start

}

Reload () {

Configtest | | return $?

Echo-n $"Reloading $prog:"

Killproc $nginx-HUP

RETVAL=$?

Echo

}

Force_reload () {

Restart

}

Configtest () {

$nginx-t-c $NGINX_CONF_FILE

}

Rh_status () {

Status $prog

}

Rh_status_q () {

Rh_status > / dev/null 2 > & 1

}

Case "$1" in

Start)

Rh_status_q & & exit 0

, 1

Stop)

Rh_status_q | | exit 0

, 1

Restart | configtest)

, 1

Reload)

Rh_status_q | | exit 7

, 1

Force-reload)

Force_reload

Status)

Rh_status

Condrestart | try-restart)

Rh_status_q | | exit 0

*)

Echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest}"

Exit 2

Esac

7. Give the script execution permission

Chmod + x / etc/init.d/nginx

Add it to the service management list and set it to boot.

Chkconfig-add nginx

Chkconfig nginx on

IX. Start

Service nginx start

10. Check the operation status

Netstat-lntup | grep nginx

(ps: Baidu is available for specific configuration items)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report