- 論壇徽章:
- 0
|
Linux+Cherokee+Mysql+Php+Zend
軟件介紹:
操作系統(tǒng): Centos 5.4 ——————————————————————————–
Web 服務(wù)端: cherokee-0.99.44.tar.gz ————————————————————-
Php引擎: php-5.2.13.tar.gz ————————————————————————-
FastCgi: php-5.2.13-fpm-0.5.13.diff.gz ————————————————————
數(shù)據(jù)庫(kù): mysql-5.0.51b.tar.gz ————————————————————————-
Zend引擎 ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz——————————————-
擴(kuò)展模塊:
freetype-2.3.9.tar.gz —————————————————————————
libpng-1.2.38rc02.tar.gz ———————————————————————–
zlib-1.2.3.tar.gz ——————————————————————————–
libpng-1.2.38rc02.tar.gz ———————————————————————–
jpegsrc.v7.tar.gz ——————————————————————————–
Libiconv-1.13.tar.gz —————————————————————————–
gd-2.0.33.tar.gz ———————————————————————————
libmcrypt-2.5.8.tar.gz —————————————————————————–
mcrypt-2.6.8.tar.gz —————————————————————————–
memcache-2.2.5.tgz —————————————————————————-
mhash-0.9.9.9.tar.gz —————————————————————————-
eaccelerator-0.9.5.3.tar.bz2 ——————————————————————–
軟件下載:
我是在/~下 mkdir soft cd soft vi down.sh
#!bin/bash/
#
wget http://www.cherokee-project.com/cherokee-latest-tarball
wget http://www.php.net/get/php-5.2.13.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.13-fpm-0.5.13.diff.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.2-m2.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
wget http://downloads.sourceforge.net ... 60&big_mirror=0
wget http://downloads.sourceforge.net ... 73&big_mirror=0
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget http://downloads.sourceforge.net ... 43&big_mirror=0
wget ftp://ftp.csx.cam.ac.uk/pub/soft ... re/pcre-8.01.tar.gz
wget http://bart.eaccelerator.net/sou ... rator-0.9.6.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/ ... /ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget http://download.scientificlinux. ... glibc23-i386.tar.gz
:wq
chmod +x down.sh
./down.sh
系統(tǒng)環(huán)境
系統(tǒng)分區(qū)
/boot
SWAP
/opt /*軟件都可以安裝到這個(gè)目錄方便管理*/
/www /*web程序可以放在此目錄里方便管理,包括虛擬目錄*/
/bak /*可以通過(guò)contab控制備份腳本來(lái)備份web文件和數(shù)據(jù)庫(kù)文件*/
/Data /*生產(chǎn)環(huán)境加上這個(gè)目錄把數(shù)據(jù)庫(kù)可以安裝在此*/
/
保留的系統(tǒng)服務(wù)
Atd; Crond; Irqblance; Microcode_ctl; network; Sendmail; sshd; syslog
Yum安裝更新同時(shí)更新軟件
Wget http://centos.ustc.edu.cn/CentOS-Base.repo
cp CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
rpm–import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
yum grouplist
yum groupinstall “Development Tools”
安裝所需的軟件用Yum install xxxxxx
安裝程序
Cherokee官方網(wǎng)站 http://www.cherokee-project.com/
安裝Cherokee
tar zxvf cherokee-0.99.44.tar.gz
cd cherokee-0.99.44.tar.gz
./configure –prefix=/opt/Cherokee –localstatedir=/var –sysconfdir=/etc –with-wwwroot=/www –disable-ipv6 –with-mysql
Make
Make install
啟動(dòng)cherokee
Cd /opt/Cherokee/sbin
./Cherokee-admin –b &
使用netstat –anp|grep 9090看看端口是否存在。
這里會(huì)提供用戶名和一次性的密碼,在瀏覽器打開http://yourserverip:9090 寫入啟動(dòng)時(shí)生成的用戶名和密碼登陸后,在頁(yè)面內(nèi)啟動(dòng)服務(wù)。啟動(dòng)后用http://yourserverip看看是否能看到cherokee的默認(rèn)頁(yè)面。
Parameter Description
–with-wwwroot=DIR Specify the webserver root directory
–with-wwwuser=USER Custom username under which the server will run
–with-wwwgroup=GROUP Custom group under which the server will run
–disable-epoll Disable epoll() support
–disable-pthread Disable threading support
–disable-readdir_r Disable readdir_r usage
–disable-ipv6 Disable IPv6 support
–disable-pam Disable PAM support
–enable-trace Allows debugging options
–disable-admin Skips cherokee-admin installation
–disable-largefile omit support for large files
–enable-internal-pcre Enable internal PCRE
–disable-nls do not use Native Language Support
–enable-static-module=MODULE build listed modules as static. Accepts ALL
———————————————————————————————————-
建立所需的用戶組
Groupadd mysql \\建立mysql用戶組
Useradd –g mysql mysql \\增加mysql用戶到mysql用戶組
Groupadd www \\建立www用戶組
Useradd –g www www \\增加www用戶到www用戶組
———————————————————————————————————————————————————————————————–
安裝Mysql5
tar zxvf mysql-5.0.51b.tar.gz
cd mysql-5.0.51b
./configure –prefix=”/opt/mysql5″ –with-comment=Source –with-server-suffix=-enterprise-gpl –with-mysql-user=mysql –without-debug –with-socket-path=”/opt/mysql5/var/mysql.sock” –with-big-tables –with-charset=gbk –with-collation=gbk_chinese_ci –with-extra-charsets=all –with-pthread –enable-static –enable-thread-safe-client –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –without-innodb –without-ndb-debug –without-isam –enable-local-infile –with-readline –with-raid
Make
Make install
cd /opt/mysql5
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db –user=mysql
chown -R root .
chown -R mysql var
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 3 mysqld on
啟動(dòng)mysql
service mysqld start
修改mysql的root密碼
mysqladmin -u root -p PASSWORD yourpassword
———————————————————————————————————-
編譯安裝PHP 5.2.13所需的支持庫(kù)
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure –prefix=/opt/lib/libiconv
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
————————————————————————————————————————————————————–
安裝libpng jpegsrc freetype zlib gd2
#先安裝zlib,freetype,libpng,jpeg,再裝GD
#1.安裝zlib
tar zxvf zlib-1.2.2.tar.gz
cd zlib-1.2.2
./configure
make
make install
#2.安裝libpng
tar zxvf libpng-1.2.7.tar.tar
cd libpng-1.2.7
cd scripts/
mv makefile.linux ../makefile
cd ..
make
make install
#注意,這里的makefile不是用./configure生成,而是直接從scripts/里拷一個(gè)
#3.安裝freetype
tar zxvf freetype-2.1.9.tar.gz
cd freetype-2.1.9
./configure
Make
make install
#4.安裝Jpeg
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure –enable-shared
Make
make test
make install
#可能出錯(cuò),一般為目錄不存在,建立一個(gè)目錄即可。注意,這里configure一定要帶–enable-shared參數(shù),不然,不會(huì)生成共享庫(kù)
5.yum安裝fontconfig和fontconfig-devel[yum install fontconfig fontconfig-devel]
6. yum安裝其他必須的軟件
yum -y install autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
7.安裝GD
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure –prefix=/opt/gd2 –with-jpeg=/usr/local/modules/jpeg7 –with-png –with-zlib –with-freetype=/usr/local/modules/freetype
make
make install
———————————————————————————————————————————————————————————————–
#==================================================================
#安裝php以及擴(kuò)展
#==================================================================
#一、安裝PHP
tar zxvf php-5.2.13.tar.gz
gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1
cd php-5.2.13/
./configure –prefix=/opt/php5 –with-config-file-path=/opt/etc/cgi –with-mysql=/opt/mysql5 –with-mysqli=/opt/mysql5/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-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –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
make ZEND_EXTRA_LIBS=’-liconv’
make install
mkdir -p /opt/etc/cgi/
cp php.ini-dist /opt/etc/cgi/php.ini
mv -f /~/soft/conffile/php-fpm.conf /opt/php5/etc/php-fpm.conf
echo ‘ulimit -SHn 65535′ >> /etc/rc.local
echo ‘/opt/php5/sbin/php-fpm start’ >> /etc/rc.local
———————————————————————————————————-
#編譯安裝PHP5擴(kuò)展模塊
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/opt/php5/bin/phpize
./configure –with-php-config=/opt/php5/bin/php-config
make && make install
cd ../
tar jxvf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6/
/opt/php5/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/opt/php5/bin/php-config
make && make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/opt/php5/bin/phpize
./configure –with-php-config=/opt/php5/bin/php-config –with-pdo-mysql=/opt/mysql5
make && make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make && make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/opt/php5/bin/phpize
./configure –with-php-config=/opt/php5/bin/php-config
make && make install
cd ../
———————————————————————————————————————————————————————————————–
#5、修改php.ini文件
#手工修改:查找/opt/etc/cgi/php.ini中的extension_dir = “./”
#修改為extension_dir = “/opt/php5/lib/php/extensions/no-debug-non-zts-20060613/”
#并在此行后增加以下幾行,然后保存:
extension = “memcache.so”
extension = “pdo_mysql.so”
extension = “imagick.so”
#再查找output_buffering = Off
#修改為output_buffering = On
#———————————————————————————————————————————————————–
#配置eAccelerator加速PHP:
mkdir -p /opt/eaccelerator/eaccelerator_cache
vi /opt/etc/cgi/php.ini
#按shift+g鍵跳到配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension=”/opt/php5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/opt/eaccelerator/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″
#———————————————————————————————————————————————————–
啟動(dòng)fast-cgi
ulimit -SHn 51200
/opt/php5/sbin/php-fpm start
#修改php.ini后不重啟php-cgi,重新加載配置文件使用reload
/opt/php/sbin/php-fpm reload
#———————————————————————————————————————————————————–
安裝Zend
Tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
Cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install
前面介紹就不說(shuō)了,問(wèn)Zend安裝到哪里 你隨便安裝 我裝的是/opt/zend 再問(wèn)php.ini在哪里 我的是/opt/etc/cgi 問(wèn)是否重啟apache 選擇 no 然后 就OK了
#———————————————————————————————————————————————————–
#==================================================================
優(yōu)化Linux內(nèi)核參數(shù)
vi /etc/sysctl.conf
# Add
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
使sysctl.conf立即生效
/sbin/sysctl –p
————————————————————————————————————————————————————–
===================================================================
配置cherokee集成php
===================================================================
啟動(dòng)Cherokee
Cd /opt/Cherokee/sbin
./cherokee-admin –b &
在屏幕上會(huì)出現(xiàn)如下提示:
[root@jjjjjjjl sbin]# ./cherokee-admin -b &
[1] 21876
[root@jjjjjjjl sbin]#
Login:
User: admin //登陸用戶名
One-time Password: wmMwL7lEMwpcBIqW //登陸密碼
Web Interface:
URL: http://localhost:9090/
[29/03/2010 15:16:40.071] (error) rrd_tools.c:120 – Could not find the rrdtool binary.
Cherokee Web Server 0.99.44 (Mar 29 2010): Listening on port ALL:9090, TLS
disabled, IPv6 disabled, using epoll, 4096 fds system limit, max. 2041
connections, caching I/O, single thread
打開瀏覽器鍵入: http://yourserverip:9090.會(huì)出現(xiàn)輸入用戶名和密碼的地方,輸入剛才顯示在屏幕上的用戶名和密碼后登陸到Cherokee的管理頁(yè)面。
中間紅色部分表示服務(wù)器未啟動(dòng),可以先啟動(dòng)服務(wù)器測(cè)試cherokee是否已經(jīng)OK,點(diǎn)擊啟動(dòng)后用http://yourserverip 來(lái)訪問(wèn)下默認(rèn)頁(yè)面如果出現(xiàn)下面的頁(yè)面則表示cherokee安裝啟動(dòng)成功。
配置PHP擴(kuò)展:
點(diǎn)擊管理頁(yè)面左側(cè)欄里的 數(shù)據(jù)源 同時(shí)在右邊頁(yè)面里可以看到需要我們填寫的項(xiàng)目,下圖是填寫好的
類型選擇:本地引擎
名稱:用戶自定義愛叫啥都可以
連接:這里可以看出來(lái)時(shí)fastcgi的9000端口
解釋器:這里是php-fmp啟動(dòng)的路徑
下面部分可以選填,解釋器填寫好后,在上面應(yīng)該會(huì)出現(xiàn) 已有數(shù)據(jù)源。別忘了點(diǎn)擊左側(cè)的保存。
再點(diǎn)擊左側(cè)的 虛擬主機(jī)配置:
再點(diǎn)擊右邊頁(yè)面的 Default虛擬主機(jī) –>擴(kuò)展設(shè)置—>WizardsLanguages—>PHPRun Wizards
點(diǎn)擊目標(biāo)里的php
選擇—處理根目錄 輸入/ 后再點(diǎn)擊 左側(cè)的保存。然后回到首頁(yè) 重啟服務(wù)器。配置完成可以運(yùn)行php程序了,如果打不開80請(qǐng)檢查你的iptables (建議還是開啟iptables,測(cè)試環(huán)境可以用service iptables stop關(guān)閉防火墻)
把某個(gè)端口在防火墻開啟命令:
先用iptables –L 查看
Iptables –I RH-Firewall-1-INPUT –p tcp –dport 80 –j ACCEPT
關(guān)于Cherokee的其他配置請(qǐng)到這里查看,自學(xué)成才。
http://www.cherokee-project.com/doc/
————–
數(shù)據(jù)備份腳本
#!/bin/bash
#
service mysqld stop
date ‘+tar -zcvf /opt/bak/sql/data.%Y-%m-%d.tar.gz /opt/mysql5/var’ | sh
service mysqld start
cron –e
增加
0 1 * * * /opt/sqlbak.sh
Wq!
在計(jì)劃任務(wù)里,每天凌晨1點(diǎn)對(duì)數(shù)據(jù)庫(kù)進(jìn)行備份 |
|