阿帕奇:如何部署网站,而不是在/ var / www /,脚本与本地主机不同的端口? [英] Apache: How to deploy websites, not in /var/www/, with different ports in localhost?

查看:124
本文介绍了阿帕奇:如何部署网站,而不是在/ var / www /,脚本与本地主机不同的端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了文件的/ etc / apache2的/网站的可用/默认来这样的事情(在Ubuntu的默认设置为原有的评论):

 的DocumentRoot /家庭/ XYZ /工作区/ XXX
    #DocumentRoot在/ var / WWW
    ...
    #<目录/ var / WWW />
    <目录为/ home / XYZ /工作区/ XXX>
    ...
    < /目录>
    ...

这hxck让我看到了在本地主机新目录的东西,而不 /无功/网络/ 部署的事情。现在我需要做的同样的事情不同的文档不XXX -dir所以我想在不改变当前以指定部署许多迪尔斯。我可以通过创建许多用户,但想法较差做到这一点。我不能有许多根-dirs,我需要明确指定端口。如何可以部署多个站点(有时需要PHP - 支持等),在不同的显示目录(不只是在/ var / WWW)通过配置Apache?


  

或许相关


  
  

      
  1. 也许同样的目标,但解决方案mod_proxy的,
      <一href=\"http://stackoverflow.com/questions/2403227/web-apps-on-localhost-on-different-ports-accessed-via-port-80\">web在不同的端口本地主机的应用程序通过端口访问80

  2.   


解决方案

您可以用更改到任何端口:

  *了NameVirtualHost:端口号
&LT;虚拟主机*:端口号&GT;



&LT; /虚拟主机&GT;

有关更改目录只需要一套文档根目录文件夹

 &LT;虚拟主机*:80&GT;
服务器名customname.dev
的DocumentRoot/路径/到/文件夹/网络
错误日志/路径/到/文件夹/ ELOG
的CustomLog//路径/到/文件夹/堵塞共同
&LT;目录/路径/到/文件夹/网络&GT;
    所有的AllowOverride
&LT; /目录&GT;
&LT; /虚拟主机&GT;

该ServerName是用于同一端口部署许多应用程序,只更改文件的 / etc / hosts文件

  127.0.0.1本地主机
127.0.1.1名-PC
127.0.0.1 customname.dev#以下行是希望支持IPv6的主机
:: 1 IP6-本地主机IP6回送
FE00 :: 0 IP6-localnet的
FF00 :: 0 IP6-MCAST preFIX
FF02 :: 1 IP6-allnodes中
FF02 :: 2 IP6-allrouters

记住任何改变之后执行的须藤服务的Apache2重启的。您还可以进入使用的 http://custonname.dev:port

I changed the file /etc/apache2/sites-available/default to something like this (comments for the original ones in Ubuntu's defaults):

    DocumentRoot /home/xyz/workspace/xxx
    #DocumentRoot /var/www
    ...
    #<Directory /var/www/>
    <Directory /home/xyz/workspace/xxx>
    ...
    </Directory>
    ...

This hxck allowed me to see things of the new dir in localhost, without deploying things in /var/www/. Now I need to do that same thing for different documents not in xxx -dir so I want to specify many dirs for deployment without changing the current one. I could do this by creating many users but poor idea. I cannot have many root -dirs and I need to specify ports explicitly. How can deploy many sites (sometimes requiring PHP -support etc) in different dirs (not just /var/www) by configuring apache?

Perhaps related

  1. perhaps the same goal but solution mod_proxy, web apps on localhost on different ports accessed via port 80

解决方案

You can change to any port using:

NameVirtualHost *:portnumber
<VirtualHost *:portnumber>
.
.
.
</VirtualHost>

For change directory only need set document root folder

<VirtualHost *:80>
ServerName  customname.dev
DocumentRoot "/path/to/folder/web"
ErrorLog "/path/to/folder/elog"
CustomLog "//path/to/folder/clog" common
<Directory "/path/to/folder/web">
    AllowOverride   All
</Directory>
</VirtualHost>

The ServerName is used for deploy many apps in the same port, only change the file /etc/hosts

127.0.0.1   localhost
127.0.1.1   name-pc
127.0.0.1   customname.dev

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Remember after any change execute sudo service apache2 restart. And you can enter using http://custonname.dev:port

这篇关于阿帕奇:如何部署网站,而不是在/ var / www /,脚本与本地主机不同的端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆