


debug note-- nginx php-fpm : Error:The page you are looking for is temporarily unavailable.,note--nginx_PHP教程
debug note-- nginx php-fpm : Error:The page you are looking for is temporarily unavailable.,note--nginx
1.在ubuntu下安装配置nginx, mysql, php
安装步骤:
参考:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04#
具体摘抄如下:
<h3 id="About-Lemp">About Lemp</h3> <p>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 is taken care of. Here is how to install the rest.</p> <h2 id="Setup">Setup</h2> <p>The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.</p> <h2 id="Step-One-mdash-Update-Apt-Get">Step One—Update Apt-Get</h2> <p>Throughout this tutorial we will be using apt-get as an installer for all the server programs. On May 8th, 2012, a serious php vulnerability was discovered, and it is important that we download all of the latest patched software to protect the virtual private server.</p> <p>Let's do a thorough update.</p> <pre class="code">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 will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.
Once you have installed MySQL, we should activate it with this command:
sudo mysql_install_db
Finish up by running the MySQL set up script:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password.
Type it in.
Enter current password for root (enter for none): OK, successfully used password, moving on...
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before 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 will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up...
Once you're done with that you can finish up by installing PHP.
Step Three—Install nginx
Once MySQL is all set up, 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 that nginx has installed an 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 $2 }'
Step Four—Install PHP
To install PHP-FPM, open terminal and type in these commands. We will 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 will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will 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 you update your configuration appropriately.
[...] server { listen 80; 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 500 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 are 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 this up, first create a new file:
sudo nano /usr/share/nginx/www/info.php
Add in the following line:
<?php phpinfo(); ?>
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. 按照上述文章介绍的安装步骤安装之后,通过浏览器访问php文件得到502页面:The page you are looking for is temporarily unavailable.
检查nginx的error.log文件: 发现错误:connect to php5-fpm.sock failed (Permission denied),
检查php5-fpm.sock的权限得到other的权限为:---
解决方法:
参考:http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied
具体摘抄如下:
<p><strong> Note</strong>: if your webserver runs as as user other than www-data, you will need to update the <code>www.conf</code> file accordingly</p>
1. First check whether the number of PHP FastCGI processes 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 time, modify the scgi_params file and find:
scgi_param SCGI 1;
Change it to:
scgi_param SCGI 5;
3. If the execution time of the PHP program exceeds the waiting time of Nginx, you can appropriately increase the FastCGI timeout time in the nginx.conf configuration file, for example:
http
{
……
fastcgi_connect_timeout 300; Restart FastCGI
First kill the process: # pkill -9 php-cgi
Then restart: # /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
First kill the process: # killall -9 nginx
Then restart: # /usr/local/sbin/nginx
Other possible situations:
1) Access any PHP file, and
The page you are looking for is temporarily unavailable.
Please try again later.
2) Access the html page, normal
Cause:
nginx cannot access PHP normally through FastCGI results
1) If it is in the form of tcp socket, it may be the process user permission setting Wrong
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 For www-data or nobody, restart the php-cgi process
2) If it is a unix socket, the socket file permissions may not allow writing
srwxrwxr-x 1 gavin gavin 0 11-12 10 :18 php-fcgi.sock
Add writing capabilities for other users
chmod o+w php-fcgi.sock
Reference: hi.baidu.com/... 7.html...The rest of the full text>>
How to display error log in nginx php fpm
http://www.bkjia.com/PHPjc/834761.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/834761.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To allow the Tomcat server to access the external network, you need to: modify the Tomcat configuration file to allow external connections. Add a firewall rule to allow access to the Tomcat server port. Create a DNS record pointing the domain name to the Tomcat server public IP. Optional: Use a reverse proxy to improve security and performance. Optional: Set up HTTPS for increased security.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

To solve the "Welcome to nginx!" error, you need to check the virtual host configuration, enable the virtual host, reload Nginx, if the virtual host configuration file cannot be found, create a default page and reload Nginx, then the error message will disappear and the website will be normal show.

There are five methods for container communication in the Docker environment: shared network, Docker Compose, network proxy, shared volume, and message queue. Depending on your isolation and security needs, choose the most appropriate communication method, such as leveraging Docker Compose to simplify connections or using a network proxy to increase isolation.

Converting an HTML file to a URL requires a web server, which involves the following steps: Obtain a web server. Set up a web server. Upload HTML file. Create a domain name. Route the request.

Server deployment steps for a Node.js project: Prepare the deployment environment: obtain server access, install Node.js, set up a Git repository. Build the application: Use npm run build to generate deployable code and dependencies. Upload code to the server: via Git or File Transfer Protocol. Install dependencies: SSH into the server and use npm install to install application dependencies. Start the application: Use a command such as node index.js to start the application, or use a process manager such as pm2. Configure a reverse proxy (optional): Use a reverse proxy such as Nginx or Apache to route traffic to your application

The most commonly used instructions in Dockerfile are: FROM: Create a new image or derive a new image RUN: Execute commands (install software, configure the system) COPY: Copy local files to the image ADD: Similar to COPY, it can automatically decompress tar archives or obtain URL files CMD: Specify the command when the container starts EXPOSE: Declare the container listening port (but not public) ENV: Set the environment variable VOLUME: Mount the host directory or anonymous volume WORKDIR: Set the working directory in the container ENTRYPOINT: Specify what to execute when the container starts Executable file (similar to CMD, but cannot be overwritten)

Yes, Node.js can be accessed from the outside. You can use the following methods: Use Cloud Functions to deploy the function and make it publicly accessible. Use the Express framework to create routes and define endpoints. Use Nginx to reverse proxy requests to Node.js applications. Use Docker containers to run Node.js applications and expose them through port mapping.
