• clockticks

    (@clockticks)


    So I’m root on my webserver using name-based virtual hosts, I’m not an expert but I know my way around various Linux distros.

    Using latest Centos/WP/PHP/MYSQL

    My site was all up and running solid but I wanted to move over some more sites I facked some stuff up. In the dashboard I changed the directory (edits the mysql db) from http://www.mywebsite.com/wordpress to http://www.mywebsite.com

    Lost communication here with the site, as expected but I thought all I had to do was move the folder and edit httpd.conf to reflect the move.

    To try to fix it I moved /var/www/html/mywebsite to /var/www/ then changed document root to /var/www/mywebsite

    This all didn’t work and looks like the DB isn’t communicating correctly as the CSS is all screwed up.

    So that’s that, I’m restoring from a backup and should be back to a working site in a second. Thought I would give that history though as I’m obviously doing something wrong.

    I want to have multiple sites using name-based virtualhosts under /var/www/websiteA /var/www/websiteB etc.. (or under /var/www/html/websiteA I don’t know the difference)

    What kind of symlink or documentroot settings do I need to do here?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter clockticks

    (@clockticks)

    Also, pretty important question as well. I’m going to host other WP sites on this server so in the WP Dashboard settings the following two options:

    WordPress address (URL): http://www.mywebsite.com/mywebsite
    Site address (URL): http://www.mywebsite.com/mywebsite

    Do I need to change the WP address URL to reflect the folder for each individual site, such as http://www.mywebsite.com/mywebsiteB etc..

    I know I asked a lot of questions but I’m really struggling here, I would really appreciate the help.

    Thread Starter clockticks

    (@clockticks)

    Ok I fixed it, this is how I setup my httpd.conf virtual hosts for anyone else that has this issue in the future.

    #<VirtualHost *:80>
    # ServerName http://www.mywebsite.com
    # ServerAlias mywebsite.com *.mywebsite.com
    # DocumentRoot /var/www/html/mywebsite.com
    #</VirtualHost>

    My wordpress install sits in a folder under /var/www/html/mywebsite.com

    I made this symlink:
    ln -n /var/www/html/mywebsite.com/mywebsite index.html

    The only problem right now is when I go to mywebsite.com it shows up as mywebsite.com/index.html

    How can I get rid of that?

    Clayton James

    (@claytonjames)

    The only problem right now is when I go to mywebsite.com it shows up as mywebsite.com/index.html

    index.html is not required.

    Here is a rudimentary name based virtual hosts configuration example for httpd.conf. The first *default* host will result in 403’s for anyone using your numeric ip to reach the server. The other two will return the sites located in the “site1” and “site2” directories located inside of /var/www/html respectively. Add sites and directives as required.

    (ignore the obvious breaks to prevent creating links in the post)

    <VirtualHost *:80>
    ServerName default.only
    <Location />
    Order allow,deny
    Deny from all
    </Location>
    ErrorLog logs/default-error_log
    CustomLog logs/default-access_log combined
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin webmaster@ site1.com
    DocumentRoot /var/www/html/site1
    ServerName w ww.site1.com
    ServerAlias site1.com
    ErrorLog logs/site1-error_log
    CustomLog logs/site1-access_log combined
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin webmaster@ site2.com
    DocumentRoot /var/www/html/site2
    ServerName w ww.site2.com
    ServerAlias site2.com
    ErrorLog logs/site2-error_log
    CustomLog logs/site2-access_log combined
    </VirtualHost>

    Thread Starter clockticks

    (@clockticks)

    Thanks ClaytonJames,

    I’m now getting a blank white page on site2.com and 404 when I try to get to http://site2.com/wp-admin/install.php

    At least it’s not redirecting anymore to site1.com

    I have the following symlinks for each site under /var/www/html/site1 and /site2

    ln -s /var/www/html/site1.com/site1 index.html
    ln -s /var/www/html/site2.com/site2 index.html

    Here are my configs, also not the very first occurance in httpd.conf is still set to the following (if that matters):
    DocumentRoot “/var/www/html”

    Here is the virtualhost parts:

    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerName default.only
    <Location />
    Order allow,deny
    Deny from all
    </Location>
    ErrorLog logs/default-error_log
    CustomLog logs/default-access_log combined
    </VirtualHost>

    <VirtualHost *:80>
    ServerName http://www.site1.com
    ServerAlias site1.com
    DocumentRoot /var/www/html/site1.com
    </VirtualHost>

    <VirtualHost *:80>
    ServerName http://www.site2.com
    ServerAlias site2.com
    DocumentRoot /var/www/html/site2.com
    </VirtualHost>

    Thread Starter clockticks

    (@clockticks)

    Please note this website added the “http://&#8221; above, it just has ww w in my config.

    I’m kind of out of ideas at this point, if someone could really take a look I would be in your debt forever and you will probably have positive karma today resulting in your finding a 50 million dollar winning lottery ticket.

    Thread Starter clockticks

    (@clockticks)

    Fixed it, turns out this was related to the earthquake in Japan.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘DocumentRoot and Virtual Host Issues’ is closed to new replies.