I cannot get Vhost to host multiple wordpress websites on centos 6.8 - wordpress

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>

Related

Virtualhost problems. Have two vhost files but results are unexpected 2nd site does not load properly

I have 1 ubuntu 14.04 server from DO and two independant WordPress installations I'm trying to run off the same server
Have two apache vhost config files:
000-default.conf and 001-default.conf
Now when navigating to domain1.com everything works flawlessly. The entire website is working as expected. But there is a problem with going to domain2.com it will automatically redirect to domain1.com. Basically the problem is I can't get to the WordPress installation screen on domain2.com
Here is the conf file under sites available for domain1.com (000-default.conf):
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
config file for domain2.com (001-default.conf):
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/htmlposts
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/htmlposts>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Additional information:
In /var/www/html I have the WordPress files for domain1.com and everything works.
In /var/www/htmlposts/ I have extracted the WordPress files for domain2.com
it looks like this: http://prntscr.com/d4h9gu
I have created an index.html file in /var/ww/htmlposts which is the directory for domain2.com and when I navigate to domain2.com/index.html the file displays as expected but when I navigate to domain2.com/wp-admin/install.php which should start the wp installation process for instance #2 "domain2.com" it shows an already installed error which looks like this: http://prntscr.com/d4hhav
There are two databases on the server. One is for domain1.com and the other database is an empty one that I created for domain2.com. Both are correctly pointed in their respective wp-config.php files.
Can you compare the config.php of the 2 sites. Make sure that the database names in both the config.php files are different.

How to configure apache to serve directory for custom domain

Currently, I have configured a domain I bought through GoDaddy to point to the elastic ip address of my personal ec2 instance. I'm having issues finding the correct solution to configure my httpd.conf such that my custom domain, example.com points to a specific subdirectory var/www/Example. Further, I want to be able to still access my other projects and sites by simply typing in the elastic ip and subdirectory.
I have tried the using a virtual host with the following configuration..
<VirtualHost *:80>
ServerAdmin webmaster#example.com
DocumentRoot "/var/www/html/Example/wordpress"
ServerName fitnessfifteen.com
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" common
</VirtualHost>
When I do this, I can access the correct content by going to www.example.com however, I'm unable to access my other files and projects via 11.11.111.111/OtherProjectDirectory (I get that default internal server error page). I'm completely new to this sort of stuff so many this isn't possible and I have a fundamental misunderstanding.
Add another virtual host to http.conf as below and restart apache.
<VirtualHost *:80>
ServerAdmin webmaster#example.com
DocumentRoot "/var/www/html/Example/wordpress/OtherProjectDirectory"
ServerName 11.11.111.111
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" common
</VirtualHost>

Error 403 when trying to access localhost

Good morning all.
I run a small in office dev (xampp) server for the build of static and WordPress websites on my Ubuntu machine.
I use vhosts for which two are workingabsolutly fine. However, I have another which for some reason keeps failing when I try to load the site.
My Xampp install is a typical /opt/lampp install, nothing unique or special.
My vhosts File
##Summerschool Development Version (which works fine)
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/summerschooldev"
ServerName summerschoolforteensuk.com
<Directory "/opt/lampp/htdocs/summerschooldev/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
##Summerschool old website (which works fine)
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/summerschool"
ServerName summerschoolold.com
<Directory "/opt/lampp/htdocs/summerschool/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
##scp old website throws error 403 You don't have permission to access / on this server..
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/scp"
ServerName scpold.com
<Directory "/opt/lampp/htdocs/scp/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Now my hosts file
127.0.0.1 summerschoolforteensuk.com
127.0.0.1 summerschoolold.com
127.0.0.1 scpold.com
From what I can see, everything seems to be working fine. Im relativly new to working like this but poor internet speed at my office means I have to. Im guessing that there is not error here as the other two sites work fine.
Is there something Im missing if not where would I look next.
Thanks
I seem to have solved this by installing wordpress locally and importing my database and wp-content folder into the install and using the full domain for the server name and host.
Dont think this has solved my issue but its working now.

Can't get to subsites. Wildcard-subdomains probably misconfigured in Apache

I'm building a portal for the organization I'm working at.
The portal is a Wordpress site using Wampserver 2.5, intalled on a Win server 2008 R2.
It's working fine and accesible from other machines over the intranet, thanks to the helpful and patient RiggsFolly.
But now, I have changed it into a network of sites so that I can build sub-portals for the different departments in my organization.
During that change Wordpress gave this warning message: Warning! Wildcard DNS may not be configured correctly!
Wordpress has a page explaining how to configure wildcard subdomains on Apache - http://codex.wordpress.org/Configuring_Wildcard_Subdomains.
I tried following it but the explanation lacks details and I'm probably doing something wrong.
On the machine where the servers and site are installed, when I write http://hipo (hipo is the current site name) in the browser's address bar, I get to the site fine.
But when I write http://depa.hipo (depa is a subsite I created successfully), the address changes into http://www.depa.hipo/ and the browser says it didn't find a server at that address.
I have probably set the ServerAlias line wrong in httpd-vhosts.conf, and also I didn't add the line *.example.com A 192.0.43.10, or in my case *.hipo A <rightIP>, cause I wasn't sure where to add it in the file.
This is my httpd-vhosts.conf file. Your help is appreciated!
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName subsites.hipo
ServerAlias *.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This definition does not have a ServerAlias so try adding one like this:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
ServerAlias www.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

www being served on iis, non-www being served on apache?

Here is the problem, if you visit the site directorybest.net you will see the correct website (which is defined in apache). But if you go to the www version of the site a catch all site for and from IIS is displayed. I have no idea what this is causing this.
I have another site that already runs fine on apache from which I copied the info for DNS and vhost settings. I also have set the DNS up so that both sites point to the same ip address. Does anyone know why the www version of the site does not show the right website?
Here is the vhost information for both the working and non working site.
NameVirtualHost *
#non-working site
<VirtualHost *>
ServerAdmin admin#email.com
ServerName www.directorybest.net
ServerAlias directorybest.net *.directorybest.net
DocumentRoot "D:\WWW\DirectoryBest\2"
DirectoryIndex index.php
<Directory D:\WWW\DirectoryBest\2>
AllowOverride All
</Directory>
# Logfiles
ErrorLog D:\WWW\DirectoryBest\2\logs\error.log
CustomLog D:\WWW\DirectoryBest\2\logs\access.log combined
</VirtualHost>
#working site
<VirtualHost *>
ServerAdmin admin#email.com
ServerName www.directorybest.info
ServerAlias directorybest.info *.directorybest.info
DocumentRoot "D:\WWW\DirectoryBest\1"
DirectoryIndex index.php
<Directory D:\WWW\DirectoryBest\1>
AllowOverride All
</Directory>
# Logfiles
ErrorLog D:\WWW\DirectoryBest\1\logs\error.log
CustomLog D:\WWW\DirectoryBest\1\logs\access.log combined
</VirtualHost>
Ok so I was just informed that the company has had DNS problems before. And upon further checking the local DNS had not been updated and was still resolving to the old ip address.

Resources