php源碼安裝

我是將下載好的軟件包放到虛擬機 /home目錄下,虛擬機是centos6.4 
如果想了解nginx源碼安裝http://blog.csdn.net/zkg510168343/article/details/43703635
mysql源碼安裝 http://blog.csdn.net/zkg510168343/article/details/43284071
PHP安裝前準備,軟件包下載地址
libmcrypt包
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
mhash
http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
mcrypt
http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
php
http://www.php.net
首先來安裝幾個源碼包依賴:
tar -jxvf libmcrypt-2.5.8.tar.bz2   # 這個包是bz2的  使用-j參數解壓
cd libmcrypt-2.5.8
./configure
make && make install




####################################################
tar -jxvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure
make && make install
# 這兩個包安裝完成後要把動態鏈接庫做一個軟連接到/usr/lib,以爲接下來的mcrypt依賴於這兩個包
ln -s /usr/local/lib/libmcrypt* /usr/lib
ln -s /usr/local/lib/libmhash.* /usr/lib/
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
###########################################################
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make && make install
php安裝
安裝依賴:
yum –y install libxml2-devel curl-devel libpng-devel openldap-devel
tar -jxvf php-5.4.0.tar.bz2
cd php-5.4.0
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap
這一步會出現各種各樣的問題,大多是因爲缺少軟件
首先預編譯第一次提示了
configure: error: *** libmcrypt was not found
這個是因爲環境變量的問題,gcc編譯的時候根據自身定義的變量尋找相關函數庫等文件,
libmcrypt也是剛安裝的,在變量中沒有定義出來,所以手動添加:
[root@localhost modules]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次編譯,又一次出錯
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
這個是curl的dev包沒有安裝, 解決方案:
yum -y install curl-devel
再次編譯,報錯:
If configure fails try --with-vpx-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
configure: error: png.h not found.
這個是因爲libpng沒有安裝,於是我執行命令
yum install libpng-devel
再次編譯,仍然報錯
configure: error: Cannot find ldap.h
好吧缺少openldap庫
yum install openldap-devel
繼續編譯,還是報錯
configure: error: Cannot find ldap libraries in /usr/lib.
這個錯誤一般是在編譯安裝PHP的時候會出現這個提示。
解決方法如下:
cp -frp /usr/lib64/libldap* /usr/lib/
可能的原因是安裝了64位的系統,在lib64下面有這個文件,可能在lib這文件夾裏面沒有,所以強制複製一次。


快要崩潰了,再一次編譯,當出現thanks you using php界面,終於預編譯通過了,這裏其實每個人遇到的錯誤會不一樣,這些是我編譯遇到的問題
執行make && make install 感覺一切要結束的時候,問題又來了
提示錯誤:
/root/dev/php-5.4.0/sapi/cli/php: error while loading shared libraries:  libmysqlclient.so.18: cannot open shared object file: No such file or  directory
make: *** [ext/phar/phar.php] Error 127
網上找到的解決辦法是
ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/
照做後仍然報錯,原因是該方法適用於32位系統,64位系統應使用下面的這行
ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/
再次make && make install
偶也PHP安裝成功
到這裏整個LNMP已經安裝完成.下面我們就配置php和nginx能運行php網站:
首先爲php創建配置文件:
cp php.ini-production /usr/local/php/php.ini # 如果是開發就複製php.ini-development
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/bin/php /usr/bin/
啓動php-fpm
/usr/local/php/sbin/php-fpm
netstat -tunlp | grep php-fpm
php-fpm啓動
配置nginx與php
找到這段,前面添加 index.php類型
location / {
            root   html;
            index  index.php index.htm index.html;
        }
打開這段註釋
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name; //這裏目錄就是web服務器站點代碼存放目錄
            include        fastcgi_params;
        }
保存後重啓nginx service nginx restart
在/usr/local/nginx/html裏添加  index.php文件
裏面輸入<?php echo phpinfo();?>
訪問站點 192.168.2.151出現php配置信息,這樣一個簡單的站點算是部署完成,如果想在一臺服務器上部署多個虛擬站點,閱讀:http://blog.csdn.net/zkg510168343/article/details/42835109
當然nginx功能強大,這裏只是一個開始

發佈了163 篇原創文章 · 獲贊 8 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章