1 环境安装
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2 新建nginx文件夹,并下载nginx压缩包
mkdir nginx
cd nginx
wget http://nginx.org/download/nginx-1.19.10.tar.gz
tar -xvf nginx-1.19.10.tar.gz
3安装nginx
cd /usr/local/nginx
cd nginx-1.19.10
./configure
make
make install
4 配置文件
vim /usr/local/nginx/conf/nginx.conf
5 启动nginx
/usr/local/nginx/sbin/nginx -s reload
如果出现报错:nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed
则运行:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
6 查看nginx进程
ps -ef | grep nginx
7 常用命令
进入安装目录
cd /usr/local/nginx/sbin
启动
./nginx
关闭
./nginx -s stop
重启
./nginx -s reload