如何在Ubuntu 12.04 +虚拟主机+ mod_rewrite中安装ZF2 [英] How to install ZF2 in ubuntu 12.04 + virtual host + mod_rewrite
问题描述
我从 https://github.com/ZF安装了zf2骨架应用程序和一些模块,例如zfcuser和zfcBase -Commons/ZfcUser ,最后我在本地运行192.168.3.12/myproject/user,成功安装了它,但是我发现404 not found错误,我总是必须运行192.168.3.12/myproject/public/user,所以我发现很多人都在谈论制作虚拟主机,但我无法让我在虚拟主机上运行zf2安装
I installed zf2 skeleton application and some modules like zfcuser and zfcBase from https://github.com/ZF-Commons/ZfcUser and I installed it successfully in my local at the end I ran 192.168.3.12/myproject/user but I found 404 not found error always I have to run 192.168.3.12/myproject/public/user so I found there are lot of people are telling about to make virtual host I am not able to get my to run zf2 installation with virtual host
请让我知道正确的解决方案.我只想在虚拟主机的帮助下安装zf2.
Please let me know the proper solution. I just want to install zf2 with the help of virtual host.
推荐答案
很抱歉,我已经在一段时间前完成了,您可以通过以下方式来完成.
Sorry for late Answer I have done it some time ago you can do it with below way.
-
在/var/www目录中安装zf2,假定项目名称为site1.
Install zf2 in the /var/www directory assume project name is site1.
使用此命令启用mod_rewrite sudo a2enmod rewrite
Enable mod_rewrite with this command sudo a2enmod rewrite
配置虚拟主机和主机文件(请记住,这是必须执行的操作)
Configure virtual host and host file (remember this is compulsory must do it)
a .复制在/etc/apache2/sites-available/default中找到的当前默认设置,并将其命名为新站点.
a.Copy the current default setting found in /etc/apache2/sites-available/default and name it the same as your new site.
eg. cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site1
b..使用您喜欢的文本编辑器为每个站点编辑新的配置文件.在ServerAdmin行下方添加ServerName server1行,并同时更改DocumentRoot和Directory以指向您的新站点. 它应该是这样的:
b. Edit the new config files for each site using your preferred text editor. Add the line ServerName server1 right below the ServerAdmin line and change both DocumentRoot and Directory to point to your new sites. This is what it should look like :
/etc/apache2/sites-available/site1
c.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.zf2.com
DocumentRoot /var/www/site1/public
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/site1/public/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
d..运行此命令
sudo a2ensite site1
e.重新启动apache
e. restart apache
sudo /etc/init.d/apache2 reload
4.编辑主机文件,为其设置新的主机名和IP地址.
4.Edit host file set your new host name and IP address to it.
运行
sudo nano /etc/hosts
设置此数据
YOUR_IP_ADDRESS test.zf2.com
那是它!!!!希望这对您有帮助...
Thatz it!!!! hope this helps...
这篇关于如何在Ubuntu 12.04 +虚拟主机+ mod_rewrite中安装ZF2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!