Illustrator76 Posted April 13, 2015 Share Posted April 13, 2015 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 https://forums.phpfreaks.com/topic/295508-need-assistance-with-setting-up-virtual-host-for-development-server/ Share on other sites More sharing options...
gizmola Posted April 13, 2015 Share Posted April 13, 2015 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 https://forums.phpfreaks.com/topic/295508-need-assistance-with-setting-up-virtual-host-for-development-server/#findComment-1508935 Share on other sites More sharing options...
Illustrator76 Posted April 13, 2015 Author Share Posted April 13, 2015 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 https://forums.phpfreaks.com/topic/295508-need-assistance-with-setting-up-virtual-host-for-development-server/#findComment-1508974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.