nginx安装
需要先安装依赖
yum install -y gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
nginx文件目录:/opt/soft
nginx安装目录:/usr/local/nginx
1.1 下载安装包
下载地址:http://nginx.org/en/download.html
或者wget http://nginx.org/download/nginx-1.25.2.tar.gz
此手册以nginx-1.25.2.tar.gz为例
1.2 安装
1.2.1 目录
将下载的安装包上传到服务器的/opt/soft目录
1.2.2 解压
tar -zxvf nginx-1.25.2.tar.gz
1.2.3 安装
cd /opt/soft/nginx-1.25.2
以下方式二选一
1)开启SSL
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
如果升级过OpenSSL,可能存在需要指定OpenSSL目录的问题,在命令后加以下内容:
–with-openssl=/opt/openssl-1.1.1w #路径为openssl的源路径
2)不开启SSL,后续按需安装
./configure
make
make install
1.2.4 开机启动
1)创建开机自启脚本
cd /etc/systemd/system
vi nginx.service
2)nginx.service文件内容
/usr/local/nginx/sbin/nginx 为nginx路径
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/n