Easy solution to centos + nginx + PHP + MySQL standard production environment

Source: Internet
Author: User
Tags mcrypt tidy vps epel repo

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

Enable epel Repo

Centos i386 input the following command

Rpm-ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.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-3.noarch.rpm

Then import the key

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

Copy code

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

Finally, update Yum-y, which is 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.

You can do this after installation.

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)

Click the next page to view the performance test of nginx + PHP-FPM benchmark.

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 isCentos 5.4 64bit

Test content:

<? PHP phpinfo ();?>

500In the concurrency test, the CPU usage reaches 30%, and the system load is10Left and Right, page opening is still fast

[Root @ localhost ~] #Webbench-C 500-T 30Http: // 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.

2000Concurrency test, CPU usage 35%, system load in18Left and Right, page opening is still fast

[Root @ localhost ~] #Webbench-c 2000-T 30Http: // 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.

5000Concurrency test, CPU usage 30%, system load35The page playing speed is good. After reading this data, the 15 million PHP request mentioned the other day is useless.

[Root @ localhost ~] #Webbench-C 5000-T 30Http: // 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

10000Concurrency, CPU usage less than 30%, system load from60Rising from left to right1000Left and Right, dizzy! It can still be opened! Just a click card! Load600When there are many, they don'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 ~] #Webbench-C 10000-T 30Http: // 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 30Http: // 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 30Http: // 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.

Author: 21 Andy Source: Andy's blog

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.