1. 程式人生 > >linux伺服器-LAMP安裝配置3-安裝php

linux伺服器-LAMP安裝配置3-安裝php

安裝php(php-5.6.24.tar.gz):

​tar zxvf php-5.6.24.tar.gz

cd php-5.6.24

該版本的php要先下載​libXpm-devel:yum -y install libXpm-devel

./configure --prefix=/usr/local/php \

–with-config-file-path=/usr/local/php/etc \

–with-apxs2=/usr/local/apache/bin/apxs \

–with-mysql=/usr/local/mysql/ \

–with-libxml-dir=/usr/local/libxml2/ \

–with-png-dir=/usr/local/libpng/ \

–with-jpeg-dir=/usr/local/jpegsrc/ \

–with-freetype-dir=/usr/local/freetype/ \

–with-gd=/usr/local/libgd/ \

–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 \

​–with-xpm-dir=/usr/lib64

出現錯誤:configure: error: Cannot find libmysqlclient_r under /usr/local/mysql/.

Note that the MySQL client library is not bundled anymore!

解決:由於/usr/local/mysql/lib中做的連結是libmysqlclient.so,需要的是libmysqlclient_r.so,所以再做個連結:

​ cd /usr/local/mysql/lib

ln -s libmysqlclient.so libmysqlclient_r.so

好了,返回安裝目錄重新執行上面的操作後

make

出現錯誤:​error: X11/xpm.h: No such file or directory

解決:yum -y install libXpm-devel

出現錯誤:undefined referenceto `XpmLibraryVersion’

解決:./configure中增加–with-xpm-dir=/usr/lib64

此處解決方案來自:http://www.th7.cn/Program/php/201406/213224.shtml

make install

​注意:這裡編譯安裝出現PEAR package PHP_Archive not installed

解決:​成功編譯安裝完成後,再安裝pear:

wget http://pear.php.net/go-pear.phar

​/usr/local/bin/php go-pear.phar​

此處解決方案來自:​http://www.cnblogs.com/tjxwg/p/3967744.html

安裝完成後,需要建立PHP配置檔案。在使用configure命令安裝配置時使用“–with-config-file-path=/usr /local/php/etc/”選項,指定了配置檔案的位置。將原始碼包下面的php.ini-development 檔案複製到/usr/local /php/etc/中,並改名為php.ini即可​

cp php.ini-development /usr/local/php/etc/php.ini

修改php.ini 把;date.timezone 前面的分號去掉,改成date.timezone =“PRC”
​修改apache配置檔案:

vim ​/etc/httpd/httpd.conf

找到AddType application/x-gzip .gz .tgz指令選項,並在其下方新增一 條指令AddType application/x-httpd-php .php .phtml

重啟apache:/usr/local/apache/bin/apachectl restart

測試PHP環境是否可以正常執行,在/usr/local/apache/htdocs目錄下建一個test.php或test.phtml的檔案,內容如下示:

瀏覽器開啟:http://伺服器IP/test.php ,顯示如下資訊表示成功安裝php