Install lnmp (Nginx + PHP + MySQL) fpm in CentOS

Source: Internet
Author: User
Tags epel repo
My VPS, 2 GB memory, 8-core CPU test, but I did not use the above yum installation, but all installed with source code compilation. the test results are as follows:


PHP 5.3.1

MySQL 5.0.89

Nginx 0.8.33 or 0.7.65 (optional)

This is much better than what one-click installation package has been circulated on the internet. it is strongly recommended that this installation method be suitable for all Cainiao and experts. It is difficult to compile and install all the source code used on my server. I have installed some common extensions including php, PDO, eaccelerator, memcache, and tidy.

Minimize CentOS installation, and then create a new repo

# Vi/etc/yum. repos. d/centos.21andy.com. repo

Add the following content

[21Andy.com]
Name = 21Andy.com Packages for Enterprise Linux 5-$ basearch
Baseurl = http://www.21andy.com/centos/5/?basearch/
Enabled = 1
Gpgcheck = 0
Protect = 1

Or use the yum source of the Chinese Emy of science and technology:

# Cd/etc/yum. repos. d

# Mv CentOS-Base.repo CentOS-Base.repo.save

# Wget http://centos.ustc.edu.cn/CentOS-Base.repo

Can also use http://mirrors.163.com/.help/CentOS-Base-163.repo (NetEase, also good)

Enable EPEL repo

CentOS i386 input the following command

Rpm-ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Run the following command in CentOS x86_64:

Rpm-ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Then import the key

Rpm -- import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

OK. One-click installation.

Yum-y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php- pear php-pecl-memcache php-eaccelerator

Last

Yum-y update

It's all the latest.

If you want to use the latest stable version 0.7.65 for nginx

Yum-y install nginx

Change

Yum-y install nginx-stable

You can.

After installation, you can play it like this (note that this tutorial cannot install php-fpm on the i386 platform, prompting that the package does not exist !)

Service mysqld start

Service php-fpm start

Service nginx start

Don't forget to set startup

Chkconfig -- level 345 mysqld on

Chkconfig -- level 345 php-fpm on

Chkconfig -- level 345 nginx on

You can find the configuration files under/etc.

Check whether automatic installation

Dependencies Resolved

========================================================== ============================
Package Arch Version Repository Size
========================================================== ============================
Installing:
Mysql x86_64 5.0.89-1. el5 21Andy.com 3.5 M
Mysql-server x86_64 5.0.89-1. el5 21Andy.com 10 M
Nginx x86_64 0.8.33-3. el5 21Andy.com 422 k
Php-cli x86_64 5.3.1-2. el5 21Andy.com 2.4 M
Php-eaccelerator x86_64. 9.6-1. el5 21Andy.com 118 k
Php-fpm x86_64 5.3.1-2. el5 21Andy.com 1.2 M
Php-gd x86_64 5.3.1-2. el5 21Andy.com 110 k
Php-mbstring x86_64 5.3.1-2. el5 21Andy.com 1.1 M
Php-mcrypt x86_64 5.3.1-2. el5 21Andy.com 27 k
Php-mysql x86_64 5.3.1-2. el5 21Andy.com 84 k
Php-pdo x86_64 5.3.1-2. el5 21Andy.com 91 k
Php-pear noarch. 9.0-1. el5 21Andy.com 420 k
Php-pecl-memcache x86_64 2.2.5-3. el5 21Andy.com 44 k
Php-tidy x86_64 5.3.1-2. el5 21Andy.com 31 k
Php-xml x86_64 5.3.1-2. el5 21Andy.com 115 k
Php-xmlrpc x86_64 5.3.1-2. el5 21Andy.com 48 k
Installing for dependencies:
Gmp x86_64 4.1.4-10. el5 base 201 k
LibXaw x86_64 1.0.2-8.1 base 329 k
LibXmu x86_64 1.0.2-5 base 63 k
LibXpm x86_64 3.5.5-3 base 44 k
Libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
Libmcrypt x86_64 2.5.8-4. el5.centos extras 105 k
Libtidy X 86_64 0.99.0-14.20070615.el5 epel 140 k
Php-common x86_64 5.3.1-2. el5 21Andy.com 554 k
Sqlite2 x86_64 2.8.17-5. el5 21Andy.com 165 k
T1lib x86_64 5.1.1-7. el5 epel 208 k
Updating for dependencies:
Libevent x86_64 1.4.12-1. el5 21Andy.com 129 k

Transaction Summary
========================================================== ============================
Install 26 Package (s)
Update 1 Package (s)
Remove 0 Package (s)

View Nginx + php-fpm Benchmark performance test


The following tests the performance of Nginx + php-fpm on my local virtual machine and VPS respectively.

My local virtual machine test, configured as PD930 dual-core 3.0 GB, 2 GB memory, allocated 1 GB memory to the virtual machine, the installed system is CentOS 5.4 64bit

Test content:

500 concurrent testing, CPU usage reaches 30%, system load is around 10, the page is still fast to open

[Root @ localhost ~] # Website- c 500-t 30 http: // 127.0.0.1/
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/
500 clients, running 30 sec.

Speed = 223504 pages/min, 21806556 bytes/sec.
Requests: 111752 susceed, 0 failed.

2000 concurrent testing, CPU usage 35%, system load around 18, the page is still fast

[Root @ localhost ~] # Website- c 2000-t 30 http: // 127.0.0.1/
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/
2000 clients, running 30 sec.

Speed = 429494 pages/min, 39004788 bytes/sec.
Requests: 214747 susceed, 0 failed.

5000 concurrent testing, CPU usage of 30%, system load to 35, the page playing speed is not bad, read this data, the 15 million PHP request that was said a few days ago has nothing to do

[Root @ localhost ~] # Website- c 5000-t 30 http: // 127.0.0.1/
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/
5000 clients, running 30 sec.

Speed = 788986 pages/min, 66952700 bytes/sec.
Requests: 394493 susceed, 0 failed.

Not quite comfortable yet. Abnormal, 10000 concurrent

10000 concurrency, CPU usage less than 30%, system load increased from around 60 to around 1000, dizzy! It can still be opened! Just a Click card! When the load reaches more than 600, it doesn't even get stuck! Crazy. I am still a virtual machine, and webbench is still running on my own machine. it's too powerful.

[Root @ localhost ~] # Website- c 10000-t 30 http: // 127.0.0.1/
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/
10000 clients, running 30 sec.

Speed = 1513718 pages/min,-17973622 bytes/sec.
Requests: 756859 susceed, 0 failed.

My VPS, 2 GB memory, 8-core CPU test, but I did not use the above yum installation, but all installed with source code compilation. the test results are as follows:

500 concurrency, 20% CPU usage, about 2 loads

# Webbench-c 500-t 30 http: // 127.0.0.1/index. php
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/index. php
500 clients, running 30 sec.

Speed = 120520 pages/min,-36244332 bytes/sec.
Requests: 60260 susceed, 0 failed.

2000 concurrency, CPU usage around 20%, load around 2, no changes

Webbench-c 2000-t 30 http: // 127.0.0.1/index. php
Webbench-Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http: // 127.0.0.1/index. php
2000 clients, running 30 sec.

Speed = 111454 pages/min,-44285944 bytes/sec.
Requests: 55727 susceed, 0 failed.

The same is true for the 3000 concurrency, but it takes a few seconds to open the page. suddenly, it means that the process is running less and there is still room for it.

Now I understand what happened to stable access to the 15 million PHP request a few days ago. haha, you only need to install CentOS 5.4 64bit and then install it using the yum method above.

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.