Linux 下安裝配置 PHP

來源:互聯網
上載者:User
Linux 下安裝配置 PHP
1)下載PHP安裝包,下載地址: http://www.php.net/downloads.php ,這裡選用PHP 5.6版本 並解壓PHP安裝包
 1 
wget cn2.php.net/get/php-5.6.31.tar.gz/from/this/mirror
2
gzip -d php-5.6.31.tar.gz
3
tar xvf php-5.6.31.tar
2)添加www使用者組和www使用者(如果系統中已存在該使用者組,不用添加該使用者組)
 1 
groupadd www
2
useradd -g www -s /sbin/nologin -M www  

3) 使用su超級使用者登入Linux ,編譯PHP參數
 1 
su
2
#./configure \ 
3
--prefix=/usr/local/php \ 
4
--with-mysql=/usr/local/mysql \  
5
--with-apxs=/usr/local/apache2/bin/apxs \
--prefix 指定安裝路徑 --with-mysql  指定mysql路徑 --with-apxs  指定apahce路徑 在接下來的編譯過程如果報錯,可以根據報錯調用 ./configure --help查看編譯參數,並下載安裝相應的依賴包;
4)編譯,安裝PHP
 1 
make
2
make install

5)修改Apache的設定檔,使其支援php, 對 apache 的 httpd.conf 作以下修改 在“ AddType application/x-gzip .gz .tgz”下添加
 1 
AddType application/x-httpd-php .php 
2
AddType application/x-httpd-php-source .php5 
在"< IfModule dir_module>"內的內容添加"index.php",即如下:
 1 
<IfModule dir_module>
2
    DirectoryIndex index.html index.php
3
</IfModule> 
將" #ServerName  www.example.com:80" 修改為
 1 
ServerName 127.0.0.1:80
2
3
ServerName localhost:80

6)複製 php-5.6.31安裝包中的設定檔
 1 
cp php-5.6.31/php.ini.dist  /usr/local/php/lib/php.ini 
</
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.