nginx配置

nginx配置

安装nginx

安装所需插件

  • yum -y install gcc
    yum install -y pcre pcre-devel
    install -y zlib zlib-devel
    yum install -y openssl openssl-devel
    
下载安装包编译

或上传nginx-1.26.1.tar.gz

wget https://nginx.org/download/nginx-1.26.1.tar.gz
tar -xzf nginx-1.26.1.tar.gz
cd nginx-1.26.1
./configure --with-http_ssl_module --prefix=/usr/local/nginx 
make
sudo make install

配置nginx.conf

vi /usr/local/nginx/conf/nginx.conf

nginx.conf

配置启动服务
  • vi /etc/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable nginx
systemctl start nginx
systemctl status nginx

posted @ 2024-07-31 17:58  学海无涯吨吨吨嗝儿~  阅读(5)  评论(0编辑  收藏  举报