编译安装Nginx
https://www.cnblogs.com/zhang-shijie/p/5294162.html 参考文档
1.安装依赖包
yum -y install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
2.解压
https://nginx.org/download/ 下载软件包
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
3.创建用户
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
4.编译
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_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/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
make && make install
5.配置
配置文件位置:/usr/local/nginx/conf/nginx.conf
listen 8090 修改监听端口
/usr/local/nginx/sbin/nginx 启动nginx
或者指定配置文件启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
6.查看nginx进程
# ps -ef | grep nginx
root 26689 1 0 10:29 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx #nginx的主进程,只有一个主进程
nginx 26690 26689 0 10:29 ? 00:00:00 nginx: worker process #nginx工作进程,默认只有一个,可以通过修改配置文件 worker_processes,启动多个工作进程
root 26705 23487 0 10:29 pts/1 00:00:00 grep nginx
# lsof -i:8090 #显示占用8090的进程
nginx 26689 root 6u IPv4 57725130 0t0 TCP *:8090 (LISTEN)
nginx 26690 nginx 6u IPv4 57725130 0t0 TCP *:8090 (LISTEN)