CentOS + Nginx + PHP + MySQL

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

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:

<? Php phpinfo ();?>

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.