我正在 ubuntu 13.10 中配置 Zend 应用程序 (ZF2)。按照以下步骤操作:
- 将代码放在
/var/www/
中,名称为zfapp
虚拟主机配置:
<VirtualHost *:80>
ServerName zfapp.com DocumentRoot /var/www/zfapp/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
在
/etc/hosts
中为其创建虚拟主机127.0.0.1 zfapp.com
在
/etc/apache2/sites-available/zfapp.cof中添加文件
sudo a2enmod rewrite
sudo a2ensite zfapp.conf
sudo service apache2 restart
但是,当我浏览到该站点时 (zfapp.com/api/user/auth
);它给出以下错误:
Not Found The requested Url
/api/user/auth
was not found on this server
我有一个 javascript MVC 项目,我在其中使用 PHP 作为服务器端语言。
项目目录结构如下:
项目目录 javascriptMVC 文件夹-> 模型/ Controller jsfiles api 文件夹 -> Zend 项目
我在 javascriptMVC 目录中创建了一个符号链接(symbolic link) api 指向 api/public
,我在对 PHP 服务器的 AJAX 调用中使用它.像 /api/user/auth
。相同的结构适用于旧的 Ubuntu 机器。
我觉得跟Apache的配置有关系;或者我可能必须设置任何别名?
最佳答案
谢谢大家,
我发现了问题。
在 apache 2.4.6 和 ubuntu 13.10 中我们需要更新 apache2.conf 改变
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
与
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
然后像这样创建你的虚拟主机文件,
<VirtualHost zfapp.com:80>
ServerName zfapp.com
DocumentRoot /var/www/zfapp/index
<Directory /var/www/zfapp/index>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
我从以下地方找到了解决方案: https://askubuntu.com/questions/423514/how-to-enable-mod-rewrite-for-virtual-host
顺便说一句,谢谢@Bilal,@jmleroux
关于php - 使用 Apache 虚拟主机在 ubuntu 13.10 上设置 zf2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21904932/