标签: virtualhost

如何配置Apache在同一个域中有两个symfony项目(不使用子域)?

我正在尝试将Apache配置为在同一个域下拥有不同的symfony项目(每个项目都有自己的框架安装),但我无法使用文件夹来使用它.

这就是我想要的:

  • mydomain.com/projectone/
  • mydomain.com/projecttwo/

我可以使用子域工作,但不是我的首选解决方案,因为我最终有疯狂的子域名,如:

  • projectone.mydomain.com
  • backend.projectone.mydomain.com
  • projecttwo.mydomain.com
  • backend.projecttwo.mydomain.com

我在Apache中使用此配置使其适用于子域:

<VirtualHost 127.0.0.1:8080>
  ServerName projectone.mydomain.com
  DocumentRoot "/home/projectone/web"
  DirectoryIndex frontend.php
  <Directory "/home/projectone/web">
    Options -Indexes IncludesNOEXEC FollowSymLinks -MultiViews
    AllowOverride None
    Allow from All

    RewriteEngine On
    # we check if the .html version is here (caching)
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    # no, so we redirect to our front web controller
    RewriteRule ^(.*)$ frontend.php [QSA,L]
  </Directory>

  Alias /sf /home/projectone/lib/vendor/symfony/data/web/sf
  <Directory "/home/projectone/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All …
Run Code Online (Sandbox Code Playgroud)

apache symfony1 virtualhost

6
推荐指数
1
解决办法
3146
查看次数

OS X Mavericks上支持SSL的虚拟主机

我在OS X 10.9(Mavericks)上运行Apache/2.2.24的本地开发机器上设置了一些虚拟主机.

我的http-vhosts.conf文件(配置为通过httpd.conf加载)如下所示:

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "/Library/WebServer/Documents"
   ServerName localhost
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/Users/me/Sites/testsite.com
   ServerName testsite.dev
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/Users/me/Sites/testsite2.com
   ServerName testsite2.dev
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我还配置了我的/ etc/vhosts文件来包含这一行:

127.0.0.1       testsite2.dev
Run Code Online (Sandbox Code Playgroud)

我希望能够通过SSL(https)使用testsite2.dev.我已经尝试了多个配置的vhosts配置文件,没有运气.

使用当前配置,转到http://testsite2.dev会拉出我期望的页面,而https://testsite2.dev指向/Library/WebServer/Documents/index.html.en上的apache主页

我尝试了以下配置,以及其他多个不起作用的配置:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
   DocumentRoot "/Library/WebServer/Documents"
   ServerName localhost
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/Users/me/Sites/testsite.com
   ServerName testsite.dev
</VirtualHost>

<VirtualHost *:80 *:443>
   DocumentRoot "/Users/me/Sites/testsite2.com
   ServerName testsite2.dev
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

是否可以让虚拟主机侦听本地计算机上的端口80和端口443?

apache ssl https virtualhost osx-mavericks

6
推荐指数
1
解决办法
8935
查看次数

Ubuntu 14.04:Apache 2.4.7虚拟主机无法正常工作/重定向

我在我的Ubuntu 14.04机器上安装了Apache 2.4.7,我的一些虚拟主机不同意我的意见.我有5个虚拟主机,我正在尝试运行; 其中3个工作,2个不工作.两个不起作用的.conf文件是:

002-tmpnet.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/tmpnet
    ServerName  tmpnet
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/html/tmpnet/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        #Order allow,deny
        #allow from all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

003-tmpcom.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/tmpcom
    ServerName  tmpcom
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/html/tmpcom>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        #Order allow,deny
        #allow from all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log …
Run Code Online (Sandbox Code Playgroud)

apache ubuntu virtualhost

6
推荐指数
3
解决办法
2万
查看次数

使用WildFly托管多个域(Undertow)

例如,我有两个域(app1.com,app2.com)和两个耳朵(app1.ear,app2.ear).每个EAR文件都包含ejb.jar和web.war.此外,每个WAR都有上下文根:/ app1/ app2.

所以,如果我开始WildFly我会对运行两个应用程序本地主机:8080/APP1本地主机:8080/APP 2.

如何将app1.com绑定到localhost:8080/app1app2.comlocalhost:8080/app2

据我了解,我应该在standalone.xml中修改Undertow子系统配置.我试过了:

<server name="default-server">
    <http-listener name="default" socket-binding="http"/>
    <host name="app1.com" default-web-module="app1.ear/web.war"/>
    <host name="app2.com" default-web-module="app2.ear/web.war"/>
</server>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

java jboss virtualhost wildfly undertow

6
推荐指数
1
解决办法
5688
查看次数

错误28105#0:*1 stderr发送的FastCGI:从上游读取响应头时"主脚本未知"

我不能配置Nginxphp-fpm正确.当我得到任何PHP脚本时,我404 Not found在浏览器中收到Nginx 错误:

File not found.
Run Code Online (Sandbox Code Playgroud)

在我的php-fpm日志中,我得到:

172.17.42.1 -  28/Apr/2015:09:15:15 +0000 "GET /index.php" 404
Run Code Online (Sandbox Code Playgroud)

任何PHP脚本调用和Nginx日志我得到:

[error] 28105#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.168.66.66:9000", host: "localhost"
Run Code Online (Sandbox Code Playgroud)

我的Nginx vitualhost配置是:

server {
  listen 80;

  root /var/www/html;
  index index.html;

  server_name localhost;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back …
Run Code Online (Sandbox Code Playgroud)

php virtualhost nginx docker

6
推荐指数
1
解决办法
7617
查看次数

www和非www VirtualHost的单行配置

我有很多VirtualHost,似乎我们每次都需要做这两行:

<VirtualHost *:80>
  ...
  ServerName www.example.com
  ServerAlias example.com
Run Code Online (Sandbox Code Playgroud)

是否有允许这样做的单行解决方案?

<VirtualHost *:80>
  ServerName *.example.com   # works for both http://example.com and http://www.example.com
Run Code Online (Sandbox Code Playgroud)

即无需复制example.com

apache apache2 virtualhost apache2.4

6
推荐指数
1
解决办法
135
查看次数

Apache2访问仅限于本地LAN

直到最近,我还有一堆虚拟网站设置如下:

<VirtualHost 127.0.0.1:1234>
    ...
Run Code Online (Sandbox Code Playgroud)

这适用于在我使用Linux桌面的本地计算机上进行测试.为了测试MS和资源管理器如何从我的Windows笔记本电脑显示我的页面,我将其更改为

<VirtualHost *:1234>
    ...
Run Code Online (Sandbox Code Playgroud)

这也很好,在我的笔记本电脑的IE 上从http:// [mylinuxservername]:1234调用网站.但是,我想将该通配符限制为本地局域网.插入任何ip,如192.nnn.nnn.nnn或192.*.*.*,其中通配符在上面导致在Windows机器上403 Forbidden.本地服务器在我的Linux机箱上仍能正常工作:

<VirtualHost 127.0.0.1:1234 192.*.*.*:1234>
    ...
Run Code Online (Sandbox Code Playgroud)

要么

<VirtualHost 127.0.0.1:1234 192.nnn.nnn.nnn:1234> #exact IP of laptop
    ...
Run Code Online (Sandbox Code Playgroud)

无论如何,我不喜欢上面第二个配置示例中的那个通配符.提示任何人?

apache2 virtualhost

5
推荐指数
1
解决办法
2万
查看次数

如何在Ubuntu 12.10中创建VirtualHost

我跟随了很多文章"如何在Ubuntu中创建VirtualHost".这就是我所做的

安装Apache

sudo apt-get  install lamp-server^ phpmyadmin
Run Code Online (Sandbox Code Playgroud)

我创建了site1.com在/ var/www /中调用的文件夹

然后我创建了该文件 /etc/apache2/sites-available/site1.com

然后将以下代码添加到该site1.com文件中

<VirtualHost *:80>
    ServerName www.site1.com
    ServerAdmin mifas@site1.com
    ServerAlias site1.com
    DocumentRoot /var/www/site1.com

    # Other directives here
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory /var/www/site1.com/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

然后我编辑主机文件添加了以下代码行

127.0.0.1   site1.com
Run Code Online (Sandbox Code Playgroud)

编辑 我也启用了site1.comsudo a2ensite site1.com

然后我重新启动apache serivice.(即使我重新启动了电脑)

当我去site1.com时,会说The connection has timed out错误信息.但我可以浏览localhost/site1.com.自从过去两天以来我一直在努力.没有解决方案.并关注了许多文章和视频.

apache ubuntu virtualhost

5
推荐指数
0
解决办法
5533
查看次数

我的虚拟主机上的Apache 500内部服务器错误

我的网络应用程序项目位于/ media/disk1/Projects中的文件夹中.我想使用Apache虚拟主机来为它们提供服务http://lab/.

这就是我设置虚拟主机的方式:

1.将/ etc/apache2/sites-available/default复制到/ etc/apache2/sites-available/lab

2.编辑/ etc/apache2/sites-available/lab到以下内容:

<VirtualHost *:80>
ServerAdmin tim@localhost
ServerName lab

DocumentRoot /media/disk1/Projects
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
# <Directory /var/www/>
<Directory /media/disk1/Projects>
    Require all granted
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

3.添加127.0.0.1 lab到我的/ etc/hosts:

127.0.0.1   localhost
127.0.0.1   lab
Run Code Online (Sandbox Code Playgroud)

4. http://lab只能访问500 Internal Server Error

所有子文件夹权限都设置为drwxrwxrwx但我的http://lab/phpmyadmin工作.

帮我解决 谢谢.

apache ubuntu lamp virtualhost vhosts

5
推荐指数
1
解决办法
8万
查看次数

为什么所有不匹配的流量都转到第一个VirtualHost,而不是转到httpd.conf中的默认站点配置

我一直想知道为什么所有不匹配的流量都流向第一个VirtualHost而不是httpd.conf中的默认站点配置?

假设httpd.conf没有被编辑。

我创建一个名为 /etc/httpd/conf.d/vhost.conf

具有以下内容:

<VirtualHost *:80>
        ServerName website.com
        ServerAlias www.website.com
        DocumentRoot "/site1"
        <Directory "/site1">
                AllowOverride All
                Require all granted
        </Directory>

        Some Rules Here
</VirtualHost>
<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot "/site2"
        <Directory "/site2">
                AllowOverride All
                Require all granted
        </Directory>

        Some Rules Here
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,如果您发送对stackoverflow.com的请求,则无论过滤器是什么,而不是httpd.conf中的默认网站,都将被过滤到第一个虚拟主机中

我想念什么?

linux apache centos virtualhost httpd.conf

5
推荐指数
1
解决办法
1751
查看次数