如何在浏览器中访问我的 zend 项目?
我在 /var/www/ 中创建了一个项目 student 但我无法使用虚拟热点访问它。
zf.sh create prohect student
我在 /etc/apache2/sites-available 中创建了一个文件 student ,如下所示:
<VirtualHost *:80>
ServerName student.dev
ServerAlias student.dev
DocumentRoot /var/www/student/public/
</VirtualHost>
然后我在终端中运行此文件:
sudo a2ensite student
我在 /etc/hosts 中有以下行
127.0.0.1 student.dev
重新启动 apache 服务器后:
sudo /etc/init.d/apache2 restart
但是当我在浏览器中访问 http://student.dev/ 时,它给我以下错误:
The server encountered an internal error or misconfiguration and was unable to complete your request.
但是当我访问 http://localhost/student/public/index.php 直接然后它就显示我欢迎成功,就像这样
Welcome to the Zend Framework!
This is your project's main page
编辑:
公共文件夹中的.htaccess文件
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I created a project student in /var/www/ But I am unable to access it using virtual hots.
zf.sh create prohect student
I created a file student in /etc/apache2/sites-available like this:
<VirtualHost *:80>
ServerName student.dev
ServerAlias student.dev
DocumentRoot /var/www/student/public/
</VirtualHost>
Then I run this in terminal:
sudo a2ensite student
I have following line in /etc/hosts
127.0.0.1 student.dev
After I restarted the apache server:
sudo /etc/init.d/apache2 restart
But when I access http://student.dev/ in browser it gives me following error:
The server encountered an internal error or misconfiguration and was unable to complete your request.
But when I access http://localhost/student/public/index.php directly then it shows me Welcome successfully like this
Welcome to the Zend Framework!
This is your project's main page
Edit:
.htaccess file in public folder
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的虚拟主机配置中缺少
配置。您的配置必须如下所示:
AllowOverride
设置告诉 apache 公共目录中的.htaccess
文件可能会覆盖常规设置。You're missing the
<Directory>
configuration in your vhost config.Your config has to look like that:
The
AllowOverride
setting tells apache that.htaccess
files in your public directory may override the general settings.