Mac Pro boot Php-fpm,nginx,mysql and other software

Source: Internet
Author: User
Tags fpm install php php development environment

Under the Mac installed the PHP development environment (PHP-FPM,NGINX,MYSQL), want to set up self-boot, originally thought and the General Linux system, but also in rc.d such directory placement startup script. On the Internet to check some information, found that Apple should be completely closed, can only use the Mac system Launchctl to do this thing.

Launchctl in fact is to write a *.plist file, its role and Linux in the role of Crontab is the same. Let's take a self-initiated MySql example

1, the new file com.mysql.plist, but this file needs to be placed in the /library/launchdaemons directory

sudo vim/library/launchdaemons/com.mysql.plist

The contents are as follows:

<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" >  < Plist version= "1.0" >  <dict>          <key>Label</key>          <string>com.mysql</ string>          <key>ProgramArguments</key>          <array>                  <string>/usr/local/mysql/ bin/mysqld_safe</string>          </array>          <key>RunAtLoad</key>          <true/>          <key>KeepAlive</key>          <true/></dict>  </plist>

2, register this plist file to the system service.

sudo launchctl load-w/library/launchdaemons/com.mysql.plist  

Note: The uninstall command is

sudo launchctl unload-w/library/launchdaemons/com.mysql.plist

3. Modify Execution permissions

sudo chown root:wheel/library/launchdaemons/com.mysql.plistsudo chmod +x/library/launchdaemons/com.mysql.plist

4, other development software (Nginx, PHP-FPM) the same configuration

/library/launchdaemons/com.nginx.plist

<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" ><plist Version= "1.0" ><dict>        <key>Label</key>        <string>com.nginx</string>        <key>ProgramArguments</key>        <array>                <string>/usr/local/nginx/sbin/nginx</ string>        </array>        <key>RunAtLoad</key>        <true/>        <key>keepalive </key>        <true/></dict></plist>

/library/launchdaemons/com.php-fpm.plist

<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" ><plist Version= "1.0" ><dict>        <key>Label</key>        <string>com.php-fpm</string>        <key>ProgramArguments</key>        <array>                <string>/usr/local/php/sbin/php-fpm-d </string>        </array>        <key>RunAtLoad</key>        <true/>        <key> Keepalive</key>        <true/></dict></plist>

Possible " error "

1, the implementation of LAUNCHCTL, the dubious ownership on file (skipping) this error

The reason is: This plist file must belong to the root user, wheel group, with chown modification.

sudo chown root:wheel/library/launchdaemons/com.mysql.plist

2, when the implementation of Launchctl, Launchctl:no plist was returned this error

The reason is: the contents of the Plist file may be malformed.

Use the following command to see if there is a problem with the file format, I use this check to see that there is a <true> tag is not closed.

sudo plutil-lint/library/launchdaemons/com.mysql.plist

Note: User names and user groups in profiles such asphp-fpm.conf,nginx.conf , etc. are set to the currently logged in user, that is, Jianbao, staff.

Extended reading:

MAC user groups: The difference between staff, wheel, and admin

Mac Pro Decompression install MySQL binary distribution version mysql-5.6.30-osx10.11-x86_64.tar.gz (not DMG)

MAC Pro Compile and install Nginx 1.8.1

MAC Pro Compile and install PHP 5.6.21 and problem summary

Reference:

Https://www.nginx.com/resources/wiki/start/topics/examples/osxlaunchd/

Https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html

Https://sexywp.com/use-launchd-to-start-shadowsocks.htm

Mac Pro boot Php-fpm,nginx,mysql and other software

Related Article

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.