Install nginx + php + memcached in ubuntu

Source: Internet
Author: User

1. Install nginx

sudo apt-get install nginx

All configuration files are in/etc/nginx, and the virtual host is configured in/etc/nginx/sites-available.

Program file in/usr/sbin/nginx

Logs are stored in/var/log/nginx.

The Startup Script nginx has been created under/etc/init. d /.

The default virtual host directory is/var/www/nginx-default.

Start nginx

sudo /etc/init.d/nginx startsudo /etc/init.d/nginx reload

 

2. install php

sudo apt-get install php5-cli php5-cgi php5-mysql

3. InstallFastCgi

 apt-get install php5-cgi

You can also install spawn-fcgi. spawn-fcgi is the fastcgi Management Program, which is a project independent of Lighthttpd. In actual operation, you can use php-fpm (fastcgi php manager of php). php 5.3.3 to bring php-fpm, but my current version is php 5.3.2.

Run with spawn-fcgi

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

Parameter meaning:

*-F specifies the location of the execution program of the process that calls FastCGI, set *-a to bind to the address addr *-p to the port *-s to bind to the path *-C of the unix socket according to the PHP installed on the system. fastCGI process count, the default value is 5 (for PHP only) *-P, which specifies the PID file path of the generated process *-u and-g FastCGI (-u user-g user group, www-data can be used in Ubuntu. Other configurations, such as nobody and apache, can be used as needed.

Restart fcgi

Php-cgi: First kill the process

sudo killall -HUP php5-cgi

Restart fcgi

4. Configure nginx to support php

Modify the nginx configuration file:/etc/nginx/sites-available/default modify the Host Name:

server_name localhost;

Modify the row of index:

index index.php index.html index.htm;

Remove the following comments to support php scripts:

location ~ \.php$ {    fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;    include /etc/nginx/fastcgi_params;}

Restart nginx:

/etc/init.d/nginx stop/etc/init.d/nginx start

Start fastcgi php:

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

6. Install the memcached server.

sudo apt-get install memcached

Start memcached Service

memcached -d -m 128 -p 11111 -u root

Parameter description:

-P listening port-l connection IP address, the default value is local-d start to start memcached service-d restart to restart memcached service-d stop | shutdown to disable the running memcached service-d install to install memcached service-d uninstall to uninstall memcached service-u run as (only valid when running as root) -MB maximum memory usage, in MB. By default, an error is returned when 64MB-M memory is used up, instead of deleting the maximum number of concurrent connections in item-c. The default value is 1024-f, and the default value is 1.25-n, key + value + flags are 48-H display help by default

Check whether the service is started

ps aux | grep memcached

  

7. Install the memcached php extension.

sudo apt-get install php5-memcached

After the installation is complete, restart nginx and fcgi to make memcached take effect.

 

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.