Jump to content

Need Assistance with Setting Up Virtual Host for Development Server


Illustrator76
Go to solution Solved by gizmola,

Recommended Posts

I am about 95% finished with setting up a local development server for my website, but I keep running into one issue. I will give as many details as I can so that everyone knows exactly what my problem is. I am using Turnkey LAMP in a VM on my local home NAS/server, I have everything set up and running properly, and I can reach the admin console for my VM by going to: 192.168.1.400. I am able create folders for my websites inside of the LAMP VM and I can see my development site by navigating to 192.168.1.400/sitename.com.

 

The issue that I am running into is that I am using PHP includes on my dev site, but when I try to use the $_SERVER['DOCUMENT_ROOT'command I keep getting errors because the default directory for the VM/website is /var/www instead of /var/www/sitename.com where all of my files are. My problem is that I have used Webmin to set up a Virtual Host for my website with a default directory of /var/www/sitename.com, but I continue to get errors because my site is still looking for a default directory of /var/www. How do I make the "connection" between my development site and the Virtual Host with the correct default directory/document root?

 

What am I doing wrong here? I have posted the Directives for my created Virtual Host below.

 

Any help given would be great!

 

DocumentRoot /var/www/sitename.com

ServerName sitename.com
<Directory "/var/www/sitename.com">
allow from all
Options IncludesNOEXEC +Indexes
</Directory>
Link to comment
Share on other sites

  • Solution

It doesn't sound like your vhost is actually functional.  Vhosts need to either be pinned to an IP/port combination, or use the HTTP1.1 "Host" header field to determine which vhost the request should be routed to. 

 

You have a couple of options:

 

  • Use a port like 8001.  I personally prefer this because it's simple, clean and it doesn't require you to edit a local hosts file on your workstation(s).  It does however requre you to access your site with urls like:   192.168.1.400:8000
  • Make an entry in a hosts file, so that the "host" header will work

 

I provide some details on how to finesse the second option on your workstation at the top of this blog post:  http://www.gizmola.com/blog/blog/archives/blog/archives/97-Centos-Virtual-LAMP-server-Part-II.html

 

Hopefully you understand how to setup the vhost for these options, as you omited the vhost wrapping tags, which is important information if you want any help or advice with that.

Link to comment
Share on other sites

It doesn't sound like your vhost is actually functional.  Vhosts need to either be pinned to an IP/port combination, or use the HTTP1.1 "Host" header field to determine which vhost the request should be routed to. 

 

You have a couple of options:

 

  • Use a port like 8001.  I personally prefer this because it's simple, clean and it doesn't require you to edit a local hosts file on your workstation(s).  It does however requre you to access your site with urls like:   192.168.1.400:8000
  • Make an entry in a hosts file, so that the "host" header will work

 

I provide some details on how to finesse the second option on your workstation at the top of this blog post:  http://www.gizmola.com/blog/blog/archives/blog/archives/97-Centos-Virtual-LAMP-server-Part-II.html

 

Hopefully you understand how to setup the vhost for these options, as you omited the vhost wrapping tags, which is important information if you want any help or advice with that.

 

Thanks a ton for your help! The code that I posted was literally copied and pasted straight from the Edit Directives field, and there were no vhost tags around that code either. I am doing everything from Webmin, so it seems like it didn't add the code somehow. I did decide to go with your easier option of just using a port rather than editing a local host file, and I still couldn't get it to work. After doing a bit more digging around I found that there was a file located in: /etc/apache2/ports.conf that I had to go in and force Apache to listen for the port I was looking to use. After doing that, my site now appears as it should.

 

I really appreciate all of your help. It's rare that I ever get help from Admins on forums, so I definitely appreciate you taking the time to assist me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.