centos6.3
apache2.2
mysql5.1
php5.2.17
安裝gcc、gcc-c++編譯器
yum -y install gcc*
卸載默認的低版本環境 http mysql
關閉selinxu
安裝
1、安裝libxml2
# cd /usr/local/src/libxml2-2.6.30
# ./configure --prefix=/usr/local/libxml2
# make && make install
2、安裝libmcrypt
# cd /usr/local/src/libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make && make install
3、安裝zlib
# cd /usr/local/src/zlib-1.2.3
# ./configure
# make && make install
4、安裝libpng
# cd /usr/local/src/libpng-1.2.31
# ./configure --prefix=/usr/local/libpng
# make && make install
5、安裝jpeg6
這個軟件包安裝有些特殊,其它軟件包安裝時如果目錄不存在,會自動創建,但這個軟件包安裝時需要手動創建。
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man/man1
# cd /usr/local/src/jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make install
6、安裝freetype
# cd /usr/local/src/freetype-2.3.5
# ./configure --prefix=/usr/local/freetype
# make
# make install
7、安裝autoconf
# cd /usr/local/src/autoconf-2.61
# ./configure
# make && make install
8、安裝GD庫
# cd /usr/local/src/gd-2.0.35
# ./configure \
--prefix=/usr/local/gd2/ \
--enable-m4_pattern_allow \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg6/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/
# make
出現錯誤:
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/usr/local/src/gd-2.0.35'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/gd-2.0.35'
make: *** [all] Error 2
分析:這個問題是因為gd庫中的gd_png.c這個源文件中包含png.h時,png.h沒有找到導致的。
解決:
在編譯文件里
# vi gd_png.c
將include “png.h” 改成 include “/usr/local/libpng/include/png.h”
其中/usr/local/libpng/為libpng安裝路徑。
# make install
9、安裝Apache
# cd /usr/local/src/httpd-2.2.9
# ./configure \
--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support
# make && make install
10、配置Apache
啟動Apache
# /usr/local/apache2/bin/apachectl start
關閉Apache
# /usr/local/apache2/bin/apachectl stop
查看80端口是否開啟
# netstat -tnl|grep 80
訪問Apache服務器
添加自啟動
# echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local
11、安裝Mysql
添加一個mysql標準組
# groupadd mysql
添加mysql用戶并加到mysql組中
# useradd -g mysql mysql
# cd /usr/local/src/mysql-5.0.41
# ./configure \
--prefix=/usr/local/mysql/ \
--with-extra-charsets=all
出現錯誤:
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found
分析:缺少ncurses安裝包
解決:
# yum install ncurses-devel
# make && make install
2、配置Mysql
創建MySQL數據庫服務器的配置文件
# cp support-files/my-medium.cnf /etc/my.cnf
用mysql用戶創建授權表,創建成功后,會在/usr/local/mysql目錄下生成一個var目錄
# /usr/local/mysql/bin/mysql_install_db --user=mysql
將文件的所有屬性改為root用戶
# chown -R root /usr/local/mysql
將數據目錄的所有屬性改為mysql用戶
# chown -R mysql /usr/local/mysql/var
將組屬性改為mysql組
# chgrp -R mysql /usr/local/mysql
啟動數據庫
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
查看3306端口是否開啟
# netstat -tnl|grep 3306
簡單的測試
# /usr/local/mysql/bin/mysqladmin version
查看所有mysql參數
# /usr/local/mysql/bin/mysqladmin variables
設置Mysql開機自啟動
# cp /usr/local/src/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chown root.root /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list mysqld
# chkconfig --levels 245 mysqld off
14、安裝PHP
# cd /usr/local/src/php-5.2.6
# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir=/usr/local/libxml2/ \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/ \
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap \
--enable-mbstring=all \
--enable-sockets
# make && make install
報錯
make: *** [ext/dom/node.lo] Error 1
在國外的一個網站上找到了這個,其他版本的php也同樣適用。
# curl -o php-5.x.x.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
# cd php-5.x.x
# patch -p0 -b < ./php-5.x.x.patch
? patching file ext/dom/node.c
? patching file
? ext/dom/documenttype.c
? patching file ext/simplexml/simplexml.c
再次編譯即可。
創建配置文件
# cp php.ini-dist /usr/local/php/etc/php.ini
使用vi編輯apache配置文件
# vi /etc/httpd/httpd.conf
添加這一條代碼
Addtype application/x-httpd-php .php .phtml
重啟Apache
# /usr/local/apache2/bin/apachectl restart
測試
運維QQ交流群:171586999