1. Use the official PPA to install the latest Nginx version. Run the following command:
The code is as follows: |
Copy code |
Sudo add-apt-repository ppa: nginx/stable Sudo apt-get update Sudo apt-get install nginx |
Nginx control commands:
Start Nginx:
Sudo/etc/init. d/nginx start
Enter "http: // localhost" in the browser browsing and running Status. If "Welcome to nginx!" appears !", It indicates that your Nginx server is successfully installed!
For more information, see the following command to stop Nginx and restart the server:
Disable Nginx: sudo/etc/init. d/nginx stop
Restart nginx: sudo/etc/init. d/nginx restart
2. Run the following command to install PHP:
The code is as follows: |
Copy code |
Sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt
|
Extended reading: If you still need to install other php libraries such as curl imap support, please refer to the following content (please choose to install according to your needs)
###
The code is as follows: |
Copy code |
Sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode
|
Remember to restart fpm after installation.
The code is as follows: |
Copy code |
/Etc/init. d/php5-fpm restart ### |
Configure the Nginx site and set:
Sudo vi/etc/nginx/sites-available/default
Modify "index" to "index index.html index.htm index. php ;"
Modify the "root" directory to "root/var/www ;"
Find the following content and remove the corresponding # comment as follows:
The code is as follows: |
Copy code |
Location ~ \. Php $ { Fastcgi_split_path_info ^ (. + \. php) (/. +) $; # NOTE: You shoshould have "cgi. fix_pathinfo = 0;" in php. ini # # With php5-cgi alone: Fastcgi_pass 127.0.0.1: 9000; # With php5-fpm: # Fastcgi_pass unix:/var/run/php5-fpm.sock; Fastcgi_index index. php; Include fastcgi_params; }
|
Create website root directory
The code is as follows: |
Copy code |
Sudo mkdir/var/www/ Create a test page: Sudo vi/var/www/test. php |
Add the following code to test. php on the test page:
The code is as follows: |
Copy code |
<? Php phpinfo ();?> Restart nginx Sudo/etc/init. d/nginx restart |
Enter the following address in the browser to check whether the installation is successful!
Http: // localhost/test. php
3. Install the MySQL database:
The code is as follows: |
Copy code |
Apt-get install mysql-server mysql-client
|
During installation, you will be asked to enter the password of the root account twice.
4. Install phpmyadmin
The code is as follows: |
Copy code |
Apt-get install phpmyadmin
|
During the installation process, you will be asked to enter the mysql account password. If any error is reported, skip this step.
Establish a connection
The code is as follows: |
Copy code |
Ln-s/usr/share/phpmyadmin/var/www/phpmyadmin
|
Test whether phpmyadmin works properly.
Open http: // localhost/phpmyadmin in the browser.