How to install ZF2 in ubuntu 12.04 + virtual host + mod_rewrite [closed]

。_饼干妹妹 提交于 2019-12-11 17:34:26

问题


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

Please let me know the proper solution. I just want to install zf2 with the help of virtual host.


回答1:


Sorry for late Answer I have done it some time ago you can do it with below way.

  1. Install zf2 in the /var/www directory assume project name is site1.

  2. Enable mod_rewrite with this command sudo a2enmod rewrite

  3. Configure virtual host and host file (remember this is compulsory must do it)

    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. 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. run this command

    sudo a2ensite site1
    

    e. restart apache

     sudo /etc/init.d/apache2 reload
    

4.Edit host file set your new host name and IP address to it.

run

sudo nano /etc/hosts

set this data

YOUR_IP_ADDRESS    test.zf2.com

Thatz it!!!! hope this helps...




回答2:


Make sure within your Apache config that the root directory of your website points to the 'Your_Skeleton_App_Path/public'. The rewrite rules are set only for the public folder

The root folder of the skeleton directory does not contain any index.php file (thus the 404 error)

(I wish i could have made this answer only a comment, but i can't comment yet)



来源:https://stackoverflow.com/questions/13538543/how-to-install-zf2-in-ubuntu-12-04-virtual-host-mod-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!