PHP Installation under Nginx environment
Actually very simple thing, every time I install seems to be detours, so write it down
?
CentOS 5.5 Nginx 1.0.5Php 5.5.8
?
1. Install Nginx First
#tar-ZXVF nginx-1.0.5.tar.gz#cd Nginx-1.0.5#./configure#make#make Install
?
2. Install PHP, using FastCGI installation method, check the advantages and disadvantages of the next fastcgi, for reference (excerpt from the network)
"Note: I have already installed MySQL because there are not so many special places, so don't make a note."
Advantage
- PHP scripts run more quickly (3 to 30 times times). The PHP interpreter is loaded into memory without having to read from memory every time it is needed, greatly improving the performance of the site that relies on the script to run.
- Fewer system resources are required. Because the server does not need to load PHP interpreter every time, you can increase the transfer speed of the site without increasing the CPU burden.
- There is no need to make any changes to the existing code. All that's available is for PHP fastcgi
Potential problems
- For all subdirectories (/home/username/public_html/php.ini) you have only one available php.ini file. This is necessary to optimize the site code. If you need multiple php.ini files to accommodate different scripting needs, you can disable PHP's fast CGI in any subdirectory, while the rest of the places continue to work. If you need to do this please contact support.
- Any upgrades you make to the PHP environment, such as changes to the php.ini file, have a few minutes of delay. This is because your php.ini files have been loaded into memory for faster speeds, rather than being re-read from memory every time you need them.
I did not consider the problem of php.ini when I installed it, just think about the good php-fpm.conf.
The installation of PHP is really slightly different, simply put, as a separate service launched
#tar-ZXVF php-5.3.8.tar.gz#cd php-5.3.8//Compile when you must add parameters--enable-fpm#./configure--prefix=/usr/local/php--WITH-GD-- Enable-gd-native-ttf--enable-gd-jis-conv--with-mysql=/usr/local/mysql/ --with-pdo-mysql=/usr/local/mysql-- Enable-soap--enable-sockets--enable-zip--enable-xml--with-curl--enable-mbregex--enable-sysvsem-- enable-mbstring--with-mcrypt--enable-fpm#make#make Install
?
3. Configure PHP and Nginx
1. Start PHP with PHP-FPM
#cd/usr/local/php/etc/#cp php-fpm.conf.default php-fpm.conf#vi php-fpm.conf//Find the following lines to ensure that the following lines are not ";" PID = Run/php-fpm.piderror_log = Log/php-fpm.loglisten = 127.0.0.1:9000pm.max_children = 50pm.start_servers = 20pm.min_ Spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500
The php5.5.8 version provides PHP-FPM management tools that can be conveniently start,stop,restart
It's just my personal habit of throwing PHP-related commands in this #cd/usr/local/php/sbin///copy the file in the installation file #cp/downloads/php-5.3.8/sapi/fpm/init.d.php-fpm./# chmod 755 init.d.php-fpm//Start | Stop | RESTART#./INIT.D.PHP-FPM start
?
2.nginx configuration?
#vi/usr/local/nginx/conf/nginx.conf//Remove the previous "#"//Script_filename if you fill in the wrong, then display a blank page location ~ \.php$ { root html; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include fastcgi_params; } #vi/usr/local/nginx/conf/fastcgi_params//commented out the line, but still do not know why #fastcgi_param redirect_status 200;
? start Nginx
#cd/usr/local/nginx/sbin///Test configuration file correctly #./nginx-t//start #./nginx/reload #./nginx-s reload//Restart #./nginx-s reopen
?
?
?
?