Php+mysql+nginx Environment on Ubuntu (apt-get mode) _php Tutorial

Source: Internet
Author: User
Tags mysql tutorial
Build Php+mysql+nginx Environment on Ubuntu (Apt-get mode)

Ubuntu version: Ubuntu 10.04 LTS

1, first use apt-get download nginx,php tutorial, MySQL tutorial, phpmyadmin,spawn-fcgi.

sudo apt-get install nginx php5-cgi php5-cli mysql-server-5.1 phpmyadmin spawn-fcgi

You may want to enter your MySQL password during the follow-up step.

After OK, you can visit http://127.0.0.1/or http://localhost/in Firefox to see the Nginx Welcome screen.

2, at this time Nginx can not run PHP program. Some configuration files need to be modified.

$ cd/etc/nginx

$ sudo vim fastcgi_params, modified as follows (red section):

Fastcgi_ignore_client_abort on;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;

Fastcgi_param query_string $query _string;
Fastcgi_param Request_method $request _method;
Fastcgi_param Content_Type $content _type;
Fastcgi_param content_length $content _length;

Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param script_name $fastcgi _script_name;
Fastcgi_param Request_uri $request _uri;
Fastcgi_param Document_uri $document _uri;
Fastcgi_param document_root $document _root;
Fastcgi_param server_protocol $server _protocol;

Fastcgi_param Gateway_interface cgi/1.1;
Fastcgi_param server_software nginx/$nginx _version;

Fastcgi_param remote_addr $remote _addr;
Fastcgi_param Remote_port $remote _port;
Fastcgi_param server_addr $server _addr;
Fastcgi_param server_port $server _port;
Fastcgi_param server_name $server _name;

Modify Nginx configuration file nginx.conf

sudo vim nginx.conf, at the end of the following:

User Codebean Codebean; # Users and user groups
Worker_processes 2;

Error_log/var/log/nginx/error.log;
Pid/var/run/nginx.pid;

Events {
Worker_connections 1024;
# multi_accept on;
}

HTTP {
Include/etc/nginx/mime.types;

Access_log/var/log/nginx/access.log;

Sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
Keepalive_timeout 65;
Tcp_nodelay on;

gzip on;
Gzip_disable "MSIE [1-6]. (?!. *SV1) ";

include/etc/nginx/conf.d/*.conf;
include/etc/nginx/sites-enabled/*;
}

3. Next, let's configure a default site:

Cd/etc/nginx/sites-available

sudo vim default

The following changes are followed:

server {
Listen default; #default represents the default site
server_name localhost; # The name of the access
Root/var/www/nginx-default; # Web site root directory

Access_log/var/log/nginx/localhost.access.log;

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

Location ~. php$ {
Include Fastcgi_params; #这个很重要
}

}

Next you create a new index.php in the directory/var/www/nginx-default, enter:

Phpinfo (), then restart the Nginx service and turn on fastcgi:

$ Sudo/etc/init.d/nginx Restart
$/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-c 5/usr/bin/php-cgi

Then visit http://127.0.0.1/or http://localhost/to see

http://www.bkjia.com/PHPjc/629844.html www.bkjia.com true http://www.bkjia.com/PHPjc/629844.html techarticle Ubuntu Build Php+mysql+nginx Environment (Apt-get Way) Ubuntu version: Ubuntu 10.04 LTS 1, first use apt-get download nginx,php tutorial, Mysql tutorial, phpMyAdmin, spawn-fcgi. sudo apt ...

  • 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.