: This article describes how to build a php network service using Ubuntu + Nginx + php + swpan-fcgi. if you are interested in the PHP Tutorial, refer to it. The environment in this article is Ubuntu 12, which can be accessed by other systems or communicated with me.
1. install nginx
This step is relatively simple. you can directly install nginx by using sudo apt-get install. After installation, set the nginx service port. its default port is 80.
2. set the nginx service port
The configuration file is in/etc/nginx. conf. the configuration file references sites-enabled/default, which can be configured as follows:
listen 8081 default_server; listen [::]:8081 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm;
8081 is the port I set. The original "80. root" directory is the directory corresponding to the website file and can be set to a custom directory. Index specifies the homepage priority.
In addition, configure the php parser port (php-cgi ):
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: fastcgi_pass 127.0.0.1:3344; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
In my configuration file, set the service port of php-cgi to 3344. Note the following when starting spawn-fcgi:
Restart nginx,
Service nginx restart
3. install spawn-fcgi,
Apt-get install spawn-fcgi
4. install php
Apt-get install php5 php5-dev php5-cgi
5. start php-cgi and bind Port 3344
Sudo spawn-fcgi-a 0.0.0.0-p 3344-C 10-u root-f/usr/bin/php-cgi
I forgot to add sudo before. It was very strange to have an error during startup.
6. test the php environment
Add the test. php file to/usr/share/nginx/html/. if the website directory is not the same, add test. php to the corresponding directory. the content is as follows:
Enter the URL: localhost: 8081/test. php to check the result.
The above section describes how to build a php network service using Ubuntu + Nginx + php + swpan-fcgi, including some content, and hope to help those who are interested in the PHP Tutorial.