一、安装
#如果没有gcc环境,需要安装gcc:
yum install gcc-c++
#安装依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
#进入文件夹
cd /usr/local
#下载安装包
wget http://nginx.org/download/nginx-1.18.0.tar.gz
#解压安装包
tar -xvf nginx-1.18.0.tar.gz
#解压之后不需要重新命名直接进去解压目录
#进入nginx-1.18.0目录
cd /usr/local/nginx-1.18.0
#执行命令
#prefix= 指向安装目录(编译安装)
#conf-path= 指向配置文件(nginx.conf)
#error-log-path= 指向错误日志目录
#pid-path= 指向pid文件(nginx.pid)
#http-log-path= 设定access log路径
#with-http_gzip_static_module 启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
#with-http_stub_status_module 启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
#with-http_ssl_module 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --http-log-path=/usr/local/nginx/logs/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module
#执行命令
make
#执行make install命令
make install
#启动nginx
cd /usr/local/nginx/sbin
./nginx
#查看nginx进程
ps -ef | grep nginx
#打开阿里云的网路安全组开放80端口
#在浏览器访问服务器ip
#设置开机自动启动
vim /lib/systemd/system/nginx.service
#按i编辑 把下面复制进去 按esc建 再按shift+:键 wq 保存退出
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
#自己nginx启动的pid文件自己找到文件目录
PIDFile=/usr/local/nginx/logs/nginx.pid
#自己nginx的启动文件
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
#默认
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#启动
systemctl start nginx.service
设置开机自启
systemctl enable nginx.service
#提示
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
#停止开机自启动
systemctl disable nginx.service
#查看服务当前状态
systemctl status nginx.service
#重新启动服务
systemctl reload nginx.service
#停止服务
systemctl stop nginx.service二、离线部署Nginx插件
一、所需安装组件
链接:https://pan.baidu.com/s/1uuqk-fjaH603IRVqcPdc6g
提取码:tc5t
二、安装步骤
1. 安装gcc
#进入目录
cd gcc_rpm
#运行命令
rpm -ivh *.rpm --nodeps --force
#验证gcc是否安装成功
gcc -v2. 安装gcc-c
#进入gcc-c++目录
cd gcc-c++/
#执行安装命令
rpm -ivh *.rpm --nodeps --force
#验证g++是否安装成功
g++ -v3. 安装pcre
#把文件复制到/usr/local/
cd /usr/local/
#解压pcre-8.42.tar.gz压缩文件
tar -zxvf pcre-8.42.tar.gz
#进入解压目录
cd /usr/local/pcre-8.42
#依次执行一下命令
./configure
make
make install4. 安装zlib
#解压压缩文件
tar -zxvf zlib-1.2.11.tar.gz
#进入解压目录
cd /usr/local/zlib-1.2.11
#依次执行一下命令
./configure
make
make install5.安装openssl
#解压压缩文件
tar -zxvf openssl-1.1.1s.tar.gz
#进入解压目录
cd /usr/local/openssl-1.1.1s
#依次执行一下命令
./config
make
make install6.安装perl-5.2
#解压压缩文件
tar -zxvf perl-5.28.0.tar.gz
#进入解压目录
cd /usr/local/perl-5.28.0
#依次执行一下命令
./Configure -des -Dprefix=$HOME/localperl
make
make install
默认评论
Halo系统提供的评论