0

I am trying to work with my Laravel installation by using a VirtualHost on my computer which is using apache2 web server under debian jessie 8.5.
To do this, I first created a virtual host file named default.conf in /etc/apache2/sites-available and put the below text in it:

<VirtualHost /var/www/html/:80>
    ServerName localhost
    ServerAlias localhost
    DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost /var/www/html/laravel40:8000>
    ServerName lara
    ServerAlias lara
    DocumentRoot /var/www/html/laravel40/
</VirtualHost>

Now, after restarting the apache2 service, I can view the localhost easily by typing it in the browser's address bar. But with typing lara in the address bar, the browser shows me (chrome in my case) the results of search about the word lara. Laravel needs port 8000 to be run but I want it to run on port 80 so that the return results of my gateway system could work correctly.

1

First: you need to make sure your DNS server would resolve lara to your webserver. Alternatively, editing your hosts file could do.

then, defining a virtualhost

<VirtualHost /var/www/html/laravel40:8000>

Should probably be replaced with

<VirtualHost 1.2.3.4:8000>
<VirtualHost fqdn:8000>
or <VirtualHost *:8000>

Also: just adding a virtualhost won't configure apache to listen on a new port. Look for /etc/apache2/ports.conf of your main apache configuration file, there should be some Listen 80 already present, make sure to add Listen 8000 somewhere in there.

Finally: if your browser starts searching when you type a short name that your DNS should resolve, you could try adding the protocol prefix (http:// or https://). If you need to connect to port 8000, then make sure to type it in as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.