編譯安裝php

來源:互聯網
上載者:User

標籤:編譯安裝php

1、下載解壓php,config

tar zxvf php-xxxx./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql  --with-openssl  --with-mysqlli=/usr/local/mysql/bin/mysql_config  ##php與mysql 串連需要##  --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/httpd/bin/apxs ##把php添加成apache模組## --with-mcrypt  ##支援加密##  --with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d  --with-bz2  --enable-maintainer-zts

如果要支援fastcgi,把

--with-apxs2=/usr/local/httpd/bin/apxs 

改成--enable-fpm


解決mcrypt看上一篇文章,編譯錯誤2次:

yum install  -y  libxml2   libxml2-devel

yum install  -y  bzip2 bzip2-devel

說明:

1、這裡為了支援apache的worker或event這兩個MPM,編譯時間使用了--enable-maintainer-zts選項。

2、如果使用PHP5.3以上版本,為了連結MySQL資料庫,可以指定mysqlnd,這樣在本機就不需要先安裝MySQL或MySQL開發包了。mysqlnd從php 5.3開始可用,可以編譯時間綁定到它(而不用和具體的MySQL用戶端庫綁定形成依賴),但從PHP 5.4開始它就是預設設定了。

# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd



2、make&&make install

過程省略


3、為php提供設定檔

在php源碼包裡有php.ini-production

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


編輯apache設定檔httpd.conf,讓apache支援php


vim /etc/httpd/httpd.conf

 1、添加如下二行

   AddType application/x-httpd-php  .php

   AddType application/x-httpd-php-source  .phps


 2、定位至DirectoryIndex index.html 

   修改為:

    DirectoryIndex  index.php  index.html


重啟httpd

測試php

<?phpphpinfo();?>

測試php是否與mysql串連正常

<?php$con=mysql_connect(‘localhost‘,‘root‘,‘‘);if ($con)    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.