您的位置:首页 > 运维架构 > Apache

ubuntu下配置多站点Apache笔记

2016-07-12 17:23 369 查看
一.首先的基本操作

1.重启Apache

$ sudo /etc/init.d/apache2 restart

(service apache2 restart )

2.启动Apache

$ sudo /etc/init.d/apache2 start

3停止Apache服务

$ sudo /etc/init.d/apache2 stop

二.如果apache搞崩了,千万别犹豫粗暴点卸载了!!!(这里的卸载是把php组件一起都卸载了)

卸载apache2

之前卸载重新安装后找不到apache2.conf配置文件,测试使用一下方式1.卸载。

(1) $ sudo apt-get –purge remove apache2

$ sudo apt-get --purge remove apache2.2-common

$ sudo apt-get autoremove


(2) (关键一步)找到没有删除掉的配置文件,一并删除

$ sudo find /etc -name “apache” -exec rm -rf {} \;

$ sudo rm -rf /var/www

2.装php+mysql+apache+phpmyadmin

详见链接:/article/5163087.html

三.重头戏来了,开始配置多站点(这个博主能搞一年!!!先让我哭一会儿)

第一步:$ sudo gedit /etc/hosts

事例:

127.0.0.1 localhost

127.0.0.1 www.cct.com

第二步:搞清楚两个文件 apache2.conf 和 sites-enabled下的000-default.conf

我们与windows下的配置对比后发现在000-default.conf这里复制一个

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.cct.com

ServerAdmin webmaster@localhost
DocumentRoot /home/mengxin/web

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>


在里面修改ServerName www.cct.com,

DocumentRoot /home/mengxin/web

保存退出

然后在apache2.conf中复制一份

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>


修改以下Directory路径保存并退出

然后打开浏览器访问一下,世界就清净了……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: