One Nginx and php-fpm self-start setting and troubleshooting

Source: Internet
Author: User

After setting up the LNMP environment on your own last time, only mysql can be started directly with service settings. nginx and php-fpm must be enabled manually, so a simple script is written:

#!/bin/bashcd /usr/local/nginx/sbin./nginxcd /usr/local/php/sbin./php-fpm

After the system is started, run the script through ssh.

This is troublesome, so you can refer to the self-starting script on the Internet to set it. However, the server prompts an error after setting.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/04424Q5F-0.png "title =" QQ20130927235534.png "alt =" 001251638.png"/>

I thought it was an nginx problem. ps aux | grep nginx looked at it and there was a process. It is suspected that it is a File Permission problem, so we set all the owner and group of files under nginx to nobody, and the error persists after restart. After a long time, I think I should check the error. log, the error "connect () failed (111: Connection refused) while connecting to upstream" is displayed. After searching, you can see a reply to a similar question:

'Connection refused 'means that backend does not listen to the port 9000 or its queue is filled up. This problem is related to the backend itsef. Are you able to telnet localhost 9000? You shoshould also check your backend and php logs.-AndrewOct 1 '11

It seems that the error should be on php-fpm and the startup log is viewed. It is true:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/04424R3J-1.png "title =" QQ20130928002220.png "alt =" 002246403.png"/>

It is indeed a problem to start the script to write, go back to look at did not see what the problem, simply find a php-fpm5.2 to start the script, the results are still not good, continue to look at the log:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/04424RM1-2.png "title =" .png "alt =" 002518576.png"/>

It seems that the startup is a parameter problem. Let's look at the startup code:

case "$1" in    start)        echo -n "Starting php_fpm "        $php_fpm_BIN --fpm $php_opts        if [ "$?" != 0 ] ; then            echo " failed"            exit 1        fi        wait_for_pid created $php_fpm_PID        if [ -n "$try" ] ; then            echo " failed"            exit 1        else            echo " done"        fi    ;;

Where

php_fpm_BIN=/usr/local/php/bin/php-cgiphp_fpm_CONF=/usr/local/php/etc/php-fpm.conf

From the error information, you cannot directly use the -- fpm parameter. Simply comment out the following parameters, reboot, visit the website, and OK!

After so long, the experience is that errors must be recorded in logs!


However, we also learned about the system service and script self-starting method in this process, init. the script in d runs with the start option by default. We recommend an article titled understanding the Linux system/etc/init. d directory and/etc/rc. local script

By the way, I also learned a lot about vim's usage, such as executing shell commands in multiple windows and vim environments.


The following two script addresses are attached:

Http://soft.vpser.net/lnmp/ext/init.d.nginx

Http://soft.vpser.net/lnmp/ext/init.d.php-fpm5.2


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.