CentOS5.2編譯安裝Apache 2.2.10,MySQL 5.0.67,PHP-5.2.6(支持GD),ZendOptimizer3.3.0

CentOS5.2編譯安裝Apache 2.2.10,MySQL 5.0.67,PHP-5.2.6(支持GD),ZendOptimizer3.3.0


1.安裝Apache 2.2.10
雖然選擇了無包安裝CentOS,但是由於包依賴關係,CentOS還是會自動安裝Apache,所以需要首先卸載掉Apache,依次點擊Applications->Add/Remove Software->把萬維網服務器前面的勾去掉即可。
開始編譯安裝Apache
解壓 tar zxvf httpd-2.2.10.tar.gz
進入目錄,開始編譯
./configure –sysconfdir=/etc –enable-ssl –enable-modules –enable rewrite
一般apache還需要支持url改寫,所以編譯時加上後面的部分;
正常情況下,如果選擇了無包安裝CentOS,會出現下面的錯誤:
checking whether to enable mod_ssl… checking dependencies
checking for SSL/TLS toolkit base… none
checking for OpenSSL version… checking openssl/opensslv.h usability… no
checking openssl/opensslv.h presence… no
checking for openssl/opensslv.h… no
checking openssl/ssl.h usability… no
checking openssl/ssl.h presence… no
checking for openssl/ssl.h… no
no OpenSSL headers found
checking for SSL-C version… checking sslc.h usability… no
checking sslc.h presence… no
checking for sslc.h… no
no SSL-C headers found
configure: error: …No recognized SSL/TLS toolkit detected
解決辦法,安裝 openssl
yum -y install openssl-devel
下載安裝和更新的列表信息
Running Transaction
Updating : e2fsprogs-libs               ####################### [ 1/15]
Updating : krb5-libs                    ####################### [ 2/15]
Installing: e2fsprogs-devel              ####################### [ 3/15]
Installing: libsepol-devel               ####################### [ 4/15]
Installing: libselinux-devel             ####################### [ 5/15]
Installing: keyutils-libs-devel          ####################### [ 6/15]
Installing: krb5-devel                   ####################### [ 7/15]
Installing: zlib-devel                   ####################### [ 8/15]
Installing: openssl-devel                ####################### [ 9/15]
Updating : krb5-workstation             ####################### [10/15]
Updating : e2fsprogs                    ####################### [11/15]
Cleanup   : e2fsprogs-libs               ####################### [12/15]
Cleanup   : krb5-workstation             ####################### [13/15]
Cleanup   : e2fsprogs                    ####################### [14/15]
Cleanup   : krb5-libs                    ####################### [15/15]
Installed: openssl-devel.i386 0:0.9.8b-8.3.el5_0.2
Dependency Installed: e2fsprogs-devel.i386 0:1.39-10.el5_1.1 keyutils-libs-devel.i386 0:1.2-1.el5 krb5-devel.i386 0:1.6.1-17.el5_1.1 libselinux-devel.i386 0:1.33.4-4.el5 libsepol-devel.i386 0:1.15.2-1.el5 zlib-devel.i386 0:1.2.3-3
Dependency Updated: e2fsprogs.i386 0:1.39-10.el5_1.1 e2fsprogs-libs.i386 0:1.39-10.el5_1.1 krb5-libs.i386 0:1.6.1-17.el5_1.1 krb5-workstation.i386 0:1.6.1-17.el5_1.1
Complete!
OK, openssl安裝完畢。
然後再次輸入./configure –sysconfdir=/etc –enable-ssl –enable-modules –enable rewrite
這樣就生成了makefile
然後make和make install即可完成Apache安裝。
終端輸入:/usr/local/apache2/bin/apachectl start啓動apache,
終端輸入:netstat -tnl看看端口,如果有80了,說明apache啓動成功了。
最後需要設置Apache隨CentOS啓動,終端輸入:echo “/usr/local/apache2/bin/apachectl start &” >> /etc/rc.local
安裝MySQL
下載MySQL
解壓縮 tar xvf mysql-5.0.67.tgz
進入目錄開始編譯./configure –sysconfdir=/etc
一般情況會出現一個錯誤提示如下:
checking for termcap functions library… configure: error: No curses/termcap library found
解決辦法如下:
yum -y install ncurses-devel
安裝完畢後再次輸入:./configure –sysconfdir=/etc
出現安裝成功信息:Thank you for choosing MySQL!
後面的工作就是make和make install了。
安裝完後,拷貝一個配置文件當作MySQL的配置文件
cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf
開始啓動MySQL
終端輸入:useradd -d /usr/local/var mysql
一般會提示mysql用戶存在
su - mysql
/usr/local/bin/mysql_install_db
啓動開始
[mysql@localhost var]$ /usr/local/bin/mysqld_safe
這裏可能會碰到點小問題,一般是文件權限問題和文件夾需要重新建立問題,具體細節我記不請了。
netstat -tnl ,如果看到3306端口,就說明MySQL啓動成功。
然後配置MySQL隨CentOS啓動,終端輸入:echo “/usr/local/bin/mysqld_safe &” >> /etc/rc.local
編譯安裝GD庫,讓php支持更多圖形方面的內容,例如gif jpg(jpeg) png wbmp xml 和 ttf字體(此部分要在PHP安裝前進行,且按照以下順序進行安裝)
1.安裝ncurses-5.6
解壓縮 tar zxvf ncurses-5.6.tar.gz,進入目錄
./configure –prefix=/usr –with-shared –without-debug
make
make install
2.安裝zlib2
解壓縮 tar zxvf tar zxvf zlib-1.2.3.tar.gz,進入目錄
./configure –prefix=/usr/local/zlib
make
make install
3.安裝PNG
解壓縮 tar zxvf tar zxvf libpng-1.2.26.tar.gz,進入目錄
cp scripts/makefile.linux ./makefile
./configure –prefix=/usr/local/libpng
make
make install
4.安裝ttf ( ttf 是字體的支持 )
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure –prefix=/usr/local/freetype
make
make install
5.安裝JPEG6
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
./configure –prefix=/usr/local/libjpeg –enable-shared –enable-static
make
make install
6.安裝 libxml2
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure –prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin
7.安裝 libmcrypt-2.5.7.tar.gz
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install
8.安裝Fontconfig
tar -zxvf fontconfig-2.4.2.tar.gz
cd fontconfig-2.4.2
./configure –prefix=/usr/local/fontconfig –with-freetype-config=/usr/local/freetype/bin/freetype-config
一般這裏會出現一個錯誤提示如下:
checking for LIBXML2… configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:
No package ‘libxml-2.0′ found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解決方法:確定 /usr/local/libxml2/lib/pkgconfig 目錄下有 libxml-2.0.pc
export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
然後再次輸入:./configure –prefix=/usr/local/fontconfig –with-freetype-config=/usr/local/freetype/bin/freetype-config
make
make install
9.安裝GD庫
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure –prefix=/usr/local/libgd –with-png=/usr/local/libpng –with-fr
如果前面安裝都順利,會看到下面的支持信息:
Support for PNG library:          yes
Support for JPEG library:         yes
Support for Freetype 2.x library: yes
Support for Fontconfig library:   yes
Support for Xpm library:          no
Support for pthreads:             yes
繼續
make
make install
安裝PHP5.2.6
tar zxvf php-5.2.6.tar.gz
cd php-5.2.6
./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local –with-gd=/usr/local/libgd –enable-gd-native-ttf –with-ttf –enable-gd-jis-conv –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/libjpeg –with-png-dir=/usr/local/libpng –with-libxml-dir=/usr/local/libxml2 –with-zlib-dir=/usr/local/zlib –enable-xml –enable-mbstring –enable-sockets
成功提示信息是:Thank you for using PHP.
make
make install
拷貝一個配置文件當作我們以後的php.ini
cp php.ini-dist /usr/local/php5/lib/php.ini
修改 apache 配置文件 httpd.conf 加入對php的支持
vi /etc/httpd.conf
加入:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
然後重啓 apache
/usr/local/apache2/bin/apachectl restart
站點目錄是:/usr/local/apache2/htdocs
最後我們還要添加上系統PATH,這樣就可以在終端直接輸入php即可運行程序,
在終端輸入:vi .bashrc,加入這一行:export PATH=”$PATH:/usr/local/php5/bin”,
然後註銷當前用戶重新登錄即可,注意,這種方式只對當前用戶有效,不是全局設置。
安裝 ZendOptimizer3.3.0
tar xzvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.3.0a-linux-glibc21-i386
./install
其中要注意有一步要求填寫之前PHP的安裝目錄,要這麼填寫/usr/local/php5/lib才正確。
經過使用發現,安裝的ZendOptimizer3.3.0版本偏低,不過不要緊,重新安裝ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章