Boot from boot NGINX,PHP-FPM

Source: Internet
Author: User
Tags fpm

Boot from boot nginx,php-fpm (other services similar)

CentOS 7 above is initialized with SYSTEMD system, SYSTEMD is the latest initialization system (INIT) in Linux system, its main design goal is to overcome the inherent shortcomings of sysvinit, and improve the system startup speed. SYSTEMD Service files end with. Service, such as now to build nginx for boot, if installed with the Yum Install command, yum command will automatically create Nginx.service file, directly with the command Systemcel enable Nginx.service set boot up.

systemcel enable nginx.service

Manually set up Nginx.service service files for source installation

  1. Create a Nginx.service file in the System services directory
    vi /lib/systemd/system/nginx.service
    Write the following (the path is changed to its own)
    [Unit]description=nginxafter=Network.target[service]type=Forkingexecstart= /www/lnmp/nginx/sbin/nginx-c/www/lnmp/nginx/conf/nginx.confexecreload=/www/lnmp/nginx/sbin/nginx-  S reloadexecstop=/www/lnmp/nginx/sbin/nginx-s quitprivatetmp=true[Install]wantedby =multi-user.target

    Create a Php-fpm.service file in the System services directory
    vi /lib/systemd/system/php-fpm.service
    Write the following (the path is changed to its own)
    [unit]description=php-fpmafter=Network.target[service]type=Forkingexecstart =/www/lnmp/php/sbin/php-fpmprivatetmp=true[Install]wantedby=multi-user.target

    [Unit]: Description of the service
    Description: Description Service
    After: Describe the service category
    settings for the [service] service run parameter
    Type=forking is the form of a background run
    Execstart specific run commands for the service
    Execreload Reset Command
    Execstop for Stop command
    Privatetmp=true represents a separate temporary space allocated to the service
    Note: The start, restart, and stop commands for [Service] all require absolute paths
    Settings for service installation under [Install] run level, can be set to multi-user, i.e. system run level is 3

  2. Test and add power-on self-start
    Close NGINX,PHP-FPM First
    Use the following command to turn on
    systemctl start Nginx.service             #如果服务是开启状态, using this command will fail. Systemctl Start PHP-fpm.service

    Open successfully, add service to boot

    systemctl enable Nginx.service                #注意后面不能跟空格systemctl enable PHP-fpm.service

    Restart the server to see if it starts

    Shutdown-R now        #重启systemctl list-units--type=service           #查看运行的服务



Other commands
systemctl start Nginx.service              #启动nginx服务systemctl enable Nginx.service             #设置开机自启动systemctl Disable Nginx.service            #停止开机自启动systemctl status nginx.service             #查看服务当前状态systemctl restart Nginx.service          # Restart the service Systemctl list-units--type=service        #查看所有已启动的服务



转载:78513521

Boot from boot NGINX,PHP-FPM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.