Symfony:许多不同领域的许多项目
我现在正在学习 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧:
在 /etc/apache2/httpd.conf 中就足够了:
我在创建其他 ServeName (教程)时重复了此命令。也许这就是冲突。我把所有的东西都留在了80端口。现在它解决了。
所以,这是最终的 /etc/apache2/httpd.conf:
/etc/hosts (或 debian 的 /etc/apache2/sites-avaiable 中)是相同的。
我可以访问 www.jobeet.com.localhost 和 www.tutorial.com.localhost
抱歉,这是我的配置错误。
Well:
In /etc/apache2/httpd.conf is enough with:
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:
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.
一个常见的错误是禁用了 apache 的虚拟主机模块,要启用它,请尝试:
sudo a2enmod virtualhost
将您的虚拟主机配置放入
/etc/apache2/sites-available/name-file-with-vhost-conf
必须启用所有虚拟主机,并使用
sudo a2ensite name-file-with- vhost-conf
必须重新加载 apache2
sudo service apache2重新加载
你可以尝试这个github/rokemaster/virtual_hosts 是一个脚本中的所有步骤
A common mistake is to have disabled the virtual host module for apache, for enable it try:
sudo a2enmod virtualhost
put your vhost conf in
/etc/apache2/sites-available/name-file-with-vhost-conf
all virtual host must be enabled, with
sudo a2ensite name-file-with-vhost-conf
apache2 must be reloaded
sudo service apache2 reload
you can try this github/rokemaster/virtual_hosts is all steps in one script