httpd.conf file vhost settings - apache

I try to fix httpd.conf file vhost settings, however there is not much information on web to find on my case. When apaceh updated on my server, httpd.conf file settings are changing. Now my website gives /cgi-sys/defaultwebpage.cgi error. You can check with biletme.com. Setting are like this on this file: (Root of website is home/wwwbiletme/public_html)
##################################################
#
# Define default vhosts for shared IPs
#
##################################################
##################################################
<VirtualHost 95.179.142.199:80>
ServerName 95.179.142.199
ServerAlias www.biletme.com
DocumentRoot /var/www/html
ServerAdmin ************
<Directory "/var/www/html">
AllowOverride All
</Directory>
<IfModule suphp_module>
suPHP_UserGroup nobody nobody
</IfModule>
</VirtualHost>
##################################################
##################################################
#
# Define default vhosts for unbound IPs
#
##################################################
##################################################
<VirtualHost *>
ServerName www.biletme.com
DocumentRoot /var/www/html
ServerAdmin ***********
<Directory "/var/www/html">
AllowOverride All
</Directory>
<IfModule suphp_module>
suPHP_UserGroup nobody nobody
</IfModule>
</VirtualHost>
##################################################

Related

Centos OS https shows apache2 default page

I am setting up my project on centos os, i have installed my ssl certificates and updated my ssl.conf. My project is accessible using http://test.com but when i try to access https://test.com, i can see the site is secure, but it displays the default apache in page. This is despite the fact that i have specified the directory and document root in my 443 virtualhost. Is there a step or error i have, any advise or useful links will be appreciated.
My code looks like this :
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
DocumentRoot "/var/www/html/strategy"
ServerName test.com/
ServerAlias www.test.com
<Directory "/var/www/html/strategy">
RewriteEngine on
# if (HTTP_ACCESS.contains('text/html') && file_not_exists(REQUEST_FILENAME))
RewriteCond %{HTTP_ACCEPT} text/html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [last]
# Any ressources loaded by index.html should behave correctly (i.e: Return 404 if missing)
RewriteRule ^ - [last]
Options Indexes FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin info#stratex.com
ServerName www.test.com
DocumentRoot "/var/www/html/strategy"
<Directory "/var/www/html/strategy">
DirectoryIndex index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine On
SSLCertificateFile /home/mydir/certificates/public-cert.pem
SSLCertificateKeyFile /home/mydir/certificates/priv-key.pem
</VirtualHost>
Since i had a ssl.conf file, i removed the conf file for port 443 from the httpd.conf file and i updated the virtual host with port 443 in the ssl.conf file with these details and my app works well.
<VirtualHost *:443>
ServerAdmin info#stratex.com
ServerName www.test.com
DocumentRoot "/var/www/html/strategy"
<Directory "/var/www/html/strategy">
DirectoryIndex index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine On
SSLCertificateFile /home/mydir/certificates/public-cert.pem
SSLCertificateKeyFile /home/mydir/certificates/priv-key.pem
</VirtualHost>

Name and IP Virtual Host on Apache

I am trying to direct web traffic for our domain to a Vhost site and our internal web site to separate directory that is only accessible within our private network,i.e 192.168.x.x.
I have modified Vhost configuration on Apache to include a name-based Vhost for the external website and a IP Vhost for the Intranet. No far I have had no luck, Apache does not like it.
Here is my modified Vhost config file.
NameVirtualHost *:80
<Directory "/home/webs">
Options +FollowSymLinks +Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot /home/webs/foo
ServerName www.foo.com
ServerAlias foo.com
LogLevel warn
ErrorLog /home/webs/foo/error.log
CustomLog /home/webs/foo/logs/access.log combined
</VirtualHost>
NameVirtualHost 192.168.0.*:80
<Directory "/home/webs/OffCat">
Options +FollowSymLinks +Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost 192.168.0.*:80>
DocumentRoot /home/webs/OffCat
ServerName 192.168.0.15/OffCat
LogLevel warn
ErrorLog /home/webs/OffCat/logs/error.log
CustomLog /home/webs/OffCat/logs/access.log combined
</VirtualHost>
I would appreciate any help.
Thanks,
Tony Cripps

Named VirtualHost in apache overrides every other VirtualHosts

I have defined two VirtualHosts on Apache, and the problem is, one of them overrides the other one. i.e. when I try to reach the second address, the first one shows up.
Here is my first config:
ServerName www.example1.com
DocumentRoot /server/sites/example1
<VirtualHost *:80>
ServerAdmin admin#example1.com
DocumentRoot /server/sites/example1
ServerAlias example1.com
<Directory /server/sites/example1/>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And the second:
ServerName www.example2.tv
DocumentRoot /server/sites/tv/public/
<VirtualHost *:80>
ServerAdmin admin#example2.tv
DocumentRoot /server/sites/tv/public
<Directory /srver/sites/tv/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
When I load www.example2.tv, it still shows www.example1.com content.
example1 is written in PHP and example2 is Ruby on Rails.
You need to have the ServerName directive inside the VirtualHost configuration i.e.:
<VirtualHost *:80>
ServerName www.example2.tv
ServerAdmin admin#example2.tv
DocumentRoot /server/sites/tv/public
<Directory /server/sites/tv/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
You can examine your configured VirtualHosts using apachectl -S - this will print a list of all the configured VirtualHosts and their corresponding config files

localhost redirecting to path specified for sub domain

In cakephp, I want to redirect localhost to app2 and client1.localhost to app1.
Instead both are redirecting to app1.
my httpd-vhost is defined as:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "D:\wamp\www\cakephp\app2\webroot\
ServerName localhost
</VirtualHost>
<VirtualHost www.myhost>
DocumentRoot "D:\wamp\app1\webroot"
ServerName client1.localhost
ServerAlias client1.localhost
<Directory "D:\wamp\app1\webroot">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
At first glance there are a few weird things with your vhost config:
The first document root has no closing "
the virtualhost names should both be the same
your referring to the webroot, instead of the approot (there's also a .htacces in your approot)
I use CakePHP 2.x with wamp server with a configuration like this:
make sure the vhost file is uncommented in your apache configuration:
wamp/bin/apache/Apache[version]/conf/httpd.conf (or left click wamp->apache->httpd.conf)
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Try this in wamp/bin/apache/Apache[version]/conf/extra/httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
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>
ServerName client1.localhost
DocumentRoot "D:\wamp\app1"
<Directory "D:\wamp\app1">
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost *:80>
ServerName dev.localhost
DocumentRoot "D:\wamp\www\cakephp\app2"
<Directory "D:\wamp\www\cakephp\app2">
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
and put this in your hosts file (C:\windows\system32\drivers\etc)
127.0.0.1 localhost
127.0.0.1 dev.localhost
127.0.0.1 client1.localhost
Do a wamp restart all services.
App2 will be available on both localhost and dev.localhost

Add a sudomain for each folder in my userdir path with Apache

I activated the userdir mod with apache2 and configure my domain to get the content of the www folder in my home.
I create a Virtualhost for the main domain which works good.
But now i would like to automatically add a subdomain for each folder in my /home/user/www/
Here is the virtualhost i code, but it redirect all the subdomains to the /home/user/www/
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias *.mysite.com
DocumentRoot /home/user/www/
UseCanonicalName Off
VirtualDocumentRoot /home/user/www/%1
<Directory /home/user/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.mysite.log
LogLevel warn
CustomLog /var/log/apache2.mysite.log combined
</VirtualHost>`
Try changing:
VirtualDocumentRoot /home/user/www/%1
to:
VirtualDocumentRoot /home/user/www/%0
You can read more about this feature at mod_vhost_alias.