drupal and wordpress together on one server - apache

I have two domains:
example1.com - is a drupal site.
example2.com - is a wordpress multisite.
Both domains live on the same physical host. I am using Ubuntu 14.04 and Virtualhosts.
Everytime I enable example1.com when I navigate to example2.com (or any domain in my multisite) I get the drupal install page. I should be seeing example 2's index page. Can anyone help? Here are the vhost.conf files
example1 vhost.conf
<VirtualHost *:80>
ServerName example1.com
ServerAlias *.example1.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
example2.conf
<VirtualHost *:80>
ServerName example2.com
ServerAlias *.example2.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example2.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When I disable example1.conf everything with the wordpress multisite (example2.conf) works as expected...
When I try to specify a domain name on the virtualhost (like
I get an 500 error.
Can anybody point me in the right direction?

It looks like there was a two part problem here. I hadn't properly closed a tag
in my .htaccess file for site example2.
When I removed this, I would get the drupal install page for example1 and example2. What I wound up doing to resolve this issue was to move both virtualhosts into one .conf file in Ubuntu.... for whatever reason that seemed to resolve the issue.

Related

Apache2 VirtualHost SSL config issues

Debian 10 / Apache2 -
GOAL: redirect all web traffic to VPS server to SSL. I have 2 sites hosted: bjmurrey.com and nextcloud.bjmurrey.com. I have 1 IP address.
PROBLEM: I can't for the life of me find a way to make this work. I have tried 1000 suggestions posted here and elsewhere with no success. The closest I get is everything redirects to https://bjmurrey.com when typing in nextcloud.bjmurrey.com. I am also a novice at this so please be kind.
I have a default.conf that looks like this:
<VirtualHost *:80>
ServerName www.bjmurrey.com
ServerAlias bjmurrey.com
DocumentRoot /var/www/blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://bjmurrey.com/
</VirtualHost>
<VirtualHost *:80>
ServerName nextcloud.bjmurrey.com
DocumentRoot /var/www/nextcloud
ServerAlias nextcloud.bjmurrey.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://nextcloud.bjmurrey.com/
</VirtualHost>
I have a default-ssl.conf that looks like this:
<VirtualHost bjmurrey.com:443>
ServerName bjmurrey.com
ServerAlias www.bjmurrey.com
DocumentRoot /var/www/blog
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/bjmurrey.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/bjmurrey.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
<VirtualHost nextcloud.bjmurrey.com:443>
ServerName nextcloud.bjmurrey.com
DocumentRoot /var/www/nextcloud
ServerAlias nextcloud.bjmurrey.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/nextcloud.bjmurrey.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nextcloud.bjmurrey.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
bjmurrey.com is in var/www/blog and nextcloud.bjmurrey.com in the var/www/nextcloud directories.
I have my DNS records www and nextcloud both pointed to same IP. I only have 1 IP available. This is a very low traffic site.
I have done all kinds of things like just have the default virtual host redirect to only nextcloud and removed all mention of the www site and it still redirects to bjmurrey.com, or redirects with an SSL error saying that nextcloud can't be loaded because the ssl is for bjmurrey.com only. As you can see I have made certs with letsencrypt for both bjmurrey.com and nextcloud.bjmurrey.com.
I'm about to yank all my hair out in frustration, so I know I've tapped out all my knowledge here. Help!
I have retested with http and is working for me.
Both addresses mydomain.myhost.example.com and myhost.example.com resolve to the same IP.
This is my configuration file
ServerName example.com
<VirtualHost *:80>
ServerName mydomain.myhost.example.com
DocumentRoot /var/www/mydomain
</VirtualHost>
<VirtualHost *:80>
ServerName myhost.example.com
DocumentRoot /var/www/myhost
</VirtualHost>
Tested in Ubuntu 20.04.1, Apache 2.4

Domains crossed over on digital ocean

I have two domains. exampleone.com and exampletwo.com.
I followed this guide for adding multiple domains on the same server:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
They are both on the same server. Somehow, blog.exampleone.com was created (out of nowhere). and it points to exampletwo.com.
If I click on the site in google, it shows blog.exampleone.com as the domain, but shows the content for exampletwo.com
How is this happening?
I've looked into the vhost files and everything seems correct.
Here is a sample vhost file:
<VirtualHost *:80>
ServerAdmin dave#example.com
DocumentRoot /var/www/html/exampleone.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.lognano
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This should result in 2 separate sites on the same server. Instead, a blog subdomain was created on one site that points to the content on another site.
What should I do?
Thanks!
You neeed to specify the "ServerName" in your vhost file, something like :
<VirtualHost *:80>
ServerAdmin dave#example.com
ServerName blog.exampleone.com
DocumentRoot /var/www/html/exampleone.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.lognano
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
in fact, for each vhost file, you need to specify the ServerName to work properly with your subdomains!

running website with no http show different content

Im running 3 sites in one server the same IP in Ubuntu/Apache using vhost.
I bought an SSL certificate and installed it in one of my sites successfully. The problem is when I run the site with no https it shows content from my other site.
Ex.
www.aaaaa.com
www.bbbbb.com (SSL)
www.ccccc.com
when I run https://bbbbb.com there is no problem but
when I run http://bbbbb.com it shows the content of www.aaaaa.com
I know the ssl is working correctly coz I have tested it sslchecker.
This is the first time I installed SSL, I hope someone knows something about this problem.
ok just got the Answer from this link
https://www.namecheap.com/support/knowledgebase/article.aspx/9821/38/redirect-to-https-on-apache
You just need to Redirect HTTPS on Apache. Solution is I added vhost port 80 on my conf file in apache to redirect it to https when accessing the site with no https.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#example.com
ServerName example.com.ca
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/example.com/example.ca.crt
SSLCertificateKeyFile /etc/ssl/example.com/example.key
SSLCertificateChainFile /etc/ssl/example.com/example.ca.ca-bundle
</VirtualHost>

Apache VirtualHost not pointing to correct subdirectory

I am a newbie to apache and server setup. I am migrating several sites from GoDaddy to a DigitalOcean VPS droplet. I am moving my first site over (a Wordpress install) and am having some trouble with VirtualHost. Here is the configs:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/html/domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Heres the thing, I have a www alias set up in the domain name records, and www.domain.com points correctly to the site, but domain.com points to the root var/www/html, not the subdirectory where the site is. I've searched for far too long, but every tutorial and forum seems to provide the same code I currently have configured. What am I doing wrong? I want to make sure it all works correctly before I take the next step of installing an SSL, but I am spinning my wheels at the moment.
The correct way to set up a virtual host is:
<VirtualHost *:80>
ServerAdmin admin#domain.com
DocumentRoot /path/to/the/directory
DirectoryIndex index.html index.php
ServerName domain.com
ServerAlias www.domain.com
ErrorLog ${APACHE_LOG_DIR}/domain.com.error.log
CustomLog ${APACHE_LOG_DIR}/domain.com.access.log combined
<Directory /path/to/the/directory>
Options -Indexes
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

VirtualHost Configuration causing issues

I am quite new to VirtualHosts,
My use case is:
The domain mobc.in should be redirected to /var/www/html/mobc
And all other requests should be redirected to /var/www/html
The configuration that I am using it is
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/mobc
ServerName www.mobc.in
ServerAlias mobc.in *.mobc.in
ErrorLog logs/mobc.in-error_log
CustomLog logs/mobc.in-access_log common
</VirtualHost>
This is not serving the purpose and even mobc.in is being redirected to /var/www/html
Kindly help me.
Remove the fist virtualhost tags and contents. Just use the 2nd one and use the default documentroot in httpd.conf