Install Ubuntu 10.04 + nginx + php5 + php-fpm and configure multiple sites

Source: Internet
Author: User
Tags fpm phpmyadmin

First, set the source of the latest stable version of nginx and the source of php-fpm.

Sudo gedit/etc/apt/sources. list
Add source

Deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main
Deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
The deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
Then add the Key and update it:

Apt-key adv-keyserver keyserver.ubuntu.com-recv-keys C300EE8C
Sudo apt-key adv-keyserver keyserver.ubuntu.com-recv-keys 8D0DC64F
Sudo apt-get update
First, install the latest stable version of Nginx

Apt-get install nginx
Nginx is installed. Let's test whether it is OK.

Sudo/etc/init. d/nginx start
Access: http: // localhost, OK, accessible
Note: If there is no/var/www directory, you can create one by yourself.

Then we installed php5.3 and a bunch of related things.

Sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json php5-suhosin
Install php5-cgi and php5-fpm

Sudo apt-get install php5-fpm php5-cgi
Start CGI

/Etc/init. d/php5-fpm start
Then we Configure nginx: sudo gedit/etc/nginx/site-available/default

My configuration is as follows:

Server {
Listen 80;
Server_name localhost;
Root/var/www;

Access_log/var/log/nginx/localhost. access. log;
Error_page 404/404 .html;

Location /{
Index index.html index.htm index. php;
    }

Location ~ * ^. +. (Jpg | jpeg | gif | css | png | js | ico | xml) $ {
Access_log off;
Expires 30d;
Root/var/www;
    }


Location ~ . Php $ {
Fastcgi_split_path_info ^ (. +. php) (. *) $;
Fastcgi_pass backend;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www $ fastcgi_script_name;
Include fastcgi_params;
Fastcgi_intercept_errors on;
Fastcgi_ignore_client_abort off;
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffer_size 128 k;
Fastcgi_buffers' 4 256 k;
Fastcgi_busy_buffers_size 256 k;
Fastcgi_temp_file_write_size 256 k;

    }

Location ~ /. Ht {
Deny all;
    }

}

Upstream backend {
Server 127.0.0.1: 9000;
}
Configure site 2
Sudo cp default arlicle
Change server_name to www.arlicle.com arlicle.com;
Modify the corresponding directory and execute the following commands to start the arlicle site.

Sudo ln-s/etc/nginx/sites-available/arlicle/etc/nginx/sites-enabled/arlicle
Sudo/etc/init. d/nginx reload
Access and test. Normal.

Finally, we install the acceleration engine:

Sudo pecl install memcache
Sudo apt-get install libpcre3-dev
Sudo pecl install apc
Note:

Add phpmyadmin to access:
Ln-s/usr/share/phpmyadmin/var/www/phpmyadmin.

Set the size of the nginx file to be uploaded:/etc/nginx. conf
Clientmaxbody_size 30 M;

Modify the php. Ini file:/etc/php5/fpm
Postmaxsize = 30 M

When nginx is configured to access php, the error 404 of php does not exist. In the configuration file, add

Error_page 404/404 .html;

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.