I cannot get my virtual host to work on Ubuntu, Apache2 - html

I moved a client's site to a new host. I have several domains/sub-domains/virtual-hosts already working. However, I cannot get this one to resolve. It keeps going to my dominate site. This is a very simple one page html page. No php, no special anything literally a one page html site.
I have it going though Cloudflare and directed to my ip with "A" & "CNAME" <-- that is it, again, nothing special.
I am on:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
With LAMP Configuration.
<VirtualHost *:80>
ServerAdmin admin#bluebonnet-realty.com
ServerName bluebonnet-realty.com
ServerAlias www.bluebonnet-realty.com
DocumentRoot /var/www/bluebonnet-realty.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/bluebonnet-realty.com/>
AllowOverride All
</Directory>
I purged all cache in Cloudflare however, it continues to resolve to the main site.
https://bluebonnet-realty.com goes to https://beardedrazorback.com
I added to the host file as follows
myip bluebonnet-realty.com
I have tried cleared history on PC, tried incognito and 4 different computers including my mobile device.
I can share logs, but I did not see anything jump out. But if you need to see them I can share.

Related

Virtualhost url not found

I installed LAMP on a new EC2 server and via the public IP address I can see the default Ubuntu webpage as loaded by my new apache server.
My problems began when I created a new directory, simply called test, alongside the original html directory. In test, I created index.html with the content "Test page responding and loading ...".
So, I then copy /etc/apache2/sites-available/000-default.conf to test.conf and set DocumentRoot /var/www/test.
I enabled the virtualhost by sudo a2ensite test.conf and restarted the server with sudo service apache2 reload.
In my browser, when I visit the IP address I get the ubuntu page as loaded by apache. I then append /test to the end of the IP address and I get a Not found: The requested URL /test was not found on this server. error.
I disabled the 000-default.conf virtualhost, just out of curiosity, and restarted the server. My output from test/index.html loads in a browser using just the IP address - which I did not expect.
ServerAdmin webmaster#localhost
DocumentRoot /var/www/test
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
I'm trying to simply serve test/index.html when I visit .../test in my browser.
If you don't want Apache to select the default virtual host (the first one for a given host+port) you'll need to use ServerName or ServerAlias in your added virtual host to make sure it matches the hostname/address you're using in the browser.
apachectl -S will summarize your vhosts.

Apache2: Index.html Loads on IP but not on Domain Name (Ubuntu)

I made an AWS EC2 Instance and get an Elastic IP.
The Elastic IP was used to set a Domain Name (Bought from GoDaddy) to the AWS EC2 Instance.
The EC2 Instance is running an Apache2 server.
According to the manual, I'm supposed to replace index.html in /var/www/html/ with the index.html of my own, which I did.
When I use the Elastic IP, the index.html page that I set is displayed.
However when I use the Domain Name, for some reason it gives me the default apache2 page, even though that file no longer exists since it was overwritten. I can access the index.html with DomainName.in/index.html.
Simply put :
- DomainName.in gives apache2 default index.html which shouldn't exist anymore
- DomainName.in/index.html gives the page that I want to show up
- ElasticIP and ElasticIP/index.html both give the page I want to show up
How can I make it so that just typing the Domain Name in the browser will take me to the index.html page that I want it to go to ?
You need to set DirectoryIndex in your virtualhost configuration which is located here: /etc/apache2/apache2.conf
If that is not where your config file is located, you can find it by running: /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
<virtualhost *:80>
ServerName domain.com
ServerAlias www.domain.com
# Index file and Document Root (where the public files are located)
DirectoryIndex home.html index.html
DocumentRoot /var/www
</virtualhost>
Ok so it turns out everything is fine, but the changes take time to propagate through the DNS for some reason.
The changes register after about half an hour.

Redirect HTML "/" to subfolder of WWW directory, the VirtualHost DocumentRoot

Sorry for asking this question again. Even though this has been asked and discussed quite a bit I cannot seem to find the right solution for a local dev environment using VirtualHost. I am using XAMPP Portable for Windows for dev work but assume this is the same for any other local server with regards to the .htaccess file.
DocumentRoot of VirtualHost is D:\dev\www\ for example.
ServerName is devwork.webdev for example.
HOSTS entry is 127.0.0.1 devwork.webdev.
VirtualHost file does have a default DocumentRoot being DocumentRoot "D:/xampp/htdocs". It works just fine.
The projects are each in a folder under D:\dev\www\ for example D:\dev\www\project01\ or D:\dev\www\project02\ and so on and show nicely in the browser when going to devwork.webdev with Options Indexes FollowSymLinks enabled. Apache is not showing any error and the access log file is also OK, things are working.
Now in my HTML when I use Project 01 a click on the link does link me to D:\dev\www\ showing all the projects I have in that folder.
Instead I would like to be linked to the root of the project, being D:\dev\www\project01\ or rather http://devwork.webdev/project01/.
How can I get that to work?
I am looking for a solution to this so that I can do dev work locally and without changing the HTML later FTP the data to the live host's root and it will work.
I have read and tried the following:
http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/
https://perishablepress.com/redirect-subdirectory-to-root-via-htaccess/ .htaccess How to redirect root URL to subdirectory files, rewrite to clean URL AND not affect subdomains?
http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/
https://stackoverflow.com/a/990405/1010918
How to redirect /directory/index.html and /directory/index.php to /directory/
Redirecting /directory/index.html to /directory/
with
How to remove .html from URL
and
http://forums.modx.com/thread/77211/endless-friendly-url-redirect-from-subdomain-folder-location
being closest to what I think I need but I must be doing something wrong since I always arrive at the DocumentRoot instead of the folder where the project is kept under the DocumentRoot.
Thank you for any help.
This seems closest:
Add VirtualHost definition for each project you want to access. (I'm
not sure how to do it on XAMPP for Windows).
For example, project01.devwork.webdev...
Set DocumentRoot for this VirtualHost to D:\dev\www\project01...
Add the hostname to your /etc/hosts/ file.
Open http://project01.devwork.webdev/ in your browser.
You should see the application in D:\dev\www\project01, while all URLs
will be based on "/".
What happens in the background:
When you open the URL http://project01.devwork.webdev/ in your browser, it will (as usual) translate it to IP address, but along with the request, it will also send Host header with the entered hostname:
GET / HTTP/1.1
Host: project01.devwork.webdev
Based on the Host field, Apache will decide which VirtualHost it needs to "pretend" to be, and serve files from the respective direcory.
However, if you need to have index of the projects, you will have to create it manually with full URLs.
An alternative with the given logic would be to simply add a VirtualHost for each project in D:dev\www\projectname by giving it its own domain instead of a subdomain on the host.
There is little difference there now when already editing httpd-vhosts.conf (using XAMP this file is in InstallDir and then in apache\conf\extra )but ideally it makes copying the local HTML to the live server without changing the HTML possible.
So this is something devs doing local work should keep in mind. I certainly will!! Thank you for your help and information.
<VirtualHost *:80>
DocumentRoot "D:/dev/www/newprojectname"
ServerName newdomainname.webdev
ServerAlias www.newdomainname.webdev
ErrorLog "D:/dev/www/log/dev-apache.error.log"
CustomLog "D:/dev/www/log/dev-apache.access.log" common
<Directory "D:/dev/www/newprojectname">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# more detailed local
# Require ip 192.168.188
# or the IP from your local network
</Directory>
</VirtualHost>

Two XAMPP WordPress Installations, pointing one to a different URL, both not working correctly

I am running Windows 7 with an XAMPP local server with an installation of WordPress. I know this one works correctly, I've used it many times. I have a MySQL database for it and it sits in htdocs/wordpress.
Now, I have a contract in which I'm working for someone on another WordPress theme and would like to have this as a separate database and install. So, I make another folder in htdocs, let's call it folder2. I then create another database in MySQL, import the db I was given, and create a user to match the wp-config.php file of this install. No problem, except that it points to "localhost/folder2" and I need it to point to "local.folder2.com" to match the contractor.
So I hunt around the web and stumble on VirtualHosts for XAMPP. I go to /System32/drivers/etc/hosts and add the domain.
127.0.0.1 localhost ## Already here for XAMPP purposes
127.0.0.1 local.folder2.com ## URL to point localhost/folder2 towards
I then go to /xampp/apache/conf/extra/httpd-vhosts.conf and add the necessary Virtual Host.
NameVirtualHost *:80
<VirtualHost *:80>
DirectoryRoot "C:/xampp/htdocs/folder2"
ServerName local.folder2.com
</VirtualHost>
I restart Apache and MySQL. Problem is, now local.folder2.com works, but "localhost/wordpress/" does not. Using that URL directs me to the theme and db of folder2, baffling me entirely. Any ideas? I realize I can just work on one and not the other, but if I ever have more than one client at a time, switching it all out isn't going to work.
In this case, localhost stopped working because when another vhost was declared, no longer did the inherent connection between http://localhost.com and the directory "/htdocs" work. The solution was to add a vhost for the original location and then add a second one for the new location. Simple as:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs/wordpress" # Where I had localhost pointing
</VirtualHost>
<VirtualHost *:80>
ServerName local.folder2.com
DocumentRoot "C:/xampp/htdocs/folder2"
<Directory "C:/xampp/htdocs/folder2">
Allow Override All
</Directory>
</VirtualHost>
Of course, you then must add them to your hosts file:
127.0.0.1 localhost
127.0.0.1 local.folder2.com
Restart Apache server, and you're good to go.

Apache Virtual Hosts with Multiple wordpress blogs

I'm running a VPS # slicehost with Linux 9.10. I've got a basic Lamp setup so far. I am hosting a few sites and adding a half dozen more, and I'd like almost all of them to have word press blogs available.
I tried installing wordpress into each directory following the normal instructions thinking that apache virtual hosts, since it finds each domain, would by extension follow each domain's /blog/ directory(I've tried leaving it the default of /wordpress/ with no results either). WordPress also installed and worked fine when I set it up in the var/www directory where I originally set it up before realizing it would only host one site per installation.
I need wordpress to respond with one of many blogs which is matched to the domain it serves via virtual hosts off the same LAMP setup.
If this is a problem of layout, and there is a better way to host multiple, completely separate wordpress blogs on a single server lamp setup with virtual hosts, I'm open to that as well.
Thank you in advance for any assistance.
I'll be keeping an eye on this to be able to answer any questions.
Oh, Also, I've made separate mysql Db's & usernames for each blog to use to keep them compartmentalized.
Simply set up different VirtualHost directories and put a wordpress installation in each.
Example of your virtualhosts
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#site1.com
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /srv/www/site1.com/public_html/
</VirtualHost>
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#site2.com
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot /srv/www/site2.com/public_html/
</VirtualHost>
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#site3.com
ServerName site3.com
ServerAlias www.site3.com
DocumentRoot /srv/www/site3.com/public_html/
</VirtualHost>
In each of the respective public_html directories put in a wordpress installation.
So for site1.com the wordpress can be put into /srv/www/site1.com/public_html/wp
For site2.com /srv/www/site2.com/public_html/wp
This will completely keep them seperate.
Thanks for the answer. I'm not sure, but I think this is what i've done with a different directory and it isn't finding the WP directory, even though apache finds the index.html for each site in the exampleX.com directories. So to be clear, It loads example1.com/index.html, but not example1.com/wordpress/ even though /wordpress/ is in the same directory as the index.html(each index.html is labeled internally to make sure i'm not pointing to the wrong one somehow).
I'm serving out of home/public_html/example1.com, home/public_html/example2.com, etc.
The virtual hosts file in sites-enabled points to /home/user/public_html/ as document root.
is the /srv/ directory the important part somehow? I thought I could set the pointers to essentially where ever was convenient?
Do I need to change something else other than 000-default in the sites-enabled directory to point?
--- as I started looking at this and thinking about it, I went and checked over my virtual hosts file. It turns out I wrote the document root all the way to /public, which is at the same level as /blog/ So I backed it up to example1.com with a forwarding href in index.html for example1.com pointed to example1.com/blog/index.html(which points to index.php for wp) which brings up the famous 5 minute installation. This works well since this site is only a blog. I'll just forward to each exampleX.com/public/ from an index.html in each exampleX.com for the rest and everything should be working fine.
Thank you very much for your help.