Debug note--nginx php-fpm:error:the page You be looking for is temporarily unavailable.,note--nginx_php tutorial

Source: Internet
Author: User
Tags php error php error log syslog vps virtual private server

Debug note--nginx php-fpm:error:the page You be looking for is temporarily unavailable.,note--nginx


1. Install config nginx under ubuntu, MySQL, PHP

Installation steps:

Reference: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04#

Specific excerpts are as follows:

About Lemp

LEMP Stack is a group of open source software to get Web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. Since the server is already running Ubuntu, the Linux part was taken care of. Here's how to install the rest.

Setup

The steps tutorial require the user to has root privileges. You can see how to set the-in-Initial Server Setup Tutorial in steps 3 and 4.

Step one-update Apt-get

Throughout this tutorial we'll be using Apt-get as a installer for all the server programs. On could 8th, a serious PHP vulnerability was discovered, and it's important that we download all of the latest patch Ed software to protect the virtual private server.

Let's do a thorough update.

sudo apt-get update

Step Two-install MySQL

MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server php5-mysql

During the installation, MySQL would ask you to set a root password. If you miss the chance to set the password and the program is installing, it's very easy-to-set the password later from Within the MySQL shell.

Once you has installed MySQL, we should activate it with the This command:

sudo mysql_install_db

Finish up by running the MySQL set up script:

Sudo/usr/bin/mysql_secure_installation

The prompt would ask you to your current root password.

Type it in.

Enter current password to root (enter for none): OK, successfully used password, moving on ...

Then the prompt would ask if you want the root password. Go ahead and choose N and move on to the next steps.

It ' s easiest just to say Yes to the options. At the end, MySQL would reload and implement the new changes.

By default, a MySQL installation had an anonymous user, allowing Anyoneto logs into MySQL without had to had a user ACC  Ount created Forthem.  This was intended only for testing, and the Installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove anonymous users? [y/n] Y ... success!  Normally, Root should only is allowed to connect from ' localhost '. Thisensures that someone cannot guess at the root of password from the network. Disallow Root login remotely? [y/n] Y ... success!  By default, MySQL comes with a database named ' test ' that anyone canaccess. This was also intended only for testing, and should was removedbefore moving into a production environment. Remove test database and access to it? [y/n] y-dropping Test Database ... success! -Removing privileges on test database ... success! Reloading the privilege tables would ensure that all changes made so farwill take effect immediately. REload privilege tables now? [y/n] Y ... success! Cleaning up ...

Once you ' re do with that can finish up by installing PHP.

Step Three-install Nginx

Once MySQL is all set up and we can move on to installing Nginx on the VPS.

sudo apt-get install Nginx

Nginx does not-start on its own. To get Nginx running, type:

sudo service nginx start

You can confirm this nginx has installed a your Web server by directing your browser to your IP address.

You can run the following command to reveal your VPS ' s IP address.

Ifconfig eth0 | grep inet | awk ' {print $} '

Step Four-install PHP

To install the PHP-FPM, open terminal and type in these commands. We'll configure the details of Nginx and PHP details in the next step:

sudo apt-get install PHP5-FPM

Step five-configure PHP

We need to make one small change in the PHP configuration. Open up php.ini:

sudo nano/etc/php5/fpm/php.ini

Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.

Cgi.fix_pathinfo=0

If This number is kept as 1, the PHP interpreter would do it best to process the file, which is as near to the requested Fil e as possible. This is a possible security risk. If This number was set to 0, conversely, the interpreter would only process the exact file path-a much safer alternative. Save and Exit. We need to make another small change in the PHP5-FPM configuration. Open up www.conf:

sudo nano/etc/php5/fpm/pool.d/www.conf

Find the line, listen = 127.0.0.1:9000, and change the 127.0.0.1:9000 to/var/run/php5-fpm.sock.

Listen =/var/run/php5-fpm.sock

Save and Exit.

Restart PHP-FPM:

sudo service php5-fpm restart

Step six-configure Nginx

Open up the default virtual host file.

sudo nano/etc/nginx/sites-available/default

The configuration should include the changes below (the details of the changes are under the config information):

UPDATE: Newer Ubuntu versions create a directory called ' HTML ' instead of ' www ' by default. If/usr/share/nginx/www does not exist, it ' s probably called HTML. Make sure update your configuration appropriately.

[...] server {        listen   ;             root/usr/share/nginx/www;        Index index.php index.html index.htm;        server_name example.com;        Location/{                try_files $uri $uri//index.html;        }        Error_page 404/404.html;        Error_page 502 503 504/50x.html;        Location =/50x.html {              root/usr/share/nginx/www;        }        # Pass the PHP scripts to FastCGI server listening on the PHP-FPM socket location        ~ \.php$ {                try_files $uri =404 ;                Fastcgi_pass Unix:/var/run/php5-fpm.sock;                Fastcgi_index index.php;                Fastcgi_param script_filename $document _root$fastcgi_script_name;                Include Fastcgi_params;                        }} [...]

Here is the details of the changes:

    • ADD index.php to the index line.
    • Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)
    • Change the correct lines in ' location ~ \.php$ {' section

Save and Exit

Step seven-create a php Info Page

We can quickly see all of the details of the new PHP configuration.

To set the this up, first create a new file:

sudo nano/usr/share/nginx/www/info.php

ADD in the following line:

 
   

Then Save and Exit.

Restart Nginx

sudo service nginx restart

You can see the Nginx and PHP-FPM configuration details by visiting http://youripaddress/info.php

Your LEMP Stack is now set up and configured on Your virtual Private server.

2. After installing the installation steps described in the above article, access the PHP file via the browser to get 502 pages: The page you were looking for istemporarily unavailable.

Check nginx error.log file: Found error: Connect to Php5-fpm.sock failed (Permission denied),

Check the permissions of Php5-fpm.sock to get the permissions of other:---

Workaround:

Reference: Http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied

Specific excerpts are as follows:

Note www.conf File accordingly


My FreeBSD system nginx PHP prompt appears the page you were looking for is temporarily unavailable error?

1. Check that the PHP fastcgi process is sufficient:
Netstat-anpo|grep "php-cgi" |wc-l
If the output is 0, it means that the number of fastcgi processes is large enough

2. At this point, modify the Scgi_params file to find:

Scgi_param scgi 1;

Change it to:

Scgi_param scgi 5;

3.PHP program If the execution time exceeds the Nginx wait time, it is possible to increase the timeout time of fastcgi in the nginx.conf configuration file appropriately, for example:
http
{
......
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64k
Fastcgi_buffers 4 64k
......
}

4. Restart fastcgi

Kill the process first: # pkill-9 php-cgi
Then reboot: #/usr/local/bin/spawn-fcgi-a 127.0.0.1-p 9000-u www-g www-f/usr/local/bin/php-cgi

5. Restart Nginx

Kill the process first: # killall-9 Nginx
Then reboot: #/usr/local/sbin/nginx

Other possible situations:

1) access to any PHP file that appears

The page looking is temporarily unavailable.
Please try again later.

2) Access to HTML page, normal

Reason:
Nginx does not normally access PHP via FASTCGI results

1) If it is in the form of a TCP socket, it may be that the process user right is not set

Spawn-fcgi-a 127.0.0.1-p 9000-c 2-u www-data-g www-data-f/usr/bin/php-cgi

Can be changed to www-data or nobody, restart php-cgi process

2) If it is a UNIX socket, there may be no write capability for socket file permissions

Srwxrwxr-x 1 Gavin Gavin 0 11-12 10:18 Php-fcgi.sock

Adding write capabilities to other users

chmod o+w Php-fcgi.sock
Reference: Hi.baidu.com/...7.html ... Remaining full text >>

Nginx PHP fpm How to display error log

configures the file path of the PHP error log in the PHP-FPM configuration file (etc/php-fpm.conf, which is typically located in the PHP installation directory).
; Error log file; If It's set to "Syslog", log was sent to Syslogd instead of being written; In a local file.; note:the default prefix Is/home/wangwei/php/var; The Default Value:log/php-fpm.log;error_log = Log/php-fpm.log is where the error log is configured in my php-fpm.conf file. Take error_log = Log/php-fpm.log before, remove, and then modify to:
; Error log file; If It's set to "Syslog", log was sent to Syslogd instead of being written; In a local file.; note:the default prefix Is/home/wangwei/php/var; Default Value:log/php-fpm.logerror_log =/HOME/WORK/LOG/PHP-FPM.LOG.WF Modified, save the configuration, and then restart the php-fpm is OK.
Note that if you use a relative path, the prefix of the path is based on the Var directory of the PHP installation directory.

 

http://www.bkjia.com/PHPjc/834761.html www.bkjia.com true http://www.bkjia.com/PHPjc/834761.html techarticle Debug note--nginx php-fpm:error:the page You be looking for is temporarily unavailable.,note--nginx 1. Installing the configuration under Ubuntu Nginx, MySQL, PHP installation steps: Reference: HTTPS ...

  • 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.