A small VPS, is not used to the enterprise-class CentOS, and the VPS would have limited resources. Centos+apache2 is really extravagant. My current VPS standard is Php5,mysql 5 and Nginx 1. The following methods hate simple, in the spirit of simple, efficient principle, All apt-get to install, not 15 minutes. If more than 30 minutes, this VPS can not be used: if not a diamond hard drive that is the network problem.
Get the VPS, install Debian 6 32-bit.
Well, update it first.
Apt-get Update
Apt-get Upgrade
Remove some unwanted things and apache2 such resources.
Apt-get-y purge apache2-* bind9-* xinetd samba-* portmap sendmail-* sasl2-bin
(You can add sendmail-* if you don't need sendmail to send mail)
What about your hard drive? Remove some unnecessary components
Apt-get-y Purge Lynx memtester python-* odbcinst-* sudo ttf-*
(also can add UNIXODBC etc.)
We can clean it up.
Apt-get Autoremove
Apt-get Clean
The next outfit Php,mysql and Nginx.
The software version of the official Debian source is too old, too old, too old ... Then let's change the unofficial one. Dotdeb is a good source.
Open/etc/apt/sources.list and save the upload after adding the following two lines
Deb Http://packages.dotdeb.org Stable All
DEB-SRC Http://packages.dotdeb.org Stable All
Then add the certificate of the source
wget HTTP://WWW.DOTDEB.ORG/DOTDEB.GPG
Cat DOTDEB.GPG | Apt-key Add-
Add a new source of course to update
Apt-get Update
Apt-get Upgrade
Then it can be installed, according to their own needs to install the corresponding things, such as GD and other components. For example, I basically use these:
Apt-get Install php5-cli php5-fpm php5-curl php5-mysql nginx mysql-server
About 110M things, in the installation process need to enter the MySQL root password. The other is waiting.
Installation is based on their own VPS configuration settings. The configuration files are under/ETC.
Recommended Modifications:
/etc/nginx/nginx.conf
...
Worker_processes 2;
...
I don't have to change the basics, but I'll open the GZIP_ option.
/etc/php5/fpm/pool.d/www.conf (the full version I used www.conf)
[WWW]
Listen =/tmp/php-www.sock
Listen.mode = 0666
user = Www-data
Group = Www-data
PM = static
Pm.max_children = 8
Pm.max_requests = 5000
Rlimit_files = 512000
Request_slowlog_timeout = 10s
Request_terminate_timeout = 30s
Slowlog =/var/log/php-fpm.slow.log
;p Hp_admin_value[sendmail_path] =/usr/sbin/sendmail-t-i-f www@my.domain.com
;p Hp_flag[display_errors] = off
;p Hp_admin_value[error_log] =/var/log/fpm-php.www.log
;p Hp_admin_flag[log_errors] = off
Php_admin_value[memory_limit] = 24M
Php_admin_value[open_basedir] =/var/www/:/tmp/:/var/tmp/
This is the standard configuration for 256M OpenVZ, adjusting the value of Pm.max_children and Php_admin_value[memory_limit] based on memory size
MySQL 5.5 defaults on the use of InnoDB, and is not a vast project, not used, but also accounted for so many resources, add the following two can
/etc/mysql/my.cnf
[Mysqld]
Default-storage-engine = MyISAM
...
Skip-innodb
and restart the service.
/etc/init.d/nginx Restart
/etc/init.d/php5-fpm restart
/etc/init.d/mysql Restart
Basically this is a very frugal resource to handle your request.
Digression, do not feel nginx will lead to 502, good DAO in the hands of good knife can play the biggest role. There is no need to put nginx on the back end, the front in the add Apache. Our single server with nginx+php run day 20 million dynamic PV no problem.