I have multiple wordpress installs that I need to access with multiple domains and I need a way to accomplish this. I have devised a folder structure that I think will be the best way, but I need help with the .htaccess. For simplicity sake, let's say I have two wordpress sites. Fully separate.
www.b.campscoreboard.net is in the folder
/a/b
www.c.campscoreboard.net is in the folder
/a/c
www.campscoreboard.net is pointing to
/a
The a folder contains nothing except an .htaccess file to help me route the domains properly. That's where I need help. I would like to point www.campscoreboard.net to that root /a folder. In my perfect world, the following things would work.
The "b" site would work just fine using www.b.campscoreboard.net or campscoreboard.net/b
The "c" site would work just fine using www.c.campscoreboard.net or www.campscoreboard.net/c
I need "b" and "c" to have their built in permalinks functions to still work. In other words, if I type www.c.campscoreboard.net/forums, I need that to work. I don't want to have to go all the way back to www..campscoreboard.net/c/forums for my links to work (which is what it's currently doing).
What needs to be in that .htaccess file in the /afolder to properly route these domains?
Update 1: Rather than breaking real sites trying this stuff, I just made 2 wordpress installs in the directory tree above. Sorry about the www's. That's what worked for testing purposes.
Here's what happened:
After installing the sites, they worked as expected. I could load the two wordpress sites with either b.campscoreboard.net or campscoreboard.net/b.
However, I got an internal server error on all campscoreboard.net, b.campscoreboard.net, and c.campscoreboard.net after adding the suggested .htaccess of...
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName b.campscoreboard.net
ServerAlias www.b.campscoreboard.net
DocumentRoot /a/b
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName c.campscoreboard.net
ServerAlias www.c.campscoreboard.net
DocumentRoot /a/c
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What do you think I'm doing wrong?
Follow these steps:
a) Create Apache virtualhost:
Read this tutorial.
Example configuration:
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName mudministry.com
ServerAlias www.mudministry.com
DocumentRoot /mudmin/home
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName userspice.com
ServerAlias www.userspice.com
DocumentRoot /mudmin/userspice
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
b) Add wordpress files in /mudmin/home and /mudmin/userspice. Make sure you access these sites first time using the servernames specified above. mudministry.com and userspice.com
This will make sure the your wordpress urls are generated correctly.
c) Use Reverse proxy for mudministry.org
Read this tutorial:
Example configuration:
<VirtualHost 10.10.1.91:80>
ServerName mudministry.org
ServerAdmin webmaster#localhost
## You dont have to keep this /mudministry
DocumentRoot /var/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyAddHeaders Off
ProxyPass /home http://mudministry.com
ProxyPassReverse /home http://mudministry.com
ProxyPass /userspice http://userspice.com
ProxyPassReverse /userspice http://userspice.com
</VirtualHost>
Related
I am using the Wordpress REST API to provide a back end to my React JS front end. Right now both are running on separate Apache servers on AWS and all works well.
Is it possible to run both on the same server? So that my React front end is making requests to Wordpress on the same server?
Sure, if you want to use Apache to handle distributing your frontend and handling the WP backend, read up on Virtual Hosts: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
The gist of it is that you'll have a VH for your frontend
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com <-- see here
DocumentRoot /var/www/example.com/client
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and a VH for your backend
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias api.example.com <-- and here
DocumentRoot /var/www/example.com/server
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Issue: I cannot make the webserver host multiple websites.
Solutions I have tried:
I made two different Vhost.conf for the different websites(named differently according the website name but with the .conf extension. I then targeted different document roots linked to the websites within these config files. – Failed, displayed “connection refused”
I then went to the second website directory I created and change the file permissions to 755 (and 777 just incase) to check if that was conflicting and creating the issue, this also failed and made the same error.
Also all files have “chown -R root:root dir/ “ on.
I then went on to open port 8080 in iptables and changed the targeted port in the vhost of the second website to 8080, this also failed with the same error.
I tried finding the second website using “ip:8080, ip/secondwebsitedirectory, ip:80/secondwebsitedirectory” none of these worked. I followed each step of multiple tutorials online and none of these worked.
When I tested just making a directory and displaying the <?php phpinfo; ?> in index.php within the directory, then targeting that with the document root of the first virtual host block, this worked but did not display the second block’s website (I used the domain to link the alias to this and forwarded the domain to the servers ip).
My current vhost.conf file looks like this **NOTE: I removed ip’s and domains on clients request. They do work and have been tested so that isn’t an issue. Anything with “testsite” was originally the clients domain. **
I have made it two separate VirtualHost blocks previously and had the same result as I am having currently, I have had <VirtualHost *:80> on both blocks too.
<VirtualHost *>
ServerAdmin webmaster#testsite.org
ServerName ea
ServerAlias *server ip was here*
DocumentRoot /var/www/html/ea
ErrorLog /var/www/html/ea/logs/error.log
CustomLog /var/www/html/ea/logs/access.log combined
ServerAdmin webmaster#testsite.org
ServerName testsite
ServerAlias www.testsite.co.uk
DocumentRoot /var/www/html/testsite/public_html
ErrorLog /var/www/html/testsite/logs/error.log
CustomLog /var/www/html/testsite/logs/access.log combined
</VirtualHost>
The end result I want to come to is to be able to host multiple sites on my cloud server, these website are using Wordpress as that is the development platform I have been instructed to use and the server is running Centos 6.8 with all php and apache2 installed and working on one website.
As to a conclusion to this, I am stumped and need your help.
You need one statment for each site you want
<VirtualHost ea.mydomain.com:80>
ServerAdmin webmaster#testsite.org
ServerName ea.mydomain.com
ServerAlias ea
DocumentRoot /var/www/html/ea
<Directory "/var/www/html/ea/">
Options FollowSymLinks Indexes
AllowOverride None
# Use require all granted for apache 2.4
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/html/ea/logs/error.log
CustomLog /var/www/html/ea/logs/access.log combined
</VirtualHost>
<VirtualHost testsite.mydomain:80>
ServerAdmin webmaster#testsite.org
ServerName testsite.mydomain
ServerAlias testsite.mydomain testsite
DocumentRoot /var/www/html/testsite/public_html
<Directory "/var/www/html/testsite/public_html">
Options FollowSymLinks Indexes
AllowOverride None
# Use require all granted for apache 2.4
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/html/testsite/logs/error.log
CustomLog /var/www/html/testsite/logs/access.log combined
</VirtualHost>
I'm setting up 2 wordpress sites. The scenario is that there are two Wordpress installations, in the folder var/www/domain/us and var/www/domain/eu. The domain.com/us should be the default option when you access the site from domain.com
Users access the site through: domain.com/us or domain.com/eu
Right now the setup for virtual host is: (I don't have a real domain name attached, so its only IP address so far)
<VirtualHost *:80>
ServerName [IP-address]
ServerAlias [IP-address]
DocumentRoot /var/www/domain/us
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName [IP-address]/us
DocumentRoot /var/www/domain/us
ServerAlias [IP-address]
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName [IP-address]/eu
DocumentRoot /var/www/domain/eu
ServerAlias [IP-address]
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
I can access the IP address with the primary virtual host, but the last two IP/us and IP/eu is giving Page not found.
What am I doing wrong?
ServerName interprets the path as part of the hostname. Server name can contain the request scheme, hostname and port, but not the path. Therefore only the first virtual host is valid.
Since you are on Apache 2.4, you can use conditional directives to solve the problem. In the first virtual host add the following, and then remove the other two:
<VirtualHost *:80>
ServerName [IP-address]
ServerAlias [IP-address]
<If "%{REQUEST_URI} =~ m#^/eu.*$#">
DocumentRoot /var/www/domain/eu
</If>
<Else>
DocumentRoot /var/www/domain/us
</Else>
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
</VirtualHost>
I currently have this apache2 site configuration:
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName engine.com
ServerAlias www.engine.com
DocumentRoot /var/www/engine.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If I type engine.com I just get a blank page.
My directory setup is like this
/var/www/engine.com/public_html/wp-content...
Localhost works fine and wordpress installation is triggered, but as I say engine.com just brings me a blank page.
Don't you need to add
engine.com 127.0.0.1
to your hosts file?
I have two installs of wordpress on a single Amazon EC2 server. One of them is just a regular wordpress install, the other being a wordpress network install, with WP Domain Mapping installed.
So let's say I have four domain names: site.example.com, multisite.example.com, multisite1.com and multisite2.com
All of the domain names are pointing to the same IP address. Multisite1.com and multisite2.com are domain mapped to blogs under the multisite.example.com wordpress network
On my server httpd.conf is setup as follows:
<VirtualHost *:80>
ServerAdmin root#localhost
DocumentRoot /persistent/html/site1
ServerName site.example.com
ErrorLog logs/site_error_log
CustomLog logs/site_access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin root#localhost
DocumentRoot /persistent/html/multisite
ServerName multisite.example.com
ErrorLog logs/multisite_error_log
CustomLog logs/multisite_access_log combined
</VirtualHost>
Right now, all of the domains seem to go to the right place - until I start getting to the wp-admin panel.
site.example.com/wp-admin and multisite.example.com/wp-admin appear to work fine.
multisite1.com/wp-admin and multisite2.com/wp-admin both seem to redirect to site.example.com/wp-admin instead of multisite.example.com/wp-admin.
I can't figure out why. I have tried putting all of the domain names in the virtual host as ServerAlias but it doesn't seem to have helped. I've also put in a wildcard ServerAlias under multisite.example.com as well, but no luck.
Any ideas? It is a bizarre install I know, but for the time being for other reasons, I have to get it to work this way. I will eventually separate the two.
Create a new sites-available entry for each of your sub-domain or virtual host for each sub-domain pointing to the same web root and reload the apache. After that all will work fine.
For e.g.
<VirtualHost *:80>
ServerAdmin root#localhost
DocumentRoot /persistent/html/multisite
ServerName multisite1.com
ErrorLog logs/multisite_error_log
CustomLog logs/multisite_access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin root#localhost
DocumentRoot /persistent/html/multisite
ServerName multisite2.com
ErrorLog logs/multisite_error_log
CustomLog logs/multisite_access_log combined
</VirtualHost>