Stop Php installation in Nginx

Source: Internet
Author: User
Tags blank page
In the Nginx environment, Php installation is actually very simple. every time I install it, it seems like a detour, so I should write it down? CentOS5.5Nginx1.0.5Php5.5.8? 1.install nginxrjtar-zxvfnginx-1.0.5.tar.gz # cdnginx-1.0.5 #./co install Php in Nginx environment first

In fact, it is very simple. every installation seems to be a detour, so remember it.

?

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. check the advantages and disadvantages of fastcgi for reference (excerpted from the network)

[Note: I have installed Mysql. I will not describe it because there are not many special items]

Advantages

  1. PHP scripts run faster (3 to 30 times ). The PHP interpreter program is loaded into the memory instead of reading from the memory every time it is needed, which greatly improves the performance of the site running by scripts.
  2. Fewer system resources are required. Because the server does not need to load the PHP interpreter every time it needs to, you can increase the transmission speed of the site significantly without increasing the cpu burden.
  3. You do not need to change the existing code. Everything is applicable to FastCGI of PHP.

Potential problems

  1. You only have one available php. ini file for all subdirectories (/home/USERNAME/public_html/php. ini. This is necessary to optimize the website code. If you need multiple php. INI files to adapt to different script needs, you can disable PHP's quick CGI in any subdirectory, while the rest will continue to be effective. If you need to do this, contact support.
  2. Any upgrades you make to the PHP environment (such as changes to the php. ini file) will be delayed for several minutes. This is because your php. ini file has been loaded into the memory for a higher speed, rather than being re-read from the memory every time you need it.

I didn't think about the php. ini issue during installation, as long as I think about the php-fpm.conf.

Php installation is indeed a little different. Simply put, it is started as a separate service.

# Tar-zxvf php-5.3.8.tar.gz # cd php-5.3.8 // you must add the parameter -- enable-fpm # When compiling #. /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 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, make sure the following lines are not "; & quot; pid = run/php-fpm.piderror_log = log/php-fpm.loglisten = 127.0.0.1: 9000pm. max_children = 50pm. start_servers = 20pm. min _spare_servers = 5. max_spare_servers = 35pm. max_requests = 500

? Php5.5.8 provides a php-fpm management tool, which can easily start, stop, and restart

// I personally get used to leaving php-related commands here # cd/usr/local/php/sbin // Copy this 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 an error is entered, a blank page is displayed. 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 // comment out this line, I do not know why # fastcgi_param REDIRECT_STATUS 200;

? Start nginx

# Cd/usr/local/nginx/sbin // test whether the configuration file is correct #. /nginx-t // start #. /nginx // reload #. /nginx-s reload // restart #. /nginx-s reopen
?

?

?

?

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.