OSX Mavericks Apache Added Virtualhost Loads Localhost instead - wordpress

Been working on a locahost VHost setup for a WordPress Roots development environment with Bedrock including Composer, Capistrano and WP CLI using Homebrew on my OSX Mavericks Mac Mini all morning. I am using Homebrew's PHP 5.5 and MySQL 5.6.19 and OSX's Apache. Thought I had sort of understood Apache VirtualHost inner workings, but I am missing something.
I added img.local to /etc/hosts
127.0.0.1 localhost img.local
255.255.255.255 broadcasthost
::1 localhost img.local
fe80::1%lo0 localhost img.local
and have this in /etc/apache2/extra/httpd-vhosts.conf:
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin jasper#img.local
DocumentRoot "/Users/jasperfrumau/webdesign/img/web"
ServerName img.local
ServerAlias www.img.local
ErrorLog "/private/var/log/apache2/img.local-error_log"
CustomLog "/private/var/log/apache2/img.local-access_log" common
<Directory "/Users/jasperfrumau/webdesign/img/web/">
Option FollowSymlinks
AllowOverride All
Order allow, deny
allow from all
</Directory>
</VirtualHost>
I restarted the server using apachectl -k restart as root after I checked the config using apachectl -S . It said I was all good:
apachectl -S
VirtualHost configuration:
Syntax OK
When I load img.local in my browser the root localhost is loaded. So either my img.local is still bypassed because of a faulty vhosts file or there is something else in /etc/apache2/httpd.conf I need to change. What am I missing or doing wrong here?

In the end I realised the /etc/apache2/httpd.conf was loading the vhosts from /private/etc/apache2/other/*.conf so I added one img.conf there and restarted the server. There were some errors in the file after all once it was read. This is the correct one:
<VirtualHost *:80>
ServerAdmin jasper#img.local
DocumentRoot "/Users/jasperfrumau/webdesign/img/web"
ServerName img.local
ServerAlias www.img.local
ErrorLog "/private/var/log/apache2/img.local-error_log"
CustomLog "/private/var/log/apache2/img.local-access_log" common
<Directory "/Users/jasperfrumau/webdesign/img/web/">
Options FollowSymlinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Related

XAMPP Wordpress Site is not accessible from production server

My Needs are
1. Configure Multiple Domain on XAMPP server on production (Woocommerce Site)
2. Configure and enable ssl
Steps i followed
Edited httpd-vshost as
NameVirtualHost *:80
ServerAdmin mail#firstsite.in
DocumentRoot "C:/xampp/htdocs/firstsite"
Allow from all
ServerName firstsite.in
ServerAlias www.firstsite.in
ServerAdmin mail#secondsite.in
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secindsite.in
ServerAlias www.secondsite.in
Allow from all
Edited httpd-ssl
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/firstsite"
ServerName firstsite.in:443
ServerAlias www.firstsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\mibstore\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\mibstore\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\mibstore\server.key"
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secondsite.in:443
ServerAlias www.secondsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\ricebazzar\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\ricebazzar\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\ricebazzar\server.key"
</VirtualHost>
I have obtained SSL certificate from sslforfree and stored them on relevant path
I also edited etc\hosts file
127.0.0.1 firstsite.in
127.0.0.1 secondsite.in
Issue
I can able to browse them from the server(windows) itself , but can't able to access them from outside. the relevant domain names are purchased and added a A record to point the IP.
Notes
Using Amazon AWS EC2 instance
Added Inbound Rules on 80 & 443, And also added firewall rules on 80 & 443
Would you tried in another PC to visit them since you changed your host file on your PC.
If they can be visited then you need remove the record of your host file.
If not, please try:
Does both the A record of WWW and Non-WWW have been pointed to IP.
If pointed, please tell me what error or message you see on browser when you load the websites.
If there're no error or message which means they are blank page, please try to check is there any htaccess file, do you enable the rewrite mod of xampp.

Virtual Host with MAMP

I installed Drupal 8 with MAMP. My MAMP preference number for Apache Port : 80 , Nginx Port: 80 and MySQL Port: 8889
In etc/hosts file, I add 127.0.0.1 mmcast.test
In httpd.conf file,
Listen 80
and uncomment the following line.
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
In httpd-vhosts.conf file,
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName mmcast.test
DocumentRoot "/Applications/MAMP/htdocs/mmcast"
</VirtualHost>
When I call the site, I type mmcast.test:8888 and also try with mmcast.test:80. However, nothing works! :(
Could someone help me please? I've been trying this problem and still cannot solve.
in httpd.conf file
ServerName localhost:8888
has to be changed to
ServerName localhost:80
For Drupal 8 you need different settings for creating virtual host.
Here is the snippet that needs to be added for virtual host:
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/site-name/web"
ServerName local.site-name.com
<Directory /Applications/MAMP/htdocs/site-name/web/>
Options Indexes FollowSymLinks
AllowOverride all
RewriteEngine On
RewriteBase /
</Directory>
</VirtualHost>
So I access my local site as
local.site-name.com:8888
I have used default port, which is 8888. So above snippet is according to it.
You can refer this link from Drupal.org as well.

WAMP second virtual host not working/re-directing to first

I got VH working fine.
Localhost and my first site (which is attached to a domain) work absolutely fine, no issues.
However I wanted to add a second site (3rd if you include localhost) to experiment with a new site. However after having added it, it simply seems to re-direct to the first site's domain. They are both wordpress installations (although the 3rd isnt installed yet as I cant access it) but I'm not sure if that's relevant.
Here's my two relevant files;
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/mysite"
ServerName mysite.local
<Directory "c:/wamp/www/mysite">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin info#mydomain.co.uk
DocumentRoot "c:/wamp/www/wordpress"
ServerName mydomain.co.uk
ServerAlias www.mydomain.co.uk
<Directory "c:/wamp/www/wordpress">
AllowOverride All
</Directory>
ErrorLog "logs/wordpress-error.log"
CustomLog "logs/wordpress-access.log" common
</VirtualHost>
As explained.. localhost works, mydomain.co.uk works (name changed for privacy reasons but it works!). mysite.local does not it just redirects to mydomain.co.uk ???? (I tried a bunch of names including mysite.localhost, etc etc-- nothing works! I don't care what the name is I just want to be able to access it, will be buying a domain for it soon).
Any help is appreciated. Thank-you!
Here's hosts file although it's pretty self explanatory;
127.0.0.1 localhost
127.0.0.1 mysite.locals
127.0.0.1 mydomain.co.uk
::1 localhost
::1 mysite.local
::1 mydomain.co.uk

Why does localhost work but my alias does not?

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?

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