在ubuntu上创build虚拟主机apache2时出现a2ensite错误“网站不存在”

我在/ home / junda / www /目录下为我的网站创build了文件。 我使用symfony2,意味着公共文件进入/ home / junda / www / symfony2-tries / web /目录。

然后我input以下命令到terminal更改权限:

sudo chmod -R a+rX ~/www sudo chmod a+rx ~ 

我还使用以下内容创build/etc/apache2/sites-available/symfony2-tries.com文件:

 # domain: symfony2-tries.com # public: /home/junda/www/symfony2-tries.com/ <VirtualHost *:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin [email protected] ServerName www.symfony2-tries.com ServerAlias symfony2-tries.com # Index file and Document Root (where the public files are located) DirectoryIndex app.php DocumentRoot /home/junda/www/symfony2-tries/web # Custom log file locations LogLevel warn ErrorLog /home/junda/www/symfony2-tries/log/error.log CustomLog /home/junda/www/symfony2-tries/log/access.log combined </VirtualHost> 

之后,我试图启用它使用a2ensite。

 sudo a2ensite symfony2-tries 

但是它返回:

 ERROR: Site symfony2-tries.com does not exist! 

任何人都可以好好告诉我,我做错了什么? 如果可能的话,如何纠正它。 非常感谢你。

我find了解决scheme!

/etc/apache2/sites-available/所有文件现在都必须具有.conf扩展名。

例如: symfony2-triessymfony2-tries.conf重命名它

键入sudo a2ensite symfony2-tries.conf并重新启动apache。