前提
centos下apache默认网站根目录为/var/www/html,假如我默认存了一个ci项目在html文件夹里,同时服务器的外网ip为exampleip,因为使用的是mvc框架,apache需开启重定向功能。
方法如下
/etc/httpd/conf/httpd.conf文件配置如下:
documentroot "/var/www/html/ci"
options followsymlinks allowoverride all
# # 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 indexes followsymlinks # # 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 all # # controls who can get stuff from this server. # order allow,deny allow from all
配置完使用“service httpd restart”重启apache,那么直接在浏览器里输入http://exampleip,就直接映射到/var/www/html/ci文件夹里了
1、配置多域名映射。假设需要映射www.website1.com和www.website1.com这两个域名,在文档httpd.conf最后添加
namevirtualhost *:80documentroot /var/www/html/website1 servername http://www.website1.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website1 servername http://website1.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website2 servername http://www.website2.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website2 servername http://website2.com options indexes followsymlinks allowoverride all order allow,deny allow from all
website1和website2为工程目录.配置完使用“service httpd restart”重启apache
2、配置多端口映射。
2.2、首先需要监听端口,在文档httpd.conf的listen 80下添加需要监听的端口,举例为8080
listen 80 listen 8080
2.2、在文档最后添加端口映射功能
documentroot /var/www/html/website3 servername exampleip:8080 options indexes followsymlinks allowoverride all order allow,deny allow from all
website3为工程目录.配置完使用“service httpd restart”重启apache
下一篇:SQL中怎么判断给定日期值