WordPress.org

Ready to get started?Download WordPress

Forums

WP and Virtual Hosts for other web sites (9 posts)

  1. radelcas
    Member
    Posted 7 years ago #

    New to Apache and WP - basically I used XAMPP and then installed WP in a sub folder called blog in the htdocs - works fine over network changing the ip for url of blog - but I also wanted to run other sites not related to blogs. So I created a folder for each site and configured Apache for Virtual Host, making the WP a virtual host also. The other site work fine, but I cannot get WP to work at all until I comment out all the Virtual Host Directives, otherwise it wants to go to the url/xampp folder. I think it is looking for the database - what am I doing wrong? I am sure I should be able to do this.

  2. MichaelH
    Member
    Posted 7 years ago #

  3. radelcas
    Member
    Posted 7 years ago #

    Well I read all the links above. I followed the directions of the second link, plus read some of the Apache documentation. I really want to start blogging so if I can't get all my web sites on this machine and have them co-exist with wordpress, I guess I will - but I hate giving up - so here is what I have, and what is happening:

    Basically, the Virtual Server stuff works OK, it is when I add the WordPress to the virtual section that it breaks (WordPress that is) - If I go to the options on the admin site for WordPress, and change the urls to the same as in the httpd.conf - it breaks (I tried techbytes.myweb.com/blog and without the /blog part). If I leave the Virtual Server stuff completely commented out for all Virtual Servers, then the url part works - techbytes.myweb.com ok, from the local or from another machine on network that has the right host entry for techbytes.myweb.com. At one point, I got the actual Blog site to come up, but then the admin site would not come up - I think there is some re-direction going on with the php, but being php stupid, I cannot easily understand it. Also, I just wanted to start bloggin and putting web sites up, then go back and study the php more closely. Yes, I clear the caches also when I make changes by restarting the whole XAMPP thing!

    Thanks for the help :=)

    Ubunto Linux
    XAMPP for Linux 1.5.5a
    PHP 5.2.0
    PHPMyAdmin 2.9.1
    MySQL 5.0.27
    Wordpress 2.0.5
    Apache 2

    Apache htdocs is in /opt/lampp/htdocs
    wordpress is in /opt/lampp/htdocs/blog

    Here is my httppd.conf file's Virtual Server part:

    NameVirtualhost *:80

    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot htdocs
    </VirtualHost>

    <VirtualHost *:80>
    ServerName wuz-up.com
    ServerAlias http://www.myweb.com
    DocumentRoot htdocs/myweb
    </VirtualHost>

    <VirtualHost *:80>
    ServerName myblog.com
    ServerAlias techbytes.myweb.com
    DocumentRoot htdocs/blog
    </VirtualHost>

    <VirtualHost *:80>
    ServerName test.com
    ServerAlias http://www.test.com
    DocumentRoot htdocs/test
    </VirtualHost>

    My Local Host File:
    127.0.0.1 localhost
    127.0.0.1 techbytes.myweb.com
    192.168.2.6 http://www.myweb.com
    192.168.2.6 techbytes.myweb.com
    192.168.2.6 http://www.test.com

  4. scaturan
    Member
    Posted 7 years ago #

    why are you not specifying the full, absolute path for DocumentRoot? why not use something like this?

    NameVirtualHost your-local-ip-address:80
    Listen your-local-ip-address:80

    <VirtualHost your-local-ip-address:80>
    ServerName yourdomain.tld
    ServerAlias *.yourdomain.tld somedomain.tld
    DocumentRoot /absolute/path/to/htdocs/
    </VirtualHost>

    also, how is your DNS setup? and do you have port forwarding enabled correctly from your router/firewall to your machine?

  5. radelcas
    Member
    Posted 7 years ago #

    Ok, thanks - here is what I did and what is currently happening:

    NameVirtualHost my-local-ip-address:80
    Listen my-local-ip-address:80

    <VirtualHost my-local-ip-address:80>
    ServerName mydomain.com
    ServerAlias myblog.mydomain.com
    DocumentRoot /absolute/path/to/htdocs/
    </VirtualHost>

    <VirtualHost my-local-ip-address:80>
    ServerName mydomain.com
    ServerAlias http://www.mydomain.com
    DocumentRoot htdocs/www
    </VirtualHost>

    <VirtualHost my-local-ip-address:80>
    ServerName test.com
    ServerAlias http://www.test.com
    DocumentRoot htdocs/test
    </VirtualHost>

    And, local host has all domains pointing to the local ip, and works accross network ok. Not yet on internet just using host files no internal dns for this.

    What is happing now though, is that:
    myblog.mydomain.com Works and brings up blog which is in the blog folder in htdocs; and all the other domains work, but myblog.mydomain.com/test and the myblog.mydomain.com/www/ bring up the test domain and www web sites also. I don't want that - so is the absolute path the answer for that? The reason I didn't use it initially is because I thought I was following the httpd.conf file instructions saying that the root was set, and I didn'thave to specifiy the whole path, and since it worked for all other sites except WordPress, I thought it is a WordPress thing.

    So each url without the /foldername at the end should bring that site only, and the /foldername should not go to anything unless it is for that site url.

    Is that understandable or am I being dense?

    Thanks again.

  6. scaturan
    Member
    Posted 7 years ago #

    whichever appears first in httpd.conf will be shown but because you have 2 <virtualhost> containers having the same "ServerName mydomain.com" - one is pointing to an absolute path, and the other, relative to the global DocumentRoot - so that alone will introduce a lot of issues.

    in your example, the first container defines mydomain.com with DocumentRoot /absolute/path/to/htdocs/ and a ServerAlias called myblog.mydomain.com - so both http://myblog.mydomain.com/ and http://mydomain.com/ will fetch whatever is present in DocumentRoot /absolute/path/to/htdocs/

    the next container below is in conflict. my advice would be to define a unique container for mydomain.com with it's own DocumentRoot and create another container with myblog.mydomain.com also with it's own DocumentRoot. afaik, you can only specify mydomain.com once but almost unlimited in ServerAliases within that same container. you have 2 :)

  7. radelcas
    Member
    Posted 7 years ago #

    You are absolutely right. I actually created a separate folder for the blog out of the htdocs folder. For mydomain.com virtual server, I only specified it once, and on the next VirtualHost I only did the ServerAlias without the ServerName and I pointed each one to its own container. The part that was really screwing me up, was in the wordpress options part - it has two urls one for the wordpress and one for the blog - if you use virtual server and do not have that right, I could not get back to it to change it so I had to start over each time. I don't know why I struggled with that so much since all the other virtual server stuff I got working. Do you know where in the config files you can change that with editor if you mess up? Anyway, I think I got this working. Not on the internet with it yet, but I am learning .... Thanks so much for your help.

  8. scaturan
    Member
    Posted 7 years ago #

    i mainly use pico on my FreeBSD box (should be available on most UNIX/Linux distros) to make changes to httpd.conf - if you're using Windows, trythe Crimson Editor - highly recommended.

  9. efbatey
    Member
    Posted 6 years ago #

    Running WP 231 on my site (TrixBox / QMailTOaster ), all have name.my.domain and only run SSL. I am seeking example of Virtual Host configs that will leave alone all my non-WP /var/www/html 443 services and allow me to rename my blogs from https://site/wpblog1 ... https://site/wpblog5 to https://wpblog1.site/ ... https://wpblog5.site/

Topic Closed

This topic has been closed to new replies.

About this Topic