[root@74-82-173-217 lnmp]# wget http://www.nginx.org/download/nginx-1.0.8.tar.gz
[root@74-82-173-217 lnmp]# tar zxvf nginx-1.0.8.tar.gz
修改 auto/cc/gcc 关闭 debug
[root@74-82-173-217 lnmp]# cd nginx-1.0.8
[root@74-82-173-217 nginx-1.0.8]# ./configure --prefix=/usr/local/nginx-1.0.8 --with-cpu-opt=pentium4 --with-cc-opt=-O3 --user=root --group=root --without-select_module --with-poll_module --without-http_ssi_module --without-http_geo_module --without-http_map_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-google_perftools_module
[root@74-82-173-217 nginx-1.0.8]# make
[root@74-82-173-217 nginx-1.0.8]# make install
把当前 Nginx 目录下 conf 文件复该到 /usr/local/nginx-1.0.8/conf/ 下即可
[root@74-82-173-217 nginx-1.0.8]# cp -rfp /usr/local/nginx/conf/* /usr/local/nginx-1.0.8/conf/
[root@74-82-173-217 nginx-1.0.8]# /usr/local/nginx-1.0.8/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.0.8/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.0.8/conf/nginx.conf test is successful
--with-cc-opt=-O3
由于我购买的是 瑞豪开源(RASHOST) 128M内存,相对CPU来说内存更宝贵,所以节省更多的内存交给CPU处理
--with-google_perftools_module
增加对内存优化 google_perftools_module 具体方法可以查看 Tcmalloc 优化 Nginx Mysql
二、Mysql升级
[root@74-82-173-217 lnmp]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.16.tar.gz/from/http://mysql.mirrors.pair.com/
[root@74-82-173-217 lnmp]# tar zxvf mysql-5.5.16.tar.gz
[root@74-82-173-217 lnmp]# cd mysql-5.5.16
[root@74-82-173-217 mysql-5.5.16]# cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.16/ \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=0 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=0 \
-DWITH_ARCHIVE_STORAGE_ENGINE=0 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8-general_ci \
-DWITH_DEBUG=0
[root@74-82-173-217 mysql-5.5.16]# make
[root@74-82-173-217 mysql-5.5.16]# make install
[root@74-82-173-217 mysql-5.5.16]# cp support-files/mysql.server /etc/init.d/mysqld5516
[root@74-82-173-217 mysql-5.5.16]# chmod 755 /etc/init.d/mysqld5516
由于升级所以不必拷贝my.cnf和初始化数据库
为了节省资源,本站只开启MyISAM引擎,并关闭其他不用的引擎,比如InnoDB,
由于mysql 5.5.* 默认启用InnoDB,所以需要在 my.cnf 添加 default-storage-engine = MyISAM否则会启动失败
三、Php升级
[root@74-82-173-217 lnmp]# wget http://cn.php.net/get/php-5.3.8.tar.gz/from/this/mirror
[root@74-82-173-217 lnmp]# tar zxvf php-5.3.8.tar.gz
[root@74-82-173-217 lnmp]# cd php-5.3.8
[root@74-82-173-217 php-5.3.8]# ./configure --prefix=/usr/local/php-5.3.8 --with-config-file-path=/usr/local/php-5.3.8/etc --with-mysql=/usr/local/mysql-5.5.16 --with-mysqli=/usr/local/mysql-5.5.16/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-fpm-user=www --with-fpm-group=www
[root@74-82-173-217 php-5.3.8]# make ZEND_EXTRA_LIBS='-liconv'
[root@74-82-173-217 php-5.3.8]# make install
[root@74-82-173-217 php-5.3.8]# cp php.ini-production /usr/local/php-5.3.8/etc/
php-fpm配置文件
[root@74-82-173-217 php-5.3.8]# cat /usr/local/php-5.3.8/etc/php-fpm.conf
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = alert
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5
daemonize = yes
rlimit_files = 65536
rlimit_core = 0
[www]
listen = /tmp/php-cgi_www.sock
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests= 500
[blog]
listen = /tmp/php-cgi_blog.sock
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests= 500
启动php-fpm
[root@74-82-173-217 php-5.3.8]# /usr/local/php-5.3.8/sbin/php-fpm
自php-5.3.3以后,不用在打FPM补丁,FPM已内置到PHP中,详细可观看http://cn.php.net/releases/5_3_3.php
新的FPM配置更加灵活,但是 php 5.2.* 和 php 5.3.* 还有以一定差距,请根据实际情况进行升级
--转自