1. Install php5
The code is as follows: |
Copy code |
Apt-get install php-pear php5-cli php5-common php5-cgi php5-mysql php5-gd php5-dev |
2. Install mysql5
The code is as follows: |
Copy code |
Apt-get install mysql-server mysql-client libipc-sharedcache-perl
|
3. Install nginx
The code is as follows: |
Copy code |
Apt-get install nginx
|
Configure nginx as follows
The code is as follows: |
Copy code |
Sudo vi/etc/nginx/sites-available/default |
The modification points are as follows:
The code is as follows: |
Copy code |
# In this line, index. php is added as the default file. Index. php index.html index.htm; |
Enable fastcgi to process php scripts
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; } |
4. Create a fastcgi control script
The code is as follows: |
Copy code |
Sudo vi/etc/init. d/php-cgi
|
The content is as follows:
The code is as follows: |
Copy code |
#! /Bin/bash BIND = 127.0.0.1: 9000 USER = www-data PHP_FCGI_CHILDREN = 15 PHP_FCGI_MAX_REQUESTS = 1000 PHP_CGI =/usr/bin/php-cgi PHP_CGI_NAME = 'basename $ PHP_CGI' PHP_CGI_ARGS = "-USER = $ user path =/usr/bin PHP_FCGI_CHILDREN = $ PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS = $ PHP_FCGI_MAX_REQUESTS $ PHP_CGI-B $ BIND" RETVAL = 0 Start (){ Echo-n "Starting PHP FastCGI :" Start-stop-daemon-quiet-start-background-chuid "$ USER"-exec/usr/bin/env-$ PHP_CGI_ARGS RETVAL =$? Echo "$ PHP_CGI_NAME ." } Stop (){ Echo-n "Stopping PHP FastCGI :" Killall-q-w-u $ USER $ PHP_CGI RETVAL =$? Echo "$ PHP_CGI_NAME ." } Case "$1 & Prime; in Start) Start ;; Stop) Stop ;; Restart) Stop Start ;; *) Echo "Usage: php-fastcgi {start | stop | restart }" Exit 1 ;; Esac Exit $ RETVAL |
Add the execution permission to/etc/init. d/php-cgi.
The code is as follows: |
Copy code |
Sudo chmod + x/etc/init. d/php-cgi |
Start the php-cgi process
The code is as follows: |
Copy code |
Sudo/etc/init. d/php-cgi start |
To enable php-cgi to start with the system, run the following command:
The code is as follows: |
Copy code |
Sudo update-rc.d php-cgi defaults 25 |