CentOS + Nginx + PHP + MySQL standard production environment configuration method

Source: Internet
Author: User
Tags mcrypt tidy 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)

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.

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.