Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

I am very new to the concept of virtual hosting and have no clue about how to make it work. Could you please help me figure out how to work with it correctly?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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