Mac system, php-fpm add boot entry

Source: Internet
Author: User
Tags chmod fpm

Find the path to PHP-FPM

Whereis PHP-FPM

If you cannot find it, you can try using:

Find/-name PHP-FPM
The general default path is:

/usr/sbin/php-fpm

modifying php-fpm.conf configuration Files

The default location is:

/private/etc/php-fpm.conf

If it doesn't exist, see if it exists.

/private/etc/php-fpm.conf.default

Then copy a copy:

sudo cp/private/etc/php-fpm.conf.default/private/etc/php-fpm.conf

Modify the PHP-FPM configuration file's project "Daemonize"

Daemonize = yes

Remove the semicolon from the front.

Add Startup Item

In the ~/library/launchagents directory, create a new Org.php.php-fpm.plist file:

<?xml version= "1.0" encoding= "UTF-8"?> <!
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>php-fpm</string >
    <key>Program</key>
    <string>/usr/sbin/php-fpm</string>
    <key> keepalive</key><true/>
</dict>
</plist>

Note: The path to the PHP-FPM in the XML file is obtained by the command above.

sudo chown root:owner ~/library/launchagents/org.php.php-fpm.plist
sudo chmod +x ~/library/launchagents/ Org.php.php-fpm.plist
sudo launchctl load-w ~/library/launchagents/org.php.php-fpm.plist

After you execute the above command, you can use this debug command to see if the startup item is loaded:

Launchctl List | grep php

Output:

-	0	PHP-FPM

The middle number is the status code, if the 0 description has been successful, then the service has been started;

If it is not 0, there may be a problem.

I started at the command

sudo chown root:owner ~/library/launchagents/org.php.php-fpm.plist

Root is not specified in, but another user I often use, but the status is: 78.

It is also important to note that the execution of the LAUNCHCTL command plus sudo is completely different from the result.

2018-04-27 continue to try

The previous configuration is still not successful, do not know whether it is due to the permissions of the issue.

1, the new file/library/launchdaemons/org.macports.php-fpm.plist, reference: Org.macports.nginx.plist, removed the PID part.

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>
<! 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>org.macports.php-fpm </string>
<key>ProgramArguments</key>
<array>
        <string>/opt/local/bin /daemondo</string>
        <string>--label=php-fpm</string>
        <string>--start-cmd</ string>
        <string>/usr/sbin/php-fpm</string>
        <string>;</string>
        < string>--pid=fileauto</string>
</array>
<key>KeepAlive</key><true/>
</dict>
</plist>
2, modify the permissions so that you can directly use PHP-FPM start
sudo chmod 777/usr/local/var/log/php-fpm.log
sudo chmod 777/usr/local/var/log/www.access.log
3, directly using Launchctl load-w org.macports.php-fpm.plist loading
After loading, execute Ps-ef | grep PHP gets
501 2622 1 0 11:05 a.m.?? 0:00.01/opt/local/bin/daemondo--label=nginx--start-cmd/usr/sbin/php-fpm; --pid=fileauto


Launchctl List | grep php
2644 2 ORG.MACPORTS.PHP-FPM
-PHP-FPM

2018-04-28

1, the service is started, but:
Launchctl List | grep php
-PHP-FPM
Previously configured or did not start successfully;

2, modify: sudo vi/library/launchdaemons/org.macports.php-fpm.plist

Change the Nginx in the file to PHP-FPM

2018-05-02

Execute LAUNCHCTL List | grep php and sudo launchctl list | grep PHP sees different results,

$ LAUNCHCTL List | grep php
3116	php-fpm
$ sudo launchctl list | grep php
Password:
3120	2	org.macports.php-fpm
viewing processes
$ PS-EF | grep php
    0   140     1   0  8:49 a.m.??         0:01.59/USR/SBIN/PHP-FPM
  501   140   0  8:50 a.m.??         0:00.26/USR/SBIN/PHP-FPM
  501   156   140   0  8:50 a.m.??         0:00.02/USR/SBIN/PHP-FPM
  501  3104   140   0 10:42 a.m.??         0:00.01/USR/SBIN/PHP-FPM
    0  3158     1   0 10:45 a.m.??         0:00.01/opt/local/bin/daemondo--LABEL=PHP-FPM--start-cmd/usr/sbin/php-fpm; --pid=fileauto
  501  3163   580   0 10:45 a.m. ttys000    0:00.00 grep--color php
It seems that both of them have been launched successfully.

================================

For a directory about the startup files mentioned above,/library/launchagents, and an associated location:/library/launchdaemons/. When not effective, you can look at this plist file, rather than try a different position. There are several similar locations in the Mac system, and the effect is different. In this case, we recommend that you use ~/library/launchagents/.


Comparison of Launchdaemons and launchagents functions:
Launchdaemons is a service (daemon) that starts before the user logs on.
Launchagents is the service (daemon) that the user starts after logging in.



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.