Ubuntu install Nginx + PHP5 (PHP-FPM) + MySQL host details

Source: Internet
Author: User
Tags mysql host ssh server
I haven't installed the web server in Ubuntu for a long time. Today I want to train my hands and perform a test on the virtual machine. I shouldn't have guaranteed that you will succeed. Please refer to it! Symptoms I will introduce the basic system situation: Virtual Machine (OracleVM) Operating System Ubuntu12.04server (I only chose sshserver when installing the system) the real machine and virtual machine use the bridging method to set the static IP Address: 192.168.1.208 applicable to personal settings 1. first, to install

I haven't installed the web server in Ubuntu for a long time. Today I want to train my hands and perform a test on the virtual machine. I shouldn't have guaranteed that you will succeed. Please refer to it!

Symptoms:

Virtual Machine (Oracle VM)
Operating system Ubuntu 12.04 server (I only select ssh server when installing this system)
Bridging between a real machine and a virtual machine
Set to static IP Address: 192.168.1.208 applicable personal settings
1. For installation convenience, switch to the root account and enter the following command:

Sudo su
2 install MySQL 5

Apt-get install mysql-server mysql-client
The system will prompt you to set the password and enter the password twice:

New password for the MySQL "root" user: (enter the password)
Repeat password for the MySQL "root" user: (enter again)

3. Install Nginx

Apt-get install nginx
Start the Nginx service:

/Etc/init. d/nginx start
Enter the URL in the browser to check whether the URL is normal: http: // 192.168.1.208 (change it to your static IP address)

"Welcome to nginx!" is displayed on the webpage !" It indicates that the installation is successful and runs.

4. Install PHP5

Apt-get install php5-fpm
5. Set nginx and modify the file:
Vi/etc/nginx. conf
Modify the following two lines of code:

Worker_processes 4;
Keepalive_timeout 2; modify the VM configuration file:
Vi/etc/nginx/sites-available/default
The following figure shows the modified Code:

Server {
Listen 80; # listen for ipv4; this line is default and implied
Listen [:]: 80 default ipv6only = on; # listen for ipv6
Root/usr/share/nginx/www;
Index. php index.html index.htm;
# Make site accessible from http: // localhost/
Server_name _;
Location /{
# First attempt to serve request as file, then
# As directory, then fall back to index.html
Try_files $ uri // index.html;
}
Location/doc {
Root/usr/share;
Autoindex on;
Allow 127.0.0.1;
Deny all;
}
# Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/usr/share/nginx/www;
}
# 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 Fig: 9000
#
Location ~ \. Php $ {
Try_files $ uri = 404;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
Location ~ /\. Ht {
Deny all;
}
}

Reload nginx:
/Etc/init. d/nginx reload
Create a probe file and test:

Vi/usr/share/nginx/www/info. php
Write content

Phpinfo ();
?> Then open the browser and enter: http: // 192.168.1.208/info. php.

The supported modules are displayed and supported modules are added. Enter the following command to query the PHP module:
Apt-cache search php5

The module and module function explanation will be displayed. (In English, you need some English skills. Google or Baidu will translate and learn more)
For example, enter the following command to install the required module:
Apt-get install php5-mysql php5-curl php5-gd php5-intl php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp
Restart php5-fpm after installation
/Etc/init. d/php5-fpm restart

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.