編譯安裝Nginx和PHP,安裝目錄: /application/nginx-1.10.3 和 /application/php-5.6.30
/application/nginx-1.10.3 軟連接到 /application/nginx
/application/php-5.6.30 軟連接到 /application/php
CentOS 7 啓動腳本在/usr/lib/systemd/system/
新建nginx.service,內容如下:
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=/application/nginx/logs/nginx.pid #PID文件位置
ExecStartPre=/application/nginx/sbin/nginx -t #啓動前先幹什麼,這裏是先測試配置文件是否正確
ExecStart=/application/nginx/sbin/nginx #啓動命令
ExecReload=/usr/bin/kill -s HUP $MAINPID #重載reload
ExecStop=/usr/bin/kill -s QUIT $MAINPID #停止服務
PrivateTmp=true #爲服務分配獨立的臨時空間
[Install]
WantedBy=multi-user.target
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
新建php-fpm.service,內容如下:
php-fpm.service
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
PIDFile=/application/php/var/php-fpm.pid
ExecStartPre=/application/php/sbin/php-fpm -t -c /application/php/etc/php-fpm.conf
ExecStart=/application/php/sbin/php-fpm
ExecStop=/usr/bin/kill -s QUIT $MAINPID
ExecReload=/usr/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
注意:php-fpm默認是沒有pid的,需要修改php-fpm.conf,大概25行左右。