0.下载包
wget https://nginx.org/download/nginx-1.18.0.tar.gz
1.安装nginx的依赖
主要包括:gcc,pcre,pcre-devel,zlib,zlib-devel,openssl,openssl-devel
命令:
yum install gcc -y
yum install pcre pcre-devel -y
yum install zlib zlib-devel -y
yum install openssl openssl-devel -y
2.查看依赖是否安装
命令:
gcc -v
openssl version -a
rpm -qa pcre
rpm -qa zlib
3.解压
在/home/app解压nginx-1.18.0.tar.gz
命令:tar -zxvf nginx-1.18.0.tar.gz
把nginx-1.18.0重名为nginx
命令:mv nginx-1.18.0 nginx
4.安装
在/home/app/nginx目录下执行命令
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install
5.安装后nginx的目录(本例是默认安装)
安装后所在目录:/usr/local/
6.启动
在/usr/local/nginx/sbin启动
命令:
./nginx -s reload
启动Nginx时候报错:nginx: [error] open() “/usr/local/nginx/logs/nginx.pid”
failed (2: No such file or directory)
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
7.查看启动进程和端口
进程:
ps -aux | grep nginx
端口
netstat -tlnp | grep nginx
8.查看nginx安装位置
whereis nginx