編譯安裝php

來源:互聯網
上載者:User

標籤:編譯安裝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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.