Ubuntu 10.10 Nginx+php+php-fpm+mysql Simple Setup implementation

Source: Internet
Author: User
Tags gpg
First of all, we need to install MySQL, installed in Ubuntu is very simple, you just need to use the command to simply install the MySQL server:

sudo apt-get install Mysql-server

After installing play MySQL server, we need to install Nginx, it is best to use the official PPA source to install the latest:

You can open the https://launchpad.net/~nginx/+archive/development and refer to its description,

Add the following source to the Ubuntu source.d file: command as follows:

sudo gedit/etc/apt/sources.list

To open the source file add to address:

Deb Http://ppa.launchpad.net/nginx/development/ubuntu Maverick Main


DEB-SRC Http://ppa.launchpad.net/nginx/development/ubuntu Maverick Main

Then add key at the command line,
sudo apt-key adv--keyserver keyserver.ubuntu.com--recv-keys c300ee9

When using this command, you will find that the newspaper:

GPG: "C300ee9" is not a user flag: Skip,

This is because the server HPK server does not recognize the flag for this key and you need to re-fetch it to its server using the following command:

GPG--keyserver subkeys.pgp.net--recv-keys da360c64005e0276

Information can be obtained:

GPG: Created directory '/HOME/JANKEY/.GNUPG '

.......

Ok so we can get a key:005e0276

Then use the command:

sudo apt-key adv--keyserver keyserver.ubuntu.com--recv-keys 005E0276

Then we can install the Nginx:

Use the command:

sudo apt-get install Nginx

After installing PHPY+PHP-FPM and other modules that may be required, use the following command:

sudo apt-get install php5-cgi php5-mysql php5-fpm php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt p Hp5-memcache php5-mhash php5-ming Php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

The above is successfully installed,

The following is a simple configuration:

First configure the php.ini file:

Of course if you appear to install the PHP5-FPM is not successful, please create a www file under Var, then use the command:

sudo apt-get install PHP5-FPM

To install,

If all of the above are OK, let's open the file now:

sudo gedit/etc/php5/fpm/php.ini

Then modify: #cgi, fix_pathinfo=1 modified into cgi.fix_pathinfo=0

Next modification:

sudo gedit/etc/nginx/sites-available/default

# You could add here your
# server {
# ...
# }
# statements for each of your virtual hosts

server {

Listen 80; # # Listen for IPv4
Listen [::]:80 default Ipv6only=on; # # Listen for IPv6

server_name localhost;
root/var/www;
Access_log/var/log/nginx/localhost.access.log;

#access_log/var/www/log/xxx-access.log;
#error_log/var/www/logs/xxx-error.log;

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

Location/doc {
Root/usr/share;
AutoIndex on;
Allow 127.0.0.1;
Deny all;
}

location/images {
Root/usr/share;
AutoIndex on;
}

#error_page 404/404.html;

# REDIRECT Server error pages to the static page/50x.html
#
#error_page 502 503 504/50x.html;
#location =/50x.html {
# root/var/www/nginx-default;
#}

# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#proxy_pass http://127.0.0.1;
#}

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/scripts$fastcgi_script_name;
Include Fastcgi_params;
}

# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
Location ~/\.ht {
Deny all;
}
}


# Another virtual host using mix of ip-, name-, and port-based configuration
#
#server {
#listen 8000;
#listen somename:8080;
#server_name somename alias Another.alias;

#location/{
#root html;
#index index.html index.htm;
#}
#}


# HTTPS Server
#
#server {
#listen 443;
#server_name localhost;

#ssl on;
#ssl_certificate Cert.pem;
#ssl_certificate_key Cert.key;

#ssl_session_timeout 5m;

#ssl_protocols SSLv3 TLSv1;
#ssl_ciphers all:! Adh:! Export56:rc4+rsa:+high:+medium:+low:+sslv3:+exp;
#ssl_prefer_server_ciphers on;

#location/{
#root html;
#index index.html index.htm;
#}
#}


After you modify the above, you need to modify the following:

sudo gedit/etc/nginx/fastcgi_params adds to it:


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_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;

Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param path_info $fastcgi _script_name;
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffer_size 128k;
Fastcgi_buffers 4 256k;
Fastcgi_busy_buffers_size 256k;
Fastcgi_temp_file_write_size 256k;
Fastcgi_intercept_errors on;

# PHP only, required if PHP is built with--enable-force-cgi-redirect
Fastcgi_param Redirect_status 200;

After the completion of the basic OK, remember when you modify a file, do not forget to use this command:

sudo./.. Files that need to be modified CP./To its backup

This is in case you modify a file, if there is an error modification can refer to the original file after the backup repair, it is a habit, please note

Next we need to restart Nginx and PHP-FPM, using the following command:

Sudo/etc/init.d/nginx restart

SUDO/ETC/INIT.D/PHP5-FPM Reload

This will completely complete the purpose we are going to achieve today, to see if it has been successfully set up, create a index.php file under/var/www, okay.

Not much, there is time to introduce more next time

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