Build a php network service using Ubuntu + Nginx + php + swpan-fcgi

Source: Internet
Author: User
: 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.

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.