Symfony:许多不同领域的许多项目

发布于 2025-01-01 14:06:39 字数 2374 浏览 2 评论 0原文

我现在正在学习 Symfony。我创建了 2 个具有 2 个不同域的 Symfony 项目。尽管如此,我的第二个域指向第一个域,但不知道为什么。

我正在关注这个教程,著名的 jobeet: http://www.symfony-project.org/ jobeet/1 ... rine/en/01

注意我的配置:

我的 /etc/apache2/httpd.conf

ServerName localhost

#From the symfony tutorial "jobeet"
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
    AllowOverride All
   Allow from All
 </Directory>
</VirtualHost>


#Another symfony tutorial
NameVirtualHost 127.0.0.1:8081

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

注意我正在收听 8081端口在教程域。我尝试了 VirtualHost 127.0.0.1:80 和 VirtualHost 127.0.0.1:81 的排列。两者都不起作用。 (实在不知道有什么用)

我的/etc/hosts:

#From the symfony tutorial
127.0.0.1 www.jobeet.com.localhost

#From ANOTHER symfony tutorial
127.0.0.1 www.tutorial.com.localhost

之后我重新启动了Apache。

现在,当我这样做时: http://www.jobeet.com.localhost/frontend_dev.php/ 我去到我的 Jobeet 教程,但是当我做 http://www.tutorial.com.localhost/frontend_dev.php/转到 Jobeet 页面。我应该去看包含教程部分的内容。

为什么工作?!

I'm learning Symfony right now. I created 2 Symfony projects with 2 different domains. Nevertheless, my second domain points to the first, and don't know why.

I'm following this tutorial, the famous jobeet: http://www.symfony-project.org/jobeet/1 ... rine/en/01

Notice my configurations:

My /etc/apache2/httpd.conf

ServerName localhost

#From the symfony tutorial "jobeet"
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
    AllowOverride All
   Allow from All
 </Directory>
</VirtualHost>


#Another symfony tutorial
NameVirtualHost 127.0.0.1:8081

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

Notice that I'm listening to 8081 port in the tutorial domain. I tried the permutation of VirtualHost 127.0.0.1:80 and VirtualHost 127.0.0.1:81. Neither worked. (really don't know which use)

My /etc/hosts:

#From the symfony tutorial
127.0.0.1 www.jobeet.com.localhost

#From ANOTHER symfony tutorial
127.0.0.1 www.tutorial.com.localhost

After that I restarted Apache.

Now, when I do:
http://www.jobeet.com.localhost/frontend_dev.php/ I go to my Jobeet tutorial things, BUT when I do http://www.tutorial.com.localhost/frontend_dev.php/ I ALSO go to the Jobeet page. I should go to the one containing the tutorial part.

Why is not working??!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半岛未凉 2025-01-08 14:06:39

好吧:

在 /etc/apache2/httpd.conf 中就足够了:

 NameVirtualHost 127.0.0.1:80

我在创建其他 ServeName教程)时重复了此命令。也许这就是冲突。我把所有的东西都留在了80端口。现在它解决了。

所以,这是最终的 /etc/apache2/httpd.conf:

ServerName localhost

NameVirtualHost 127.0.0.1:80

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
   AllowOverride All
   Allow from All
</Directory>
</VirtualHost>


#Another symfony tutorial
# DO NOT REPEAT NameVirtualHost 127.0.0.1:80 --------> ****HERE: do not repeat this****

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
 </VirtualHost>

/etc/hosts (或 debian 的 /etc/apache2/sites-avaiable 中)是相同的。

我可以访问 www.jobeet.com.localhost 和 www.tutorial.com.localhost

抱歉,这是我的配置错误。

Well:

In /etc/apache2/httpd.conf is enough with:

 NameVirtualHost 127.0.0.1:80

I repeated this command when creating the other ServeName (tutorial). Maybe that was the conflict. I left all in port 80. Now it resolve right.

So, this is the final /etc/apache2/httpd.conf:

ServerName localhost

NameVirtualHost 127.0.0.1:80

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
   AllowOverride All
   Allow from All
</Directory>
</VirtualHost>


#Another symfony tutorial
# DO NOT REPEAT NameVirtualHost 127.0.0.1:80 --------> ****HERE: do not repeat this****

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
 </VirtualHost>

The /etc/hosts (or in /etc/apache2/sites-avaiable for debian) is the same.

I can access to www.jobeet.com.localhost and www.tutorial.com.localhost

Sorry, it was my misconfiguration.

世俗缘 2025-01-08 14:06:39
  1. 一个常见的错误是禁用了 apache 的虚拟主机模块,要启用它,请尝试: sudo a2enmod virtualhost

  2. 将您的虚拟主机配置放入 /etc/apache2/sites-available/name-file-with-vhost-conf

  3. 必须启用所有虚拟主机,并使用 sudo a2ensite name-file-with- vhost-conf

  4. 必须重新加载 apache2 sudo service apache2重新加载

你可以尝试这个github/rokemaster/virtual_hosts 是一个脚本中的所有步骤

  1. A common mistake is to have disabled the virtual host module for apache, for enable it try: sudo a2enmod virtualhost

  2. put your vhost conf in /etc/apache2/sites-available/name-file-with-vhost-conf

  3. all virtual host must be enabled, with sudo a2ensite name-file-with-vhost-conf

  4. apache2 must be reloaded sudo service apache2 reload

you can try this github/rokemaster/virtual_hosts is all steps in one script

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文