CentOS 6.4php
httpd-2.4.10.tar.gzhtml
apr-util-1.5.3.tar.gzmysql
apr-1.5.1.tar.gzc++
pcre-8.34.tar.gzsql
php-5.6.0.tar.bz2shell
libmcrypt-2.5.3.tar.gzapache
mysql-5.1.51.tar.gzvim
yum install make openldap-devel ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf bzip2-devel ncurses-devel openssl-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl-devel curl pam-devel openldap-devel e2fsprogs-devel krb5-devel libidn libidn-devel -y瀏覽器
tar -zxvf apr-1.5.1.tar.gz cd apr-1.5.1 ./configure --prefix=/usr/local/apr make && make install
tar -zxvf apr-util-1.5.3.tar.gz cd apr-util-1.5.3 ./configure \ --prefix=/usr/local/apr-util \ --with-apr=/usr/local/apr make && make install
tar -zxvf pcre-8.34.tar.gz cd pcre-8.34 ./configure --prefix=/usr/local/pcre make && make install
tar -zxvf httpd-2.4.10.tar.gz cd httpd-2.4.10 ./configure --prefix=/usr/local/apache \ --with-apr-util=/usr/local/apr-util/ \ --with-pcre=/usr/local/pcre/ \ --with-apr=/usr/local/apr/ make && make install
在make的時候,報錯:服務器
exports.c:2429: error: redefinition of 'ap_hack_apr_xlate_open'
exports.c:2013: note: previous definition of 'ap_hack_apr_xlate_open' was here
打開 server/exports.c ,發現裏面確實有大量重複。apr 與 apr-util 都包含了重複一樣頭文件。刪除重複再make就能夠了。
make install 正常
/usr/local/apache/conf/httpd.conf
DocumentRoot "/usr/local/apache/htdocs"
修改此條可配置項目運行目錄。
啓動文件
/usr/local/apache/bin/apachectl start
報錯:httpd: Could not open configuration file /usr/local/apache2/conf/httpd.conf: No such file or directory
這個錯誤,是因爲上次./configure時--prefix=/usr/local/apache2,而本次沒有make clean時沒有清除上次的記錄。解決方法:要麼刪除整個目錄,要麼
./configure --prefix=/usr/local/apache2 make clean
再按上面的步驟 ./configure,make
此次正常經過~
tar zxf mysql-5.1.51.tar.gz cd mysql-5.1.51 ./configure --prefix=/usr/local/mysql make && make install
安裝完以後,執行 mysql 報錯:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
這是由於本地的mysql服務器沒有啓動起來。
service mysqld start
再次輸入 mysql 命令就沒有問題了。
tar xvf libmcrypt-2.5.3.tar.gz cd libmcrypt-2.5.3 ./configure make && make install
tar -zxvf php-5.6.0.tar.gz cd php-5.6.0 ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/php/etc make
報錯:php-5.6.0/ext/iconv/iconv.c:1001: undefined reference to `libiconv'
緣由是Makefile在連接的時候,沒有將iconv庫鏈進去。
解決方法:
make ZEND_EXTRA_LIBS='-liconv' #...略 Build complete. Don't forget to run 'make test'.
經過了!編譯是經過了,能夠執行make test測試一下。不測試也沒什麼問題。
cp php.ini-production /usr/local/php/etc/php.ini
打開 /usr/local/apache/conf/httpd.conf
將文件中:DirectoryIndex index.html
替換爲:DirectoryIndex index.html index.php
並添加:AddType application/x-httpd-php .php
在 /usr/local/apache/htdocs/ 目錄中建立測試php頁面 test.php
<?php phpinfo(); ?>
重啓apache服務後,在瀏覽器上輸入網址:http://127.0.0.1/test.php
看到站點,則說明php搭建完成。
結果OK了!!!!!