標籤:編譯安裝php
編譯安裝php
http://php.net/
[[email protected] ~]# ls
anaconda-ks.cfg install.log install.log.syslog php-5.6.24.tar.bz2
[[email protected] php-5.6.24]# yum -y install libxm*
解決mcrypt加密問題 需要安裝4個包 mhash 和 mhash-devel 和 libmcrpt-devel 和 libmcrpt
http://www.rpmfind.net/ 下載後使用yum進行安裝
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
# --prefix 指定安裝路徑
# --with-mysql指定mysql在什麼地方
# --with-openssl 支援openssl功能
# --with-mysqli php和mysql互動的介面
# --enable-mbstring 開啟mbstring,支援中文
# --with-freetype-dir 支援freetype功能,引用特定字型。
# --with-jpeg-dir 支援圖片
# --with-png-dir 支援圖片
# --with-zlib 壓縮庫,讓資料檔案先壓縮再解壓縮,節約頻寬
# --with-libxml-dir xml擴充標記語言,指定xml庫的路徑在什麼地方
# --enable-xml 開啟xml功能
# --enable-sockets 讓php能夠支援基於通訊端的通訊
# --with-apxs2 將/usr/local/apache/bin/apxs 編譯成apache模組。改成--enable-fpm則使用fastCGI
# --with-mcrypt 支援加密功能
# --with-config-file-path php的主設定檔存放位置
# --with-config-file-scan-dir 主設定檔的片段存放位置
# --with-bz2 壓縮庫
# --enable-maintainer-zts 此項如果apache使用prefork就不需要此項,如果apache需要以線程工作就必須啟動此項
make
make install
[[email protected] php-5.6.24]# cp php.ini-production /etc/php.ini 給php複製一個設定檔
[[email protected] php-5.6.24]# vim /etc/httpd/httpd.conf
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php 添加此行
AddType application/x-httpd-php-source .phps php源碼
------------------------------------------------------
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php index.html 增加index.php
</IfModule>
-------------------------------
[[email protected] bin]# ./apachectl start 啟動httpd服務
[[email protected] htdocs]# mv index.html index.php
[[email protected] htdocs]# vim index.php
<html><body><h1>It works!</h1></body></html>
<?php
phpinfo();
?>
此時可以通過pc端進行測試php
----------------------
<html><body><h1>It works!</h1></body></html>
<?php
$conn=mysql_connect(‘localhost‘,‘root‘,‘‘);
if ($conn)
echo "Success..";
else
echo "Failure..."
?>
測試資料庫
--------------------
本文出自 “營運成長路” 部落格,謝絕轉載!
編譯安裝php