標籤:style http io ar os 使用 for sp 檔案
二.) 安裝MYSQL
安裝mysql-5.0.45.tar.gz, 下面是總體的編譯檔案
1. -static 13%
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
靜態連結提高13%效能
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%效能
3. Unix Socket 7.5%
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
使用unix通訊端連結提高7.5%效能,所以在windows下mysql效能肯定不如unix下面
4. --enable-assembler
允許使用彙編模式(最佳化效能)
[[email protected]]#tar zxvf mysql-5.0.45.tar.gz
[[email protected]]#./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
[[email protected]]#make -j 50 && make install
[[email protected]]#groupadd mysql
[[email protected]]#useradd -g mysql mysql
[[email protected]]#bin/mysql_install_db --user=mysql
[[email protected]]#chown -R root .
[[email protected]]#chown -R mysql data
[[email protected]]#chgrp -R mysql .
[[email protected]]#bin/mysqld_safe --user=mysql &
[[email protected]]#cd bin
[[email protected]]#/usr/local/mysql/share/mysql/mysql.server stop
[[email protected]]#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
[[email protected]]#chmod 755 /etc/init.d/mysql
[[email protected]]#chkconfig --level 345 mysql on
-------------------------------------------------------------------------------------------------------------------------
三、)安裝PHP 5.2.5(FastCGI模式)
1、編譯安裝PHP 5.2.5所需的支援庫:
[[email protected]]#tar zxvf libiconv-1.11.tar.gz
[[email protected]]#cd libiconv-1.11/
[[email protected]]#./configure --prefix=/usr/local/webserver/lib/libiconv
[[email protected]]#make && make install
[[email protected]]#cd ../
[[email protected]]#tar zxvf freetype-2.3.5.tar.gz
[[email protected]]#cd freetype-2.3.5/
[[email protected]]#./configure --prefix=/usr/local/webserver/lib/freetype
[[email protected]]#make && make install
[[email protected]]#cd ../
[[email protected]]#tar zxvf libpng-1.2.20.tar.gz
[[email protected]]#cd libpng-1.2.20/
[[email protected]]#./configure
[[email protected]]#make && make install
[[email protected]]#cd ../
[[email protected]]#tar zxvf jpegsrc.v6b.tar.gz
[[email protected]]#cd jpeg-6b/
[[email protected]]#./configure --enable-static --enable-shared
[[email protected]]#make && make install
[[email protected]]#cd ../
t[[email protected]]#ar zxvf gd-2.0.35.tar.gz
[[email protected]]#cd gd-2.0.35/
[[email protected]]#./configure --prefix=/usr/local/webserver/lib/gd --with-freetype=/usr/local/webserver/lib/freetype --with-jpeg --with-png
[[email protected]]#make
[[email protected]]#make install
[[email protected]]#cd ../
[[email protected]]#tar zxvf libxml2-sources-2.6.30.tar.gz
[[email protected]]#cd libxml2-2.6.30/
[[email protected]]#./configure --prefix=/usr/local/webserver/lib/libxml
[[email protected]]#make && make install
[[email protected]]#cd ../
-------------------------------------------------------------------------------------------------------------
2、編譯安裝PHP(FastCGI模式)
[[email protected]]#tar zxvf php-5.2.4.tar.gz
[[email protected]]#cd php-5.2.4/
[[email protected]]#./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
[[email protected]]#cp php.ini-dist /usr/local/php/etc/php.ini
[[email protected]]#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檔案的修改:
[[email protected]]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添加擴充的方法。(本步驟可選)
[[email protected]]#cd php-5.2.4/pcntl
[[email protected]]#/usr/local/php/bin/phpize
[[email protected]]#./configure --with-php-config=/usr/local/php/bin/php-config
[[email protected]]#make && make install
[[email protected]]#cd ../../../
[[email protected]]#cd php-5.2.5/ext/gd/
[[email protected]]#/usr/local/php/bin/phpize
[[email protected]]#./configure --with-jpeg-dir --with-png-dir --with-zlib-dir --with-ttf --with-freetype-dir --with-php-config=/usr/local/php/bin/php-config
[[email protected]]#make -j 50
[[email protected]]#make install
利用 Memcached 處理即時資料讀寫;MySQL是影響效能的最大瓶頸,可以用一台MySQL主庫(唯寫)+多台MySQL輔庫(唯讀)的主輔庫叢集來解決。另外,訪問計數等即時性很強的東西用Memcache做緩衝。
[[email protected]]#tar zxvf memcache-2.2.1.tgz
[[email protected]]#cd memcache-2.2.1/
[[email protected]]#/usr/local/php/bin/phpize
[[email protected]]#./configure --with-php-config=/usr/local/php/bin/php-config
[[email protected]]#make -j 50
[[email protected]]#make install
安裝支援MYSQL PDO驅動
[[email protected]]#tar xzvf PDO-1\[1\].0.3.tgz
[[email protected]]#cd PDO-1.0.3/
[[email protected]]#/usr/local/php/bin/phpize
[[email protected]]#./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
[[email protected]]#make -j 50
[[email protected]]#make install
-------------------------------------------------------------------------------------------------------------
6.安裝lighttpd中附帶的spawn-fcgi,用來啟動php-cgi
註:壓縮包中的spawn-fcgi程式為已經編譯成二進位的版本。
[[email protected]]#cp spawn-fcgi /usr/local//php/bin
[[email protected]]#chmod +x /usr/local/php/bin/spawn-fcgi
7、啟動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.設定開機啟動
[[email protected]]#echo "/usr/local/mysql/share/mysql/mysql.server start" >> /etc/rc.local
[[email protected]]#echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >> /etc/rc.local
[[email protected]]#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
-------------------------------------------------------------------------
Varnish+nginx+php(FastCGI)+MYSQL5+MenCache+MenCachedb(2)