目前nginx的worker_processes設定為4,php-fpm設定為dynamic模式,max_children=32,start_servers=8,min_spare_servers=4,max_spare_servers=16,max_request=512的環境下,540mb記憶體剩餘380mb,相較於之前用zend server ce搭建的lamp記憶體開銷,優化效果還是十分明顯的,而且網站速度也很理想,給我最大的感受就是頁面請求的回應速度比以前大大提升了。
鑑於mysql5.5.8這個新產品發布不久,網上的相關資料匱乏,補充一些自己在編譯上的內容(注意,我因為自己對innodb無需求,因此屏蔽了innodb引擎,如果需要可以開啟參數- dwith_innobase_storage_engine=1。
複製程式碼 程式碼如下:
#download software package
wget http://www.cmake.org/files/v2.8/cmake- 2.8.3.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.4.3.tar.gz
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3/
./configure --prefix=/usr
gmake
gmake install
cd ../
tar zxvf bison-2.4.3.tar.gz
cd cd bison-2.4.3
./configure
make
make install
#install mysql5.5.8
/usr/sbin/groupadd mysql
/ usr/sbin/useradd -g mysql mysql
mkdir -p /data/mysql
chown -r mysql:mysql /data/mysql
tar zxvf mysql-5.5.8.tar.gz
cd mysql-5.5.8
cmake . -dcmake_install_prefix=/usr/local/mysql -dmysql_datadir=/data/mysql -dwithout_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_myisam_storage_engine=1 -dsysconfdir=/etc/ -dwith_ssl=yes -ddefault_charset =utf8 -ddefault_collation=utf8_general_ci -dwith_readline=on
make
make install
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/my/ --datadir=/data/sql mysql --user=mysql
#modify mysql config
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql .sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256m
max_allowed_packet = 1m
table_open_cache =## 256
sort_buffer_size = 1m
read_buffer_size = 1m
read_rnd_buffer_size = 4m
myisam_sort_buffer_size = 64m
thread_cache_size = 8
query_cache_size= 16m
thread_concurrency = 1
basedir = /usr /local/mysql
datadir = /data/mysql
default-storage-engine = myisam
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16m
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 128m
sort_buffer_size = 128muffer_read_ 2m
write_buffer = 2m
[mysqlhotcopy]
interactive-timeout
#add to boot config
cp /usr/local/mysql/support-files/mysql.server /etc /rc.d/init.d/mysqld
chkconfig --add mysqld
/etc/rc.d/init.d/mysqld start
/usr/local/mysql/bin/mysql -u root -p -s /tmp/mysql.sock
以上是基於Nginx+PHP+MySQL怎麼搭建VPS的詳細內容。更多資訊請關注PHP中文網其他相關文章!