nginx,想要解决这个问题可以
nginx,想要解决这个问题可以
nginx
1.nginx简介
2.lnmp工作原理
- apache
-
- nginx
3.nginx参数与模块介绍
- --prefix=/usr/local/nginx #/指定安装路径
- --with-http_stub_status_module #/安装状态模块、
- --with-http_ssl_module #/安装https模块
二、nginx安装
1.安装依赖包
yum -y install openssl-devel gcc gcc-c++ zlib-devel pcre-devel
2.解压nginx压缩包
cd /opt/opt
tar -xvf nginx-1.22.0.tar.gz
cd nginx-1.22.0
3.检测环境选择模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
4.编译安装ngixn
make && make install
5.软连接启动路径方便管理
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
5.检测nginx是否可以启动 ok表示正常
nginx -t #/检测nginx是否正常
6.链接nginx方便管理
添加systemctl管理
vim /etc/rc.d/init.d/nginx
添加以下内容
#!/bin/bash #chkconfig: 35 85 21 case $1 in start) /usr/local/sbin/nginx ;; stop) killall -9 nginx rm -f /var/run/nginx.pid ;; restart) $0 stop $0 start ;; *) echo "start|stop|restart" ;; esac :wq #/保存退出 7.保存退出后授予执行权限 chmod +x /etc/rc.d/init.d/nginx systemctl daemon-reload #/重新加载服务 useradd nginx #/创建用于启动nginx的账户 8.启动nginx sytemctl restart nginx #/以systemctl方式启动nginx9.启动nginx并过滤端口验证是否启动
nginx -s reload #/重启nginx
ss -antpul | grep nginx #/过滤nginx端口
nginx -c stop #/关闭nginx
7.nginx pid无效导致无法启动解决方法
说明:原因是因为每一个nginx进程都对应一个id,存放于nginx.pid中,而在进行重新编译时可能会因为一些bug导致nginx.pid中的id号被卡死,因此无法重启。想要解决这个问题可以杀掉所有nginx进程,再用-c命令指定配置文件进行启动。
方法一:
将安装路径下的nginx启动文件 使用nginx -c 到nginx的配置文件
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
方法二:
nginx -c 指向到ngingx配置文件路径
nginx -c /usr/local/nginx/conf/nginx.conf
评论暂时关闭