Switch from apche to nginx on CentOS 5 web server

Source: Internet
Author: User

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


Related Article

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.