Varnish+nginx+php(FastCGI)+MYSQL5+MenCache+MenCachedb(2)

二.) 安裝MYSQL
安裝mysql-5.0.45.tar.gz, 下面是整體的編譯文件
1. -static  13%
   --with-client-ldflags=-all-static
   --with-mysqld-ldflags=-all-static
靜態連接提升13%性能
php

2. -pgcc  1%
   CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
     CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \
     -felide-constructors -fno-exceptions -fno-rtti"
若是是Inter處理器,使用pgcc提升1%性能
mysql

3. Unix Socket  7.5%
   --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
使用unix套接字連接提升7.5%性能,因此在windows下mysql性能確定不如unix下面
nginx

4. --enable-assembler
容許使用匯編模式(優化性能)
web


[root@localhost]#tar zxvf mysql-5.0.45.tar.gz
[root@localhost]#./configure --prefix=/usr/local/mysql/ --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread --enable-thread-safe-client
[root@localhost]#make -j 50 && make install
[root@localhost]#groupadd mysql           
[root@localhost]#useradd -g mysql mysql       
[root@localhost]#bin/mysql_install_db --user=mysql     
[root@localhost]#chown -R root  .         
[root@localhost]#chown -R mysql data       
[root@localhost]#chgrp -R mysql .       
[root@localhost]#bin/mysqld_safe --user=mysql &      
[root@localhost]#cd bin         
[root@localhost]#/usr/local/mysql/share/mysql/mysql.server stop    
[root@localhost]#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
[root@localhost]#chmod 755 /etc/init.d/mysql
[root@localhost]#chkconfig --level 345 mysql on
sql

-------------------------------------------------------------------------------------------------------------------------shell


3、)安裝PHP 5.2.5(FastCGI模式)
一、編譯安裝PHP 5.2.5所需的支持庫:windows

[root@localhost]#tar zxvf libiconv-1.11.tar.gz
[root@localhost]#cd libiconv-1.11/
[root@localhost]#./configure --prefix=/usr/local/webserver/lib/libiconv
[root@localhost]#make && make install
[root@localhost]#cd ../緩存

[root@localhost]#tar zxvf freetype-2.3.5.tar.gz
[root@localhost]#cd freetype-2.3.5/
[root@localhost]#./configure --prefix=/usr/local/webserver/lib/freetype
[root@localhost]#make && make install
[root@localhost]#cd ../服務器

[root@localhost]#tar zxvf libpng-1.2.20.tar.gz
[root@localhost]#cd libpng-1.2.20/
[root@localhost]#./configure
[root@localhost]#make && make install
[root@localhost]#cd ../app

[root@localhost]#tar zxvf jpegsrc.v6b.tar.gz
[root@localhost]#cd jpeg-6b/
[root@localhost]#./configure --enable-static --enable-shared
[root@localhost]#make && make install
[root@localhost]#cd ../

t[root@localhost]#ar zxvf gd-2.0.35.tar.gz
[root@localhost]#cd gd-2.0.35/
[root@localhost]#./configure --prefix=/usr/local/webserver/lib/gd --with-freetype=/usr/local/webserver/lib/freetype --with-jpeg --with-png
[root@localhost]#make
[root@localhost]#make install
[root@localhost]#cd ../

[root@localhost]#tar zxvf libxml2-sources-2.6.30.tar.gz
[root@localhost]#cd libxml2-2.6.30/
[root@localhost]#./configure --prefix=/usr/local/webserver/lib/libxml
[root@localhost]#make && make install
[root@localhost]#cd ../


-------------------------------------------------------------------------------------------------------------
二、編譯安裝PHP(FastCGI模式)

[root@localhost]#tar zxvf php-5.2.4.tar.gz
[root@localhost]#cd php-5.2.4/
[root@localhost]#./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --enable-ftp --with-config-file-path=/usr/local/php --enable-zip --with-zlib --with-curl --without-iconv --with-iconv=/usr/local/lib --with-libxml-dir=/usr --enable-xml --with-xmlrpc --enable-mbregex-backtrack --with-gettext --with-gd=/usr/lib --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local/php/lib/freetype --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-dom --enable-safe-mode --enable-discard-path --disable-debug --disable-rpath  --enable-bcmath --enable-shmop --enable-sysvsem --with-ldap --enable-sockets --enable-soap --enable-inline-optimization --enable-mbstring=all --with-ming=/usr --with-pdo-sqlite --enable-pdo --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config

[root@localhost]#cp php.ini-dist /usr/local/php/etc/php.ini
[root@localhost]#cd ../

-----------------------------------------------------------------------------------------------------------------
3.修改php.ini文件
  手工修改:查找/usr/local/php/etc/php.ini中的extension_dir = "./"
  修改成extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
  並在此行後增長如下幾行,而後保存:
  extension = "memcache.so"
  extension = "gd.so"

4.自動修改:若嫌手工修改麻煩,可執行如下shell命令,自動完成對php.ini文件的修改:
[root@localhost]sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "gd.so"\n#' /usr/local/php/etc/php.ini


--------------------------------------------------------------------------------

5.附:編譯PHP以後,爲PHP添加擴展的方法。(本步驟可選)

[root@localhost]#cd php-5.2.4/pcntl
[root@localhost]#/usr/local/php/bin/phpize
[root@localhost]#./configure --with-php-config=/usr/local/php/bin/php-config
[root@localhost]#make && make install
[root@localhost]#cd ../../../

[root@localhost]#cd php-5.2.5/ext/gd/     
[root@localhost]#/usr/local/php/bin/phpize      
[root@localhost]#./configure --with-jpeg-dir --with-png-dir --with-zlib-dir --with-ttf --with-freetype-dir --with-php-config=/usr/local/php/bin/php-config          
[root@localhost]#make -j 50       
[root@localhost]#make install 

利用 Memcached 處理實時數據讀寫;MySQL是影響性能的最大瓶頸,能夠用一臺MySQL主庫(只寫)+多臺MySQL輔庫(只讀)的主輔庫集羣來解決。另外,訪問計數等實時性很強的東西用Memcache作緩存。 
     
[root@localhost]#tar zxvf memcache-2.2.1.tgz     
[root@localhost]#cd memcache-2.2.1/      
[root@localhost]#/usr/local/php/bin/phpize     
[root@localhost]#./configure --with-php-config=/usr/local/php/bin/php-config 
[root@localhost]#make -j 50       
[root@localhost]#make install 
  
安裝支持MYSQL PDO驅動

[root@localhost]#tar xzvf PDO-1\[1\].0.3.tgz                        
[root@localhost]#cd PDO-1.0.3/                                     
[root@localhost]#/usr/local/php/bin/phpize                          
[root@localhost]#./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/   
[root@localhost]#make -j 50        
[root@localhost]#make install 

-------------------------------------------------------------------------------------------------------------

6.安裝lighttpd中附帶的spawn-fcgi,用來啓動php-cgi

 注:壓縮包中的spawn-fcgi程序爲已經編譯成二進制的版本。

[root@localhost]#cp spawn-fcgi /usr/local//php/bin
[root@localhost]#chmod +x /usr/local/php/bin/spawn-fcgi 

七、啓動php-cgi進程,監聽127.0.0.1的10080端口,進程數爲250(若是服務器內存小於3GB,能夠只開啓25個進程),用戶爲www:

/usr/local/php/bin/spawn-fcgi -a 127.0.0.1 -p 10080 -C 250 -u www -f /usr/local/php/bin/php-cgi

8.設定開機啓動

[root@localhost]#echo "/usr/local/mysql/share/mysql/mysql.server start" >> /etc/rc.local
[root@localhost]#echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >> /etc/rc.local
[root@localhost]#echo "/usr/local/php/bin/spawn-fcgi -a 127.0.0.1 -p 10080 -C 250 -u www -f /usr/local/php/bin/php-cgi" >> /etc/rc.local

-------------------------------------------------------------------------

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息