cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
Category: Nginx
Nginx 隐藏版本号
修改相关配置文件
vi /usr/local/nginx/conf/nginx.conf
http模块加入 server_tokens off;
vi /usr/local/nginx/conf/fastcgi.conf
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为
fastcgi_param SERVER_SOFTWARE nginx;
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload
修改前后对比