Nginx 源码编译安装
添加用户
# useradd nginx -s /sbin/nologin
安装所需要的系统组件
# yum -y groupinstall "Development tools"
# yum -y install pcre-devel
# yum -y install openssl-devel
创建所需要的临时目录
# mkdir -p /var/tmp/nginx/{client,fastcgi,proxy,uwsgi}
解压nginx安装包、并编译安装
# tar xf nginx-1.8.1.tar.gz # cd nginx-1.8.1 # ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx \ --error-log-path=/home/nginx/error.log \ --http-log-path=/home/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --with-http_flv_module \ --with-http_mp4_module \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi # make -j 2 && make install
配置系统环境变量
vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
让刚配置好的环境变量生效
source /etc/profile.d/nginx.sh
启动nginx
/usr/local/nginx/sbin/nginx
查看监听端口
]# ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:80 *:* users:(("nginx",3574,6),("nginx",3575,6),("nginx",10892,6))