php5.4.41 绿色_编译安装PHP5.4.41
一、部署LAMP環境,安裝順序
二、編譯、安裝php
三、安裝xcache,為php(opcode)加速
四、其他
一、部署LAMP環境,安裝順序
編譯安裝部署LAMP環境,安裝順序
3、編譯安裝php
二、編譯、安裝php
1、下載php并解壓[root@localhost?downloads]#?wget?http://cn2.php.net/distributions/php-5.4.41.tar.bz2
[root@localhost?downloads]#?tar?xf?php-5.4.41.tar.bz2
2、編譯前準備工作
(1)、編譯選項./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
(2)、直接編譯,會有如下提醒,所以需提前準備1、configure:?error:?xml2-config?not?found.?Please?check?your?libxml2?installation.
2、configure:?error:?Please?reinstall?the?BZip2?distribution
3、configure:?error:?mcrypt.h?not?found.?Please?reinstall?libmcrypt.
4、configure:?error:?Cannot?find?MySQL?header?files?under?/usr/local/mysql.????#這個問題就需要先安裝mysql后,再來編譯php了,所以最好按照步驟apache-->mysql-->php
所以編譯前需要安裝依賴環境1、#?yum?-y??install?libxml2?libxml2-devel
2、#?yum?-y??install?bzip2-devel
下載libmcrypt?libmcrypt-devel,并安裝
#?wget?http://mirrors.sohu.com/fedora-epel/6Server/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
#?wget?http://mirrors.sohu.com/fedora-epel/6Server/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
3、#?rpm?-ivh?libmcrypt-2.5.8-9.el6.x86_64.rpm
#?rpm?-ivh?libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
3、編譯、安裝php#?./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
#?make?&&?make?install
注:--enable-maintainer-zts??? 編譯模塊worker、event時,需要使用該選項
4、編輯/etc/httpd/httpd.conf
(1)、在AddType application/x-gzip .gz .tgz后添加以下信息,使httpd識別php格式的頁面ADDType?application/x-httpd-php?.php
ADDType?application/x-httpd-php-source?.phps
(2)、添加默認起始頁文件名
DirectoryIndex index.php
DirectoryIndex?index.php?index.html
完成配置后,重載配置[root@localhost?~]#?service?httpd?graceful
(3)、為php提供配置文件,在我們解壓出的源碼目錄中,有兩個配置文件樣例[root@localhost?~]#?cd?/root/downloads/php-5.4.41
[root@localhost?php-5.4.41]#?ls?|grep?php.ini
php.ini-development????#適用于開發環境
php.ini-production????#適用于生產環境
編譯安裝時,我們指定了php的配置文件目錄/etc,這里我們把適用于生產環境的配置文件復制過去[root@localhost?php-5.4.41]#?cp?php.ini-production?/etc/php.ini
(4)、測試
之前編譯安裝的apache,配置文件中,默認網站根目錄是DocumentRoot "/usr/local/apache/htdocs"
在該路徑新建一個測試頁面index.php,內容如下
host1
phpinfo();
?>
在瀏覽器輸入主機地址測試,出現下圖所示,說明安裝、配置成功
(5)、測試連接mysql
/usr/local/apache/htdocs在該路徑新建一個測試頁面pcmysql.php,內容如下
host1
$link=mysql_connect(localhost,root,'password');????#注意之前給mysql的root用戶改過密碼執行函數返回值mysql_connect(localhost,"root",)存儲在變量$link中
if?($link)
echo?"Sueccess.";
else
echo?"Failure.";
?>
然后用瀏覽器訪問這個頁面,顯示如下信息則說明php成功連接mysql
三、安裝xcache,為php(opcode)加速
1、下載xcachewget?http://xcache.lighttpd.net/pub/Releases/3.1.2/xcache-3.1.2.tar.gz
2、為php添加xcache[root@localhost?downloads]#?tar?xf?xcache-3.1.2.tar.gz
[root@localhost?downloads]#?cd?xcache-3.1.2
[root@localhost?xcache-3.1.2]#?/usr/local/php/bin/phpize
Configuring?for:
PHP?Api?Version:?????????20100412
Zend?Module?Api?No:??????20100525
Zend?Extension?Api?No:???220100525
3、編譯安裝xcache[root@localhost?xcache-3.1.2]#?./configure?--enable-xcache?--with-php-config=/usr/local/php/bin/php-config
[root@localhost?xcache-3.1.2]#?make?&&?make?install
安裝完成,提示模塊安裝的位置Installing?shared?extensions:?????/usr/local/php/lib/php/extensions/no-debug-zts-20100525/
4、將xcache配置文件復制到php配置文件目錄[root@localhost?xcache-3.1.2]#?mkdir?/etc/php.d
[root@localhost?xcache-3.1.2]#?cp?xcache.ini?/etc/php.d
[root@localhost?xcache-3.1.2]#?vim?/etc/php.d/xcache.ini
[root@localhost?xcache-3.1.2]#?service?httpd?graceful????#重載配置
新建測試頁面,在瀏覽器中訪問測試頁面,顯示如下畫面,說明模塊正常加載vim?/usr/local/apache/htdocs/test.php
編輯如下內容
phpinfo();
?>
??? #配置文件已經載入
如果xcache沒有正常工作,試試編輯xcache.ini,編輯extension = xcache.so,修改為全路徑extension?=?/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
四、其他
配置文件/etc/php.ini,/etc/php.d/目錄下的*.ini
php.ini官方文檔:
總結
以上是生活随笔為你收集整理的php5.4.41 绿色_编译安装PHP5.4.41的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 选中内容_Excel – 选中的单元格自
- 下一篇: php历史上的今天源码,代码获取历史上的