linux安装nginx
参考:https://www.cnblogs.com/hdnav/p/7941165.html
1. tar -zxvf nginx-1.16.1.tar.gz
2. 安装依赖包
yum install -y pcre pcre-devel yum install -y zlib zlib-devel
3. 编译安装:
./configure
make
make install
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
3.查找安装路径:
whereis nginx
4.
启动、停止nginx
cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop #此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。 ./nginx -s quit #此方式停止步骤是待nginx进程处理任务完毕进行停止。 ./nginx -s reload
5. 重启 nginx
1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit
./nginx
2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload
不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload
启动成功后,在浏览器可以看到这样的页面:
6. 设置开机自启动
即在rc.local
增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 rc.local