httpd virtual hosts are not working - apache

So I recently am working on my new bootstrap website where I am using a VPS. Since I am only assigned one IP and I cannot get additional IP's, I was thinking of using Apache VirtualHosts combined with SRV records. While setting up the virtual hosts, I noticed that only virtual hosts on port 80 and 443 work. I am using ports 80, 8080, 8081, 8082 and 443. While connecting to 8080, I get a "This web page is not available" from google chrome. While connecting to 8081 and 8082, I get a "Oops! Google Chrome could not connect to ...". For now, I am using the domain "entel.us" because I am still transferring starfire1337.com. Here is my httpd.conf file: http://pastebin.com/awvR55aE
Any suggestions?
I am running CentOS 6

All your VirtualHost servernames are set to: *.starfire1337.com but you say your using entel.us...?
Perhaps try adding:
ServerAlias *.entel.us where * is your subdomain, i.e. js.
Another issue is that you have only set a Directory for the /var/www/html directory, where all your virtualhosts goto other directories in /var/www/ so either add a <Directory> for each of your virtual hosts like:
<Directory "/var/www/js">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
or add change this:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
to this:
<Directory "/var/www">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Related

WampServer: 403 Forbidden

All of a sudden my local WampServer vhosts are not working.
I've added a new vhost to vhosts.conf and hosts.
When I load that vhost in a web browser, I receive 403 Forbidden.
In vhosts.conf, I have:
<VirtualHost *:80>
ServerName example.com.au
ServerAlias example.com.au
DocumentRoot "D:\Dropbox\WAMP\WWW\example.com.au"
<Directory "D:\Dropbox\WAMP\WWW\example.com.au">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>
In httpd.conf I have:
Listen 10.0.0.199:80 ::1
Listen [::0]:80
<Directory />
AllowOverride none
Require all denied
</Directory>
where 10.0.0.199 is my PC's IP.
WampServer is online.
WampServer 3.0.6
Apache 2.4.23
Help appreciated.
I changed
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride none
Require all granted
</Directory>
in httpd.conf, and that resolved the 403 error.
The default config in httpd.conf has all the Listen parameters you need
Listen 0.0.0.0:80
Listen [::0]:80
This says listen on port 80 of whatever this PC's ip address is for both IPV4 and IPV6 address ranges, and is all you need.
This section of httpd.conf should also be left as you found it. This sets up the basic denial of all rights to all folders on the drive where you installed WAMPServer(Apache) and should do exactly that. Change it back to this
<Directory />
AllowOverride none
Require all denied
</Directory>
This is for your security. It say nobody is allowed access to the root of this driver and therefore no access to anything below the root. Once this is set you are then supposed to open up access to ONLY what Apache actually need access to. That is what you do in your httpd-vhosts.conf file for only the folders that site requires access too.
If you are hacked, then a hacker can only access those folder given access and NOT YOUR WHOLE DRIVE.
Your Virtual Host definition in httpd-vhosts.conf shoudl look like this
<VirtualHost *:80>
ServerName example.com.au
ServerAlias www.example.com.au
DocumentRoot D:/Dropbox/WAMP/WWW/example.com.au
<Directory "D:/Dropbox/WAMP/WWW/example.com.au/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
## Dangerous unless you really mean to
## allow the universe into your server
## I would use one of the other options and comment this one out
Require all granted
# If access from this PC only then us
# i.e. you are a standalone developer
# uncomment this
#Require local
#If access from your local network is required
# i.e. you are working with other devs within your local network
# uncomment this
#Require ip 10.0.0
</Directory>
</VirtualHost>
Note the use of Unix forward slashes and the <Directory.... tag needs a trailing slash
Then check your HOSTS file it should be like this
127.0.0.1 localhost
::1 localhost
127.0.0.1 example.com.au
::1 example.com.au

Problems in setting up VirtualHost using WAMP server

I want to host multiple websites on my computer. I'm using Windows with WAMP server. I already have domains and know how to map them to ip.
I have already edited httpd.conf file to allow virtual hosts.
My httpd-vhosts file looks like this,
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp64/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/testcase"
ServerName test.mydomain.com
<Directory "C:/wamp64/www/testcase">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/test2"
ServerName test2.mydomain.com
<Directory "C:/wamp64/www/test2">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
The problem is that both my domains open only the first site in this VirtualHost tag.
Example: In this case, both my domains will open the WAMP server configuration page. If I were to move the "testcase" tag above the other, both my domains will open the "testcase" page.
Update:
My subdomains show corresponding pages successfully when I open them on the server. But when I open subdomains on another machine, they open the first entry in the VH.
Update 2: Okay, so this is just out of my understanding now. I thought may be WAMP is not my cup of tea. So I installed XAMPP and made changes to the VH configuration and still ended up with same problem. So I then got rid of XAMPP too and installed WAMPDeveloper Pro. What could go wrong when the software sets up all the configuration files for you, right? But to my surprise, I still have the same problem. The websites work fine when I open them (using actual domain name) on the server itself, but when I open them on machine outside network the first VH entry open for all the domains I open.
Can anyone please help me with this?
Thanks!
Using both Apache2.2 and Apache2.4 syntax gets Apache a litle confused.
So as I assume you are running Apache 2.4 change the VH defs to this
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/testcase"
ServerName test.mydomain.com
<Directory "C:/wamp64/www/testcase">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/test2"
ServerName test2.mydomain.com
<Directory "C:/wamp64/www/test2">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Why Apache opens the first site i.e. localhost in this case.
If Apache cannot make sense of a VH def, it ignores it and default to loading the first Virtual Host that was correctly defined in the httpd-vhosts.conf file.
Of course you will also need to amend your c:\windows\system32\driverrs\etc\hosts file to include these domain names
127.0.0.1 localhost
127.0.0.1 test.mydomain.com
127.0.0.1 test2.mydomain.com
::1 localhost
::1 test.mydomain.com
::1 test2.mydomain.com

How to add CName (alias) to amazon ec2 web server?

Following the instructions in How to change Public DNS in amazon ec2, I could change public DNS in amazon ec2 (ubuntu image).
What I need to do is to add CName (alias) so that wiki.XYZ.com points to /var/www/html/wiki.
I use godaddy for DNS Zone file, so I added the name wiki, and check ping wiki.XYZ.com works fine.
I also modified the /etc/apache2/apache2.conf, and restarted apache server with service apache2 restart.
<VirtualHost *>
DocumentRoot "/var/www/html/wiki"
ServerName wiki.XYZ.com
# Other directives here
<Directory "/var/www/html/wiki">
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
However, wiki.XYZ.com ends up in error (not page found) in my browser. What might be wrong?
You should point the Cname to a domain name listed in your A record.
Be sure to read #michael in the comments below.
The issue was with my browser (Safari) that searches wiki.XYZ.com instead of visiting the site. I had to specify http://wiki.XYZ.com. I don't have this issue with Chrome.
Also, the configuration should be modified as follows:
<VirtualHost *:80> <-- specify the port
DocumentRoot "/var/www/html/wiki"
ServerName wiki.XYZ.com
# Other directives here
<Directory "/var/www/html/wiki">
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Apache 2 Test Page

I dont know why I see this Apache test page when I've configured my virtual host to point to my project?
Server settings
<VirtualHost *:80>
ServerName malltomobiledev.com
DocumentRoot /home/dcms/public/html/dcms/app/web
<Directory "/home/dcms/public/html/dcms/app/web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Apache restarted fine, so it was access the folders fine.
My host file
Ip malltomobiledev.com
Any ideas guys?
If you're using apache 2.2, make sure you have NameVirtualHost *:80 set in your main apache config file, otherwise apache will use the default virtual host, which points to the test page.
You can check the configured virtual hosts using apachectl -S

Local sub-domains on httpd apache

I have on my machine wampp server installed that I use to run php applications.
There are many folder in the htdocs with inside my projects and I can see those in the browser at this url: localhost/folder-name/.
I'd like to see every project in a custom url like: dev.name-folder.com
With IIS is very easy to do that, can someone explain how do that with Apache, using wampp server?
Thanks.
You can change your C:\Windows\System32\drivers\etc\hosts file to map domain names like dev.name-folder.com to your local system. (Otherwise you'll have to use a DNS server).
To configure a vhost in apache create a file for each domain/project you'd like to serve:
<VirtualHost *:80>
ServerAdmin email#domain.tld
ServerName domain.tld
DocumentRoot /var/www/htdocs/domain.tld/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/htdocs/domain.tld/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
ServerName is the domain name you'd like to serve your files under. DocumentRoot must be set to the absolute path to your files (here taken from a linux system).