標籤:lamp中的php編譯安裝 源碼包安裝 庫
下載安裝包:wget http://cn2.php.net/distributions/php-5.6.29.tar.gz
php編譯安裝步驟:
一,配置編譯參數./configure
./configure \
>--prefix=/usr/local/php \
>--with-apxs2=/usr/local/apache2/bin/apxs \ //安裝該參數後會出現php_module模組
>--with-config-file-path=/usr/local/php/etc \
>--with-mysql=/usr/local/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編譯之後遇到的一些錯誤資訊:
1.configure: error: Cannot find OpenSSL‘s <evp.h>
解決方案:yum install -y openssl openssl-devel
2.checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解決方案:yum install -y bzip2 bzip2-devel
3.configure: error: jpeglib.h not found.
解決方案:yum install -y libjpeg-turbo libjpeg-turbo-devel
4.configure: error: png.h not found.
解決方案:yum install -y libpng libpng-devel
5.configure: error: freetype-config not found.
解決方案:yum install -y freetype freetype-devel
6.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決方案:yum install -y epel-release
yum install -y libmcrypt-devel
(因為Centos預設的yum源沒有libmcrypt-devel這個包,只能借epel的yum源)
7.checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
解決方案:yum install -y libxml2-devel
二,編譯make
三,安裝make install
安裝完成後,還不能使用,還需要進一步配置一下
拷貝php設定檔:(在./configure配置參數時的目錄下)
cp php.ini-production /usr/local/php/etc/php.ini
(這一步必須得有,要不然後面不能正常解析php檔案)
650) this.width=650;" src="http://s4.51cto.com/wyfs02/M00/8B/A1/wKioL1hTceLR_lp9AAD3rJ4QBs0970.png-wh_500x0-wm_3-wmp_4-s_777933021.png" title="clipboard.png" alt="wKioL1hTceLR_lp9AAD3rJ4QBs0970.png-wh_50" />
修改apache設定檔
vi /usr/local/apache2/conf/httpd.conf
1.找到:
<Directory "/usr/local/apache2//cgi-bin">
AllowOverride None
Options None
Order allow,deny
Deny from all
</Directory>
改為:
<Directory "/usr/local/apache2//cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
說明:如果不修改這個地方,我們訪問網站會禁止訪問,顯示403
2.找到: AddType application/x-gzip .gz .tgz
在該行下面添加: AddType application/x-httpd-php .php
說明:要想支援PHP指令碼解析,必須要加上對應的類型
3.找到:
<IfModule dir_module>
DirectoryIndex index.html index.htm
</IfModule>
改為:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
說明:增加針對php的索引,如果一個網站預設頁為index.php,那麼就得加上這個index.php的支援。
4.找到:
#ServerName www.example.com:80
改為:
ServerName localhost:80
說明:如果不去掉#,啟動apache時,會有警告資訊
5.去掉/user/local/apache2/conf/httpd.conf裡#Include conf/extra/httpd-vhosts.conf的井號,解析localhost下的php提示404.
原因:/usr/local/apache2/confhttpd.conf下的php檔案在doucmentroot=/usr/local/apache2/htdocs下;而/usr/local/apache2/conf/extra/httpd-vhosts.conf下的php檔案在doucmentroot=/data/www下。兩個路徑不一樣所以不能通用php檔案
6.要想使用curl localhost/1.php:要開啟httpd服務,該命令才可以使用
本文出自 “11842333” 部落格,請務必保留此出處http://11852333.blog.51cto.com/11842333/1883288
LAMP中的php編譯安裝