Nginx
Nginx安装配置
1. 下载Nginx
wget http://nginx.org/download/nginx-1.17.3.tar.gz
2. 解压并安装
tar -zxvf nginx-xx.tar.gz
cd nginx-xx
./configure
make && make install
Tips: 可能会产生的错误
- ./configure: error: C compiler cc is not found
sudo yum -y install gcc gcc-c++ autoconf automake
- ./configure: error: the HTTP rewrite module requires the PCRE library.
sudo yum -y install pcre pcre-devel
- ./configure: error: the HTTP gzip module requires the zlib library.
sudo yum -y install zlib zlib-devel
3. 测试是否安装成功
查看/usr/loca目录下是否存在nginx文件夹,如果存在说明安装成功
ls /usr/local/
Nginx的启动与停止
1. Nginx的启动
启动代码格式:
Nginx地址 -c Nginx配置文件地址
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2. Nginx的停止
Nginx有三种停止方式:
查看Nginx进程号
ps -ef | grep nginx
- 从容停止:
kill -QUIT 进程号
- 快速停止:
kill -TERM 进程号 or kill -INT 进程号
- 强制停止:
pkill -9 nginx
3. Nginx的重启
- 验证Nginx配置文件的正确性:
方法1:
sudo /usr/local/nginx/sbin/nginx -t
方法2:
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
- 重启:
方法1:
sudo /usr/local/nginx/sbin/nginx -s reload
方法2:
kill -HUP 进程号