天天看點

Linux下apache+php+mysql搭建配置記錄第1章  環境說明第2章  Apache搭建說明第3章  PHP搭建說明第4章  修改配置并測試

centos 6.4

httpd-2.4.10.tar.gz

apr-util-1.5.3.tar.gz

apr-1.5.1.tar.gz

pcre-8.34.tar.gz

php-5.6.0.tar.bz2

libmcrypt-2.5.3.tar.gz

mysql-5.1.51.tar.gz

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

在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"

修改此條可配置項目運作目錄。

啟動檔案

報錯: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,make

這次正常通過~

安裝完之後,執行 mysql 報錯:

error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2)

這是因為本地的mysql伺服器沒有啟動起來。

再次輸入 mysql 指令就沒有問題了。

報錯:php-5.6.0/ext/iconv/iconv.c:1001: undefined reference to `libiconv'

原因是makefile在連結的時候,沒有将iconv庫鍊進去。

解決方法:

通過了!編譯是通過了,可以執行make test測試一下。不測試也沒什麼問題。

打開 /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

重新開機apache服務後,在浏覽器上輸入網址:http://127.0.0.1/test.php

看到站點,則說明php搭建完成。

結果ok了!!!!!