Install Nginx + PHP + MySQL in Ubuntu

Source: Internet
Author: User
Install Nginx + PHP + MySQL on Ubuntu

sudo apt-get install nginx

After Ubuntu is installed, the file structure is roughly as follows:
All configuration files are under/etc/nginx, and each virtual host is already under/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.

[Edit] start nginx

sudo /etc/init.d/nginx start

Then you can access http: // localhost/. everything is normal! If it cannot be accessed, do not continue. check the cause and then continue.

[Edit] configure php and mysql
[Edit] install Php and mysql
Install php and MySQL:

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

[Edit] FastCgi installation
The/usr/bin/spawn-fcgi file is used to manage FastCgi. it originally belongs to the lighttpd package, but after 9.10, spawn-fcgi is separated into a separate package:

sudo apt-get install spawn-fcgi

[Edit] Configure nginx
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:

spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi

To enable php-cgi to boot automatically:

cd /etc/init.d cp nginx php-cgi vim php-cgi

Replace nginx with php-cgi and modify the corresponding part:

DAEMON=/usr/bin/spawn-fcgi DAEMON_OPTS="-a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi" ... stop) echo -n "Stopping $DESC: " pkill -9 php-cgi echo "$NAME."

Run rcconf to set php-cgi to create and test phpinfo at startup:

sudo vi /var/www/nginx-default/info.php

 

Open http: // localhost/info. php.

Related Article

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.