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
(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这里复制一个
在里面修改ServerName www.cct.com,
DocumentRoot /home/mengxin/web
保存退出
然后在apache2.conf中复制一份
修改以下Directory路径保存并退出
然后打开浏览器访问一下,世界就清净了……
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路径保存并退出
然后打开浏览器访问一下,世界就清净了……
相关文章推荐
- [转]通过命令查看apache的位置
- apache commons fileupload Clirr结果(2016-07-01更新)
- java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration
- Apache Prefork、Worker和Event三种MPM分析
- 【Shiro】Apache Shiro架构之实际运用(整合到Spring中)
- java.lang.ClassNotFoundException: org.apache.hadoop.util.PlatformName
- Linux安装apache全过程
- 利用Apache commons-net 包进行FTP文件和文件夹的上传与下载
- 架构设计:系统间通信(39)——Apache Camel快速入门(下2)
- Linux下安装、配置、启动Apache
- [转]Apache Maven 入门篇 ( 上 )
- [转]Apache Maven 入门篇(下)
- 【Apache Thrift】thrift入门教程(一)windows下thrift的安装
- org.apache.subversion.javahl.ClientException: svn: E175002: Commit failed 的解决办法
- 【Shiro】Apache Shiro架构之自定义realm
- apache的ab命令做压力测试
- 使用Apache.commons.io文件工具类FileUtils,IOUtils使用
- 【Shiro】Apache Shiro架构之集成web
- 利用Apache的. htaccess完美解决301重定向
- hadoop入门第七步---hive部署安装(apache-hive-1.1.0)