Nginx安装

yum install -y wget gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel
cd /usr/local/src
yum install lrzsz -y
wget 'http://nginx.org/download/nginx-1.26.2.tar.gz'
tar -zxvf nginx-1.26.2.tar.gz
cd nginx-1.26.2
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
make && make install

# 手动启动和关闭Nginx

1. 环境变量:export PATH=$PATH:/usr/local/nginx/sbin/
2. 检查Nginx配置: nginx -t
3. 启动Nginx:nginx
4. 关闭Nginx:nginx -s stop

验证Nginx安装是否成功

1. 查看进程
2. 查看监控端口
3. nginx日志
4. 浏览器访问

使用systemctl管理Nginx,/usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
[Install]
WantedBy=multi-user.target

星霜荏苒 居诸不息