1. 程式人生 > >linux編譯安裝php5.4

linux編譯安裝php5.4

找到 free 解決 order found fix 默認 pro 錯誤

下載
wget http://cn2.php.net/distributions/php-5.4.44.tar.gz
解壓
tar zxvf php-5.4.44.tar.gz
提前安裝一些依賴包
yum install -y libjpeg-devle libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libmcrypt
yum install -y libmcrypt-devel
配置編譯參數:
cd php-5.4.44
./configure \
--prefix=/u01/php \
--with-apxs2=/u01/apache2/bin/apxs \
--with-config-file-path=/u01/php/etc \
--with-mysql=/u01/mysql \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-bz2 \
--with-openssl \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-sockets \
--enable-exif \
--disable-ipv6

可能出現的錯誤及解決辦法
configure: error: xml2-config not found. Please check your libxml2 installation.
解決辦法是:
yum install -y libxml2-devel
還有錯誤:
configure: error: Cannot find OpenSSL‘s <evp.h>
解決辦法是:

yum install -y openssl openssl-devel

錯誤:
checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution
解決辦法:

yum install -y bzip2 bzip2-devel

錯誤:
configure: error: png.h not found.
解決辦法:

yum install -y libpng libpng-devel

錯誤:
configure: error: freetype.h not found.
解決辦法:

yum install -y freetype freetype-devel

錯誤:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決辦法:

yum install -y epel-release

yum install -y libmcrypt-devel

因為 centos6 默認的 yum 源沒有 libmcrypt-devel 這個包,只能借助 epel 的 yum 源。

make&&make install

拷貝 php 配置文件:

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

修改 apache 配置文件

vi /usr/local/apache2/conf/httpd.conf

找到:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改為:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
說明:如果不修改這個地方,我們訪問網站會禁止訪問,顯示 403。
然後找到:
AddType application/x-gzip .gz .tgz
在該行下面添加:
AddType application/x-httpd-php .php
說明,要想支持 php 腳本解析,必須要加上對應的類型。
再找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
將該行改為:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
說明: 增加針對 php 的索引,如果一個站點默認頁為 index.php,那麽就得加上這個
index.php 的支持。
再找到:
#ServerName www.example.com:80
修改為:
ServerName localhost:80
如果不去掉#,則啟動 apache 時,會有警告信息“httpd: Could not reliably determine the
server‘s fully qualified domain name, using localhost.localdomain for ServerName”,看起來像是
錯誤,其實沒有影響。
查看配置文件是否有問題:
/usr/local/apache2/bin/apachectl -t
如果顯示 Syntax OK,說明配置沒問題了。然後啟動服務:
/usr/local/apache2/bin/apachectl start
檢查 apache 是否正常啟動的命令是:
ps aux |grep httpd
看有沒有進程列表。

linux編譯安裝php5.4