I can't seem to get started with Zend Framework 2 skeleton app

▼魔方 西西 提交于 2020-01-15 12:11:54

问题


I'm following through the getting started skeleton app tutorial on the Zend homepage:

http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html

I've got as far as being able to enter into the browser address bar "zf2-tutorial.localhost/" and my Zend welcome page should appear. It doesn't, the apache web folder (/var/www) directory appears instead. If I enter "http://zf2-tutorial.localhost/1234" to test whether the Zend 404 page appears, it doesn't. The default apache Not Found page appears.

I created my app by running in terminal:

php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application:dev-master /var/www/zf2-tutorial

.. this created all the files in the desired folder (/var/www/zf2-tutorial).

I then created the file /etc/apache2/sites-enabled/zf2-tutorial with the following:

<VirtualHost *:80>
         ServerName zf2-tutorial.localhost
         DocumentRoot /var/www/zf2-tutorial/public
         SetEnv APPLICATION_ENV "development"
         <Directory /var/www/zf2-tutorial/public>
                 DirectoryIndex index.php
                 AllowOverride All 
                 Order allow,deny
                 Allow from all
         </Directory>
</VirtualHost>

I updated my /etc/hosts file with:

127.0.0.1               zf2-tutorial.localhost localhost

I restarted apache

sudo service apache2 restart

.. and by this point I should be able to see the Zend welcome page so I can proceed with the rest of the tutorial but nothing.

By the way, I'm using Ubuntu 12.04, Apache/2.4.9 (Ubuntu) and PHP 5.5.14.

Is there anything obvious that I've missed out? I've got a feeling that it has something to do with the mod_rewrites but I'm a little confused which I should be updated and how. Any help would be much appreciated.


回答1:


Add the

<VirtualHost *:80>
    [... same code ....]
</VirtualHost>

in the /etc/apache2/sites-enabled/000-default file and restart the apache2


Update -

If it still doesn't work then try the below command and check -

sudo a2enmod rewrite

sudo service apache2 restart

This will enable the rewrite module if not already is.

After entering the URL in the browser, if the required page is not displayed then check the apache error log file located at /var/log/apache2/error.log

By this, you could get some idea as where its going wrong.




回答2:


Your problem was in config file name. In directory sites-enabled files should have .conf in the end of name.

  • Good: zf2-tutorial.conf
  • Bad: zf2-tutorial


来源:https://stackoverflow.com/questions/24592213/i-cant-seem-to-get-started-with-zend-framework-2-skeleton-app

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