linux下安裝apache與php

來源:互聯網
上載者:User

標籤:http   io   ar   for   檔案   art   sp   html   on   

1.apache 
在如下頁面下載apache的for Linux 的源碼包 
http://www.apache.org/dist/httpd/; 
存至/home/xx目錄,xx是自建檔案夾,我建了一個wj的檔案夾。

命令列表:  
cd /home/wj 
tar -zxvf httpd-2.0.54.tar.gz
mv httpd-2.0.54 apache 
cd apache 
./configure --prefix=/usr/local/apache2 --enable-module=so 
make 
make install  
安裝apache至/usr/local/apache 並配置apache支援dso方式 
2.php 
在如下頁面下載php的for Linux 的源碼包  
http://www.php.net/downloads.php ; 
存至/home/wj目錄 
命令列表: 
cd /home/wj
tar -zxvf php-5.0.4.tar.gz 
mv php-5.0.4 php 
cd php 
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-MySQL 
make 
make install
其中apache和mysql是根據你安裝的目錄名變,我的是 =/usr/local/apache2/bin/apxs 和MySQL
cp php.ini-dist /usr/local/lib/php.ini 
以dso方式安裝php至/usr/local/php 設定設定檔目錄為/usr/local/lib 開啟mysql,xml支援 
3.配置
  
vi /usr/local/apache/conf/httpd.conf 
對apache做如下配置 
#將ServerAdmin mailto:[email protected]一行改為您的郵箱地址 

#DocumentRoot "/home/httpd/html/" 此處為html檔案主目錄 
# 同上 
#Options FollowSymLinks MultiViews 為安全起見,去掉"Indexes"  
# 
# DirectoryIndex default.php default.phtml default.php3 default.html default.htm 
# 
#設定apache的預設檔案名稱次序 
#AddType application/x-httpd-php .php .phtml .php3 .inc 
#AddType application/x-httpd-php-source .phps 
#設定php檔案尾碼 
存檔退出  
vi /usr/local/lib/php.ini 
#register-golbals = On 
存檔退出 
4.啟動服務 
/usr/local/apache/bin/apachectl start  

5.測試  
然後寫個php測試頁info.php:內容如下
〈?php
phpinfo(); 
?> 
正常的話,應該能看到php的資訊了,恭喜你的Apche Mysql PHP安裝成功。 
6、apache自動啟動- - 
下面用自啟動apache為例;
自啟動指令碼:
/usr/local/apache/bin/apachectl start
檔案位於/etc/rc.d/init.d下,名為apached,注意要可執行.
#chmod x /etc/rc.d/init.d/apached //設定檔案的屬性為可執行
#ln -s /etc/rc.d/init.d/apached /etc/rc3.d/S90apache //建立軟串連,捷徑 
#ln -s /etc/rc.d/init.d/apached /etc/rc0.d/K20apache

linux下安裝apache與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.