Linux系統為Ubuntu
一、Start Apache 2 Server /啟動apache服務
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
二、 Restart Apache 2 Server /重啟apache服務
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
三、Stop Apache 2 Server /停止apache服務
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop
配置
1、在./etc/ 找到hosts文件,在hosts里面添加域名指向虛擬機IP地址 如
192.168.**.** video.xxx.com(命令行下ifconfig查看)
2、創建自己的根目錄:
例如
sudo mkdir /wwwroot
子目錄
sudo mkdir video
3、在video目錄下創建自己的主頁
sudo vi index.html
4.進入./etc/apache2/sites-available復制默認文件:
sudo cp 000-default.conf video.conf
5.修改vide.conf
sudo vi video.conf
將DocumentRoot 后面的目錄改為/wwwroot/video
在ServerAdmin上一行加入
ServerName video.imooc.com
6.修改apache2.conf
增加
<Directory /wwwroot/video/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
7.建立軟連接
進入/etc/apache2/sites-enabled 目錄下打開命令行工具
sudo ln -s ../sites-available/video.conf video.conf
8.重啟Apache2:
/etc/init.d/apache2 restart
9.在瀏覽器輸入video.xxx.com 會出現你創建的index.html內容
參考http://blog.csdn.net/lsmrsun/article/details/51593926