Awan
Awan

Reputation: 18560

How to access my zend project in browser?

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]

Upvotes: 0

Views: 474

Answers (1)

markus
markus

Reputation: 40675

You're missing the <Directory> configuration in your vhost config.

Your config has to look like that:

<VirtualHost *:80>
    ServerName student.dev
    DocumentRoot /var/www/student/public/
    <Directory /var/www/student/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

The AllowOverride setting tells apache that .htaccess files in your public directory may override the general settings.

Upvotes: 1

Related Questions