Nginx
本项目使用版本
解压目录
- 解压:
tar -zxvf nginx-1.25.0.tar.gz - /software/nginx-1.25.0
- 解压:
CentOS 安装
shell# checking for C compiler ... not found yum -y install gcc # using --with-pcre=<path> option. yum -y install pcre-devel # using --with-zlib=<path> option. yum -y install zlib-devel # using --with-openssl=<path> option. yum -y install openssl-devel ./configure --with-http_ssl_module --with-http_v2_module make make installUbuntu 安装
shell# checking for C compiler ... not found apt-get -y install gcc # using --with-pcre=<path> option. apt-get -y install libpcre3-dev # using --with-zlib=<path> option. apt-get -y install zlib1g-dev # using --with-openssl=<path> option. apt-get -y install libssl-dev ./configure --with-http_ssl_module --with-http_v2_module # Command 'make' not found apt-get -y install make make make install安装目录
shellConfiguration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"服务脚本示例文件
shell/usr/lib/systemd/system/nginx.serviceshell[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target开放端口
CentOS
shellfirewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload firewall-cmd --list-allUbuntu
shellsudo ufw allow 80 sudo ufw allow 443
服务命令
查看状态
shellsystemctl status nginx.service启动
shellsystemctl start nginx.service停止
shellsystemctl stop nginx.service重启
shellsystemctl restart nginx.service设置开机自启
shellsystemctl enable nginx.service查看开机自启
shellsystemctl list-unit-files | grep nginx.serviceshellsystemctl is-enabled nginx.service关闭开机自启
shellsystemctl disable nginx.service