默认情况下,linux上apache使用的
默认文档目录是:/var/www
默认端口是:80
如果想发布自己的一个系统资源目录,可以使用下面的方法,执行如下命令:
(1)添加监听端口
#cd /etc/apache2
#vim ports.conf
文件添加:
namevirtualhost *:8000
listen 8000
(2)配置虚拟目录
#cd /etc/apache2/sites-available
#cp default default-me
#vim default-me
文件内容如下:
复制代码 代码如下:
8000 >
serveradmin webmaster@localhost
documentroot /wwwroot
options followsymlinks
allowoverride none
wwwroot/ >
options indexes followsymlinks multiviews
allowoverride none
order allow,deny
allow from all
errorlog /var/log/apache2/error.log
# possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
loglevel warn
customlog /var/log/apache2/access.log combined
粗体部分是关键点。
(3)发布站点
# ln -s /etc/apache2/sites-available/default-me /etc/apache2/sites-enabled/001-default
(4)重启服务
#/etc/init.d/apache2 restart
(5)测试
http://localhost:8000/
如果能够正常访问就说明配置正确了。
复制代码 代码如下:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# virtual hosts
#
# if you want to maintain multiple domains/hostnames on your
# machine you can setup virtualhost containers for them. most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# ip addresses. this is indicated by the asterisks in the directives below.
#
# please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# you may use the command line option '-s' to verify your virtual host
# configuration.
#
# use name-based virtual hosting.
#
namevirtualhost *:81
namevirtualhost *:82
namevirtualhost *:83
namevirtualhost *:84
namevirtualhost *:85
namevirtualhost *:86
#
# virtualhost example:
# almost any apache directive may go into a virtualhost container.
# the first virtualhost section is used for all requests that do not
# match a servername or serveralias in any block.
#
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/www-nongye
servername www.dede.com
errorlog d:/appserv/www/www-nongye/errornongye.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
options followsymlinks
#deny from all
allow from all
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www-chinaec
servername www.dede.com
directoryindex index.php index.html
errorlog d:/appserv/www-chinaec/errornongjiale.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/www-05110
servername www.dede.com
errorlog d:/appserv/www/www-05110/errornong05110.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/wordpress
servername www.dede.com
errorlog d:/appserv/www/wordpress/errornongwordpress.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/magento
servername www.dede.com
errorlog d:/appserv/www/magento/errormagento.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/magento1322
servername www.dede.com
errorlog d:/appserv/www/magento1322/errormagento1322.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin jsw7001@hotmail.com
documentroot d:/appserv/www/www-nongjiale
servername www.dede.com
errorlog d:/appserv/www/www-nongjiale/errornongjiale.log
customlog logs/dummy-host2.appservnetwork.com-access_log common
serveradmin webmaster@dummy-host2.x
documentroot c:/apache2.2/docs/dummy-host2.x
servername dummy-host2.x
errorlog logs/dummy-host2.x-error.log
customlog logs/dummy-host2.x-access.log common
1、单域名单端口设置
如:www.abc.com 默认用80访问
特别说明,apache的配置默认都在安装目录下的conf目录里面
或者是/etc/apache2
不过一定要注意,listen.conf文件中端口监听是否开启
如下图,表示已经开启80端口监听
直接默认
1、单域名单端口设置
如:www.abc.com 默认用80访问
特别说明,apache的配置默认都在安装目录下的conf目录里面
或者是/etc/apache2
不过一定要注意,listen.conf文件中端口监听是否开启
如下图,表示已经开启80端口监听
直接默认修改default-server.conf
这个配置最好简单
安装好了,之后,默认已经能够使用了,只是要把它修改成你需要的域名及访问路径罢了。
给一个标准配置吧
复制代码 代码如下:
documentroot /srv/www/htdocs
#
# configure the documentroot
#
# possible values for the options directive are none, all,
# or any combination of:
# indexes includes followsymlinks symlinksifownermatch execcgi multiviews
#
# note that multiviews must be named *explicitly* --- options all
# doesn't give it to you.
#
# the options directive is both complicated and important. please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
options none
# allowoverride controls what directives may be placed in .htaccess files.
# it can be all, none, or any combination of the keywords:
# options fileinfo authconfig limit
allowoverride none
# controls who can get stuff from this server.
order allow,deny
allow from all
2、单域名多端口设置
复制代码 代码如下:
options none
allowoverride none
order allow,deny
allow from all
options none
allowoverride none
order allow,deny
allow from all
namevirtualhost *:80
namevirtualhost *:81
directoryindex index.html index.php
servername www.abc.com
documentroot /srv/www/htdocs/
directoryindex index.php
servername www.abc.com:81
documentroot /srv/www/htdocs/bbs/
3、多域名多端口设置
复制代码 代码如下:
options none
allowoverride none
order allow,deny
allow from all
options none
allowoverride none
order allow,deny
allow from all
options none
allowoverride none
order allow,deny
allow from all
namevirtualhost *:80
namevirtualhost *:81
directoryindex index.html index.php
servername www.abc.com
documentroot /srv/www/htdocs/
directoryindex index.html index.php
servername www.btc.com
documentroot /srv/www/htdocs/btc
directoryindex index.php
servername www.abc.com:81
documentroot /srv/www/htdocs/bbs/
需要注意的问题是,多端口监听,一定要注意listen.conf文件,是否开启了相应端口。
http://www.bkjia.com/phpjc/327524.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/327524.htmltecharticle默认情况下,linux上apache使用的 默认文档目录是:/var/www 默认端口是:80 如果想发布自己的一个系统资源目录,可以使用下面的方法,执行如...
