第一步: 编写nginx文件,放入/etc/init.d/ nginx文件内容如下,粉红色部分为自己实际nginx安装的路径. #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v. version. # chkconfig: - # description: Nginx is a high-performance web and proxy server. # It has a lot of feature
1.建立服务文件 (1)文件路径 vim /usr/lib/systemd/system/nginx.service (2)服务文件内容 [Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/opt/nginx/sbin/nginx ExecReload=/opt