ubuntn 安裝apache

能上網的話sudo apt-get install apache2

不能上網先去官方下載apache2.0 : httpd-2.0.63.tar.gz 

1.解壓縮httpd-2.0.63.tar.gz到臨時目錄如~/httpd-2.0.63 

2.進入~/httpd-2.0.63目錄,執行 
#./configure --prefix=/usr/local/apache2 --enable-module=so 
#make 
#make install 

實際執行過程中可能要求你有root權限,所以要求使用sudo. 
如果需要mod_rewrite模塊,需要加參數: --enable-rewrite 

3.啓動和停止apache 
啓動:sudo /usr/local/apache2/bin/httpd -k start 
啓動時提示: 
  httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName. 
解決辦法是在http.conf中加一行: 
  ServerName 127.0.0.1:80 

停止:sudo /usr/local/apache2/bin/httpd -k stop 

4.讓Ubuntu開機自動啓動apache. 
1). 複製 /usr/local/apache2/bin/apachectl到/etc/init.d 
2). 加載爲服務 
     sudo update-rc.d apachectl defaults 

開機重啓訪問http://localhost/如果顯示apache的網頁,就說明自動啓動成功了。

在ubuntu下啓動apache和mysql的命令

  1. // Apache  
  2. //Task: Start Apache 2 Server /啓動apache服務  
  3. # /etc/init.d/apache2 start  
  4. //or  
  5. $ sudo /etc/init.d/apache2 start  
  6. //Task: Restart Apache 2 Server /重啓apache服務  
  7. # /etc/init.d/apache2 restart  
  8. //or  
  9. $ sudo /etc/init.d/apache2 restart  
  10. //Task: Stop Apache 2 Server /停止apache服務  
  11. # /etc/init.d/apache2 stop  
  12. //or  
  13. $ sudo /etc/init.d/apache2 stop   
  14. // Mysql  
  15. /etc/init.d/mysql start  
  16. /etc/init.d/mysql stop  
  17. /etc/init.d/mysql restart 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章