Ubuntu下apache2启动、停止、重启、配置

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

posted @ 2020-02-04 11:57  行方思远  阅读(2967)  评论(0编辑  收藏  举报