systemctl stop firewalld
systemctl disable firewalld
setenforce 0
2、安装依赖包
yum -y install gcc pcre-devel openssl-devel zlib-devel openssl openssl-devel
3、创建运行用户、组
(Nginx 服务程序默认以 nobody 身份运行,建议为其创建专门的用户账号,以便更准确地控制其访问权限)
useradd -M -s /sbin/nologin nginx
4、编译安装Nginx
cd /opt
tar zxvf nginx-1.22.0.tar.gz -C /opt/
cd nginx-1.22.0/
./configure --prefix=/usr/local/nginx
–user=nginx
–group=nginx
–with-http_ssl_module
–with-http_v2_module
–with-http_realip_module
–with-http_stub_status_module
–with-http_gzip_static_module
–with-pcre
–with-stream
–with-stream_ssl_module
–with-stream_realip_module
make && make install
chown -R nginx.nginx /usr/local/nginx #修改权限
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/ #让系统识别nginx的操作命令
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/run/nginx.pid
#注意文件位置,如果不对 启动不了
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#注意启动文件位置
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
mkdir -p /usr/local/nginx/run/
#创建目录
vim /usr/local/nginx/conf/nginx.conf
#修改配置文件
pid /usr/local/nginx/run/nginx.pid;
#找到 pid的位置修改
systemctl daemon-reload
#重新加载配置
systemctl start nginx.service
vim /usr/local/nginx/html/index.html
100 dd 删除原内容
添加新内容:
this is zpll!
打开浏览器,访问ip地址