准备好环境,就要开始进行开发了。这一篇,我们在Ubuntu Apache上配置虚拟目录。

知识准备:

区别于Windows 下apache,配置文件通常只有一个,就是httpd.conf。

Linux下 Apache的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。

在apache2.conf里有sites-enabled目录,而在 /etc/apache2下还有一个sites-available目录,其实,这里面才是真正的配置文件,而sites- enabled目录存放的只是一些指向这里的文件的符号链接,你可以用ls /etc/apache2/sites-enabled/来证实一下。

所以,如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在 sites-available下,那么对于虚拟主机的停用、启用就非常方便了:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链 接时,就启用了它;如果要关闭某个虚拟主机的话,只需删除相应的链接即可,根本不用去改配置文件。

了解这些以后,就开始配置apache之旅吧~

1. copy /etc/apache2/sites-avaliable/default , 命名为 chaichunyan

2.修改配置文件:chaichunyan

  1. <VirtualHost *:80>
  2. ServerAdmin webmaster@localhost
  3. ServerName www.ccy.com
  4. DocumentRoot /var/www/ccy
  5. <Directory /var/www/ccy>
  6. Options Indexes FollowSymLinks MultiViews
  7. AllowOverride None
  8. Order allow,deny
  9. allow from all
  10. </Directory>
  11. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  12. <Directory "/usr/lib/cgi-bin">
  13. AllowOverride None
  14. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  15. Order allow,deny
  16. Allow from all
  17. </Directory>
  18. ErrorLog ${APACHE_LOG_DIR}/error.log
  19. # Possible values include: debug, info, notice, warn, error, crit,
  20. # alert, emerg.
  21. LogLevel warn

前提是你已经在 /var/www 下已经cychai目录

3. 建立链接文件:

sudo ln -s /etc/apache2/sites-available/chaichunyan  /etc/apache2/sites-enabled/chaichunyan

4. 重启apache 服务器

sudo /etc/init.d/apache2 restart

5. 客户端(如windows 7)修改hosts

添加

192.168.102.8     www.ccy.com

Internet 选线--连接 -- 添加例外

6. 访问

www.ccy.com OK,配置成功!

Reference:

Ubuntu上安装Apache,每次重启,都会出现以下错误提示:

Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

解决方法:

http://blog.csdn.net/klinghr/article/details/5378271

ubuntu apache2配置详解(含虚拟主机配置方法)

http://www.guanwei.org/post/LINUXnotes/01/ubuntuapache2configure.html

Apache2: Virtual Hosts in ubuntu

Virtual Hosts
Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in /etc/apache2/sites-available. By default, there is one site available called default this is what you will see when you browse to http://localhost or http://127.0.0.1. You can have many different site configurations available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/. To do this, we must create a new site and then enable it in Apache2.

To create a new site:

Copy the default website as a starting point.

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite

Edit the new configuration file in a text editor “sudo nano” on the command line or “gksudo gedit”, for example:

gksudo gedit /etc/apache2/sites-available/mysite

Change the DocumentRoot to point to the new location. For example, /home/user/public_html/
Change the Directory directive, replace to 
You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites
Save the file
Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

sudo a2dissite default && sudo a2ensite mysite

Finally, we restart Apache2:

sudo /etc/init.d/apache2 restart

If you have not created /home/user/public_html/, you will receive an warning message

To test the new site, create a file in /home/user/public_html/:

echo '<b>Hello! It is working!</b>' > /home/user/public_html/index.html

Finally, browse to http://localhost/

The above content was taken from the website at https://help.ubuntu.com/community/ApacheMySQLPHP

http://www.anisjendoubi.com/tag/httpd/

apache 2 修改虚拟目录的更多相关文章

  1. Apache 配置方法(虚拟目录、域名、虚拟主机等)

    基本配置 Define SRVROOT "C:/Apache24"     #宏定义一个主站点目录常量ServerRoot "${SRVROOT}"       ...

  2. apache php配置 虚拟目录 和 虚拟主机 多域名配置 原理解析

    虚拟目录配置 就是说,我们放项目放在D盘,F盘,而不是默认的www文件夹下也可以访问.比如这里,我在 D:/PHP/work 放入的项目文件. 在httpd.conf加入: (位置一般是在 </ ...

  3. Apache多网站虚拟目录域名

    一台服务器安装了Apache,如何绑定多个域名或网站呢? 最简单高效的方法如下: 1. 先打开Apache的配置文件httpd.conf,在这个文件, 找到这句:“#Include etc/extra ...

  4. IIS的虚拟目录和子应用程序

    一.虚拟目录     虚拟目录是指在发布的网站下建立一个虚拟子目录,指定一个固定的物理路径做为站点的应用路径.     1. 虚拟目录与父级站点共用一个应用程序池,网站Test是在D盘下建立了的虚拟目 ...

  5. Weblogic虚拟目录

    p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...

  6. 【原创】Apache和基于虚拟主机的Tomcat集群方案

    最近建设了北京某政府机构的网站,网站前段使用Apache做负载均衡,后端使用Tomcat做的集群,基于虚拟主机的方式访问,并且实现了静态资源和动态资源的分离. 开始的建设方案有两种,一种是使用apac ...

  7. apache 虚拟目录

    补充:必须使用80端口才能正常使用  C:\Windows\System32\drivers\etc\hosts 最后添加上: 127.0.0.1 shenyi.com 127.0.0.1 offli ...

  8. apache的虚拟目录的配置

    第一步:在httpd.conf底部添加以下代码.表示添加虚拟目录 1 <IfModule dir_module> #direcotory相当于是欢迎页面 DirectoryIndex in ...

  9. apache 配置网站目录,虚拟目录,新端口

    1 配置网站目录,以ubuntu为例 1)打开apache的默认配置文件夹:cd /etc/apache2/sites-available 2)打开配置文件,本机为sudo vi  000-defau ...

随机推荐

  1. C语言排序算法之简单交换法排序,直接选择排序,冒泡排序

    C语言排序算法之简单交换法排序,直接选择排序,冒泡排序,最近考试要用到,网上也有很多例子,我觉得还是自己写的看得懂一些. 简单交换法排序 /*简单交换法排序 根据序列中两个记录键值的比较结果来对换这两 ...

  2. 间隔问题,合并间隔(merge interval),插入间隔(insert interval)

    Merge Interval: Given a collection of intervals, merge all overlapping intervals. For example,Given  ...

  3. root run-parts

    crontab的文件格式 分 时 日 月 星期 要运行的命令 第1列分钟0-59 第2列小时0-23(0表示子夜) 第3列日1-31 第4列月1-12 第5列星期0-7(0和7表示星期天) 第6列要运 ...

  4. mac的一些配置

    1,基础知识 /etc/bashrc :是针对系统所有用户的全局变量,只有root用户才能修改这两个文件,对一般用户来说是他们是只读的.一般用户要想修改它们,可以在命令前加sudo,意思是以Root身 ...

  5. scala学习手记40 - case表达式里的模式变量和常量

    再来看一下之前的一段代码: def process(input: Any) { input match { case (a: Int, b: Int) => println("Proc ...

  6. 使用Entity Framework时遇到的各种问题总结

    在这里记录一下之前使用Entity Framework(4.3.1版本)遇到的问题. 更新没有设置主键的表 在默认情况下,EF不能对一个没有主键的表进行更新.插入和删除的动作.用xml方式查看edmx ...

  7. Python 导出数据from Mysql

    环境 Anaconda3 Python 3.6, Window 64bit 目的 从MySQL数据库读取目标表数据,并处理 代码 # -*- coding: utf-8 -*- import pand ...

  8. python脚本3_输入若干个整数打印出最大值

    #输入若干个整数,打印出最大值 # m = int(input('Input first number >>>')) while True: c = input('Input a n ...

  9. 四十七 Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)用Django实现搜索的自动补全功能

    elasticsearch(搜索引擎)提供了自动补全接口 官方说明:https://www.elastic.co/guide/en/elasticsearch/reference/current/se ...

  10. 四则运算生成与校检 Python实现

    GitHub地址 https://github.com/little-petrol/Arithmetic.git 合作者: 郭旭 和 卢明凯 设计实现过程 代码的组织主要分为两个部分: 算法与结构体的 ...