All Apache virtual hosts shows default website page - apache

Here is a problem. I am running on CentOS 7 with Httpd(Apache) installed. After installation default DocumentRoot is /var/www/html. And my site domain is avect.ru. Then I've created a virtual host with the link cp.avect.ru. But when I enter it, it shows content NOT from specified DocumentRoot /var/www/cp, but /var/www/html.
Idk why this happens. NameServers are not working, because they are deprecated. Help please!
Here is part of httpd.conf:
<VirtualHost *:80>
ServerName www.cp.avect.ru
ServerAlias *.avect.ru
DocumentRoot /var/www/cp/
ErrorLog /var/log/cp-error.log
CustomLog /var/log/cp-requests.log combined
</VirtualHost>

Related

CentOS Apache VirtualHost default

I have set up some virtal host to distinguish between my subdomains (/etc/httpd/conf.d/*.conf).
This was working on my old server (Debian 7). But now if I browse the root page I get the first defined VirtualHost displayed.
Also if I am browsing an undefined subdomain I get the first VirtualHost config displayed.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName sub1.example.com
ServerAlias sub1.example.com
DocumentRoot /home/sub/sub_sub1/www
ServerAdmin Admin
CustomLog /home/sub/sub_sub1/logs/access.log combined
ErrorLog /home/sub/sub_sub1/logs/error.log
LogLevel warn
<Directory /home/sub/sub_sub1/www>
Require all granted
</Directory>
</VirtualHost>
The first defined VirtualHost will serve all the requests that don't get handled by the other ones. You can create a default VirtualHost that handles those requests. To make sure this VirtualHost is the first one, you should name its config-file something like "000-default.conf".
This might also help you: VirtualHost Examples

Editted Virtual Host ServerName in httpd.conf but it seems it did not take effect

So I have 4 Virtual Host. I made the 3 Virtual Hosts 2 days ago and it
all works fine. When I made another Virtual Host the next day, it
won't load up the newly created Virtual Host. So I tried renaming the Server Name of my 1st Virtual
Host which is running.
I changed the ServerName and Alias of www.test1.biboglobal.com to hogehoge.com with still the directory of test1. Saved the file and restarted apache. But when I tried to browse hogehoge.com,it won't load the contents.
I tried browsing the test1.biboglobal.com and it still worked. But
that Server Name does not exist anymore because I changed it to
hogehoge.com.
I've searched all about httpd.conf not taking changes but found no answer. I hope someone can help me.
I also tried removing all Virtual Hosts and restarted Apache. But still, it was able to browse test1, test2, test3.biboglobal.com. Although it only displayed the Apache Test Page, not the index.html inside their respective directory.
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
ServerAdmin webmaster#hogehoge.com //**This was supposed to be test1.biboglobal.com**
DocumentRoot /var/www/test2.biboglobal.com/public_html
ServerName www.hogehoge.com //**This was supposed to be test1.biboglobal.com**
ServerAlias hogehoge.com //**This was supposed to be test1.biboglobal.com**
ErrorLog /var/www/test1.biboglobal.com/error.log
# CustomLog /var/www/test1.biboglobal.com/requests.log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#test2.biboglobal.com
DocumentRoot /var/www/test2.biboglobal.com/public_html
ServerName www.test2.biboglobal.com
ServerAlias test2.biboglobal.com
ErrorLog /var/www/test2.biboglobal.com/error.log
# CustomLog /var/www/test2.biboglobal.com/requests.log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#test3.biboglobal.com
DocumentRoot /var/www/test3.biboglobal.com/public_html
ServerName www.test3.biboglobal.com
ServerAlias test3.biboglobal.com
ErrorLog /var/www/test3.biboglobal.com/error.log
# CustomLog /var/www/test3.biboglobal.com/requests.log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#test4.biboglobal.com
DocumentRoot /var/www/test4.biboglobal.com/public_html
ServerName www.test4.biboglobal.com
ServerAlias test4.biboglobal.com
ErrorLog /var/www/test4.biboglobal.com/error.log
CustomLog /var/www/test4.biboglobal.com/requests.log common
</VirtualHost>

how to change localhost/mysite/web to localhost in bitnami

how to change localhost/mysite/web to localhost in bitnami
DocumentRoot "C:/Bitnami/wampstack-5.4.25-0/apache2/htdocs/srd-last/web"
i have configured httpd.conf but it is not working?
i want to call localhost.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "C:/Bitnami/wampstack-5.4.25-0/apache2/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/Bitnami/wampstack-5.4.25-0/apache2/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
I had a similar problem.
If you look towards the bottom of your http.conf file it has
Include "/path-to-bitnami-lamp/apache2/conf/bitnami/bitnami.conf
This overwrites your configuration of virtual hosts so edit virtual hosts there instead.
This problem only exists in newer version and is mentioned in the documentation -
"In recent versions of BitNami apps the bitnami.conf file defines which configuration for each application should be loaded by the Apache server. This file is located in /installdir/apache2/conf/bitnami/bitnami.conf."
DocumentRoot is the path from the root of your Web server (as in the entire file system) to your Web root (The location of where the files that make up your Web page are located)
ServerName is the name you would type into your Web browser.
For a custom ServerName to work you on local host you also need to edit your hosts file.
I think on Windows it's located at C:\windows\system32\drivers\etc\hosts

Apache Virtual Host IP Works but not ServerName

I am using Wamp.
My Apache Server is running on port 90.
I Tried adding a virtual host by doing the following steps:
1)Removed the comment from the line Include conf/extra/httpd-vhosts.conf line in my Apache httpd.conf file.
2)I Added the following code to my C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin admin#laravel.dev
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
ErrorLog "logs/laravel.dev.log"
CustomLog "logs/dummy-laravel.dev.log" common
</VirtualHost>
<VirtualHost *:90>
DocumentRoot "c:/wamp/www/"
</VirtualHost>
3)I made changes to my windows hosts file.This is the content of my hosts file
127.0.0.1:90 localhost
127.0.0.1:90 laravel.dev
127.0.0.1:90 www.laravel.dev
Now localhost:90 will Redirect to my C:/wamp/www and 127.0.0.1:90 will Redirect to my C:/wamp/www/laravel/public but both laravel.dev and www.laravel.dev are not working
I get the message Oops! Google Chrome could not find laravel.dev in my chrome.
Any help would be appreciated :)

VIrtualHost: Different hosts point to the same location

I am trying to set virtual hosts for two Zend Framework applications. I started by changing the system32 hosts file.
It contains the following lines now:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 quickstart
After that, I proceeded with changing the httpd-vhosts.conf file. Its current content:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\ProjManer\public"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\quickstart\public"
ServerName quickstart
ServerAlias quickstart
ErrorLog "logs/quickstart-error.log"
CustomLog "logs/quickstart-access.log" combined
</VirtualHost>
If I don't add the virtual host with localhost first, I get a "Access forbidden 403 Error message".
The problem now is that both point to the same location, the localhost. How am I supposed to get the second virtual host working? I used the flushdns also.
You don't need the ServerAlias in them unless you want say quickstart2 to go to quickstart. In that case you will do ServerAlias quickstart2. You get access forbidden because your document root in your httpd.conf doesn't have an index.php or that virtualhost doesn't have an index.php and you have -Indexes set
Other than that the virtualhost and hosts file look fine. Try restarting your browser and restarting apache.