Ubuntu下安裝和配置Apache2,小編覺得挺不錯的,現在就分享給大家
本篇文章主要介紹了詳解Ubuntu下安裝和配置Apache2,小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。有興趣的朋友可以了解一下。(http://xz.8682222.com)
在Ubuntu中安裝apache
安裝指令:
sudo apt-get install apache2
安裝結束後:
產生的啟動和停止文件是:/etc/init.d/apache2
啟動:
sudo apache2ctl -k start
停止:
sudo apache2ctl -k stop
重新啟動:
sudo apache2ctl -k restart
配置文件保存在:/etc/apache2
需要說明的是,普通的apache發行版本配置文件是:httpd.conf
Ubuntu發行版本的主配置文件是:apache2.conf
在apache2.conf引用到了以下文件:
# 包含動態模塊的配置:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf# 包含用戶自己的配置:Include /etc/apache2/httpd.conf# 包含端口監聽的配置:Include /etc/apache2/ports.conf# 包含一般性的配置語句片斷:Include /etc/apache2/conf.d/# 包含虛擬主機的配置指令:Include /etc/apache2/sites-enabled/
修改httpd.conf
增加以下內容:
ServerName 127.0.0.1:80
ubuntu apache2配置
1.apache2.conf 是主配置文件,httpd.conf 用戶配置文件
2.虛擬目錄在 httpd.conf 中
DocumentRoot "路徑"ServerName 名稱 allow from all Options +Indexes
3.根設置(默認主目錄)在 /etc/apache2/sites-available/default
4.重啟命令
sudo /etc/init.d/apache2 restart或者cd /etc/init.dsudo apache2 -k restart
stop 停止;start 啟動5.日誌文件在 /var/log/apache2/
ServerName www.kimoqi.com DocumentRoot /home/vsftpd/kimoqi ServerName www.arwenedu.com DocumentRoot /home/vsftpd/wangguan/webapps ServerName www.arwenedu.org.cn DocumentRoot /home/vsftpd/wangguan/chem
vi /etc/httpd/conf/httpd.conf
在Windows下,Apache的配置文件通常只有一個,就是httpd.conf。但我在Ubuntu Linux上用apt-get install apache2命令安裝了Apache2後,竟然發現它的httpd.conf(位於/etc/apache2目錄)是空的!進而發現Ubuntu的 Apache軟件包的配置文件並不像Windows的那樣簡單,它把各個設置項分在了不同的配置文件中,看起來復雜,但仔細想想設計得確實很合理。
嚴格地說,Ubuntu的Apache(或者應該說Linux下的Apache?我不清楚其他發行版的apache軟件包)的配置文件是 /etc/apache2/apache2.conf,Apache在啟動時會自動讀取這個文件的配置信息。而其他的一些配置文件,如 httpd.conf等,則是通過Include指令包含進來。在apache2.conf中可以找到這些Include行:
引用
# Include module configuration: Include /etc/apache2/mods-enabled/*.load Include /etc/apache2/mods-enabled/*.conf# Include all the user configurations: Include /etc/apache2/httpd.conf# Include ports listing Include /etc/apache2/ports.conf……# Include generic snippets of statements Include /etc/apache2/conf.d/# Include the virtual host configurations: Include /etc/apache2/sites-enabled/
Ubuntu下安裝和配置Apache2,小編覺得挺不錯的,現在就分享給大家