Apache + mysql + php that has been installed and can be used normally.
Download the current Pre-BuiltPackages for Stable version (http://nginx.org) for CentOS from the official nginx website http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm)
Run the following command:
Wget http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
Install rpm: rpm-ivh nginx-release-centos-5-0.el5.ngx.noarch.rpm
Install nginx: yum install nginx
Start nginx: service nginx start
Nginx is installed to/usr/sbin/nginx by default,
The configuration file is/etc/nginx/conf. d/default. conf/etc/nginx. conf.
To enable nginx to support php, install php-fpm. Since the previous php version was 5.1.6, I searched the internet for a long time and found no corresponding php-fpm. Finally, we found a fully compiled rpm resource CentALThttp: // centos.alt.ru/pub/repository/centos/ for centos. The php-fpm version is 5.2.17, which is slightly different from 5.1.6, so I decided to use this.
Follow the prompts in CentALT:
First, create the centos.alt.ru. repo file in the/etc/yum. repo. d/directory. The content is as follows:
[CentALT]name=CentALT Packages for Enterprise Linux 5 - $basearchbaseurl=http://centos.alt.ru/repository/centos/5/$basearch/enabled=1gpgcheck=0
Then enable EPEL Repository: (you can run the getconf LONG_BIT or uname-a command to check whether the system is 32-bit or 64-bit)
for i386 rpm -ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpmfor x86_64rpm -ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
Finally, you can use yum install php-fpm for installation.
After the installation is successful, you can start php-fpm: service php-fpm start.
Ps: Many of the 502 bad gateways that often occur when using nginx + php are caused by the absence of php-fpm or the absence of startup even though php-fpm is installed.
Then stop apache and start nginx. Run the following commands:
Service httpd stop
Service nginx start