Nginx服务器---编译安装NGINX

编辑安装NGINX

  1. 安装必要的依赖包
  2. 创建nginx用户
  3. 解压nginx-1.18.0.tar.gz
  4. 编译安装
  5. 创建自启动脚本
[root@centos8 ~]#yum install gcc gcc-c++  pcre pcre-devel openssl-devel zlib zlib-devel make lrzsz vim tree wget lsof
[root@centos8 ~]#useradd nginx
[root@centos8 ~]#tar xf nginx-1.18.0.tar.gz
[root@centos8 ~]#cd nginx-1.18.0
[root@centos8 ~]#./configure --prefix=/apps/nginx \ #程序路径
--user=nginx \
--group=nginx \
--with-http_ssl_module  \   #启用ssl模块
--with-http_v2_module \
--with-http_realip_module \ 
--with-stream  \   #开启proxy
--with-stream_ssl_module \
--with-stream_realip_module
[root@centos8 ~]#make && make install
[root@centos8 ~]#cat /usr/lib/systemd/system/nginx.service 
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /apps/nginx/logs/nginx.pid
ExecStartPre=/apps/nginx/sbin/nginx -t
ExecStart=/apps/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

[root@centos8 ~]#systemctl daemon-reload
[root@centos8 ~]#systemctl enable --now nginx



上一篇:修改oracle数据库用户密码的方法 --九五小庞


下一篇:【ORM】用PHP实现一个简单的ORM【原创】