I have two projects. One is main project and another one is separate module project.I want to configure virtual host for both using same domain with sub-directory structure.
For Example : www.example.com pointing to one main project while www.example.com/submodule as another independent project.
My two virtual host
<VirtualHost *:80>
ServerAdmin it#example.com
DocumentRoot /var/www/mainproject/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ServerName dev-test.example.com
DirectoryIndex index.php
<Directory /var/www/mainproject/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Submodule virtual host:
<VirtualHost *:80>
ServerAdmin it#example.com
DocumentRoot /var/www/example/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ServerName dev-test.example.com
Alias /module /var/www/example/
DirectoryIndex index.php
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Anything wrong in this?
I merged into single My virtual host file .My code :
<VirtualHost *:80>
ServerAdmin it#example.com
DocumentRoot /var/www/example/docroot
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ServerName dev-test.example.com
DirectoryIndex index.php
<Directory /var/www/example/docroot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /module/ "/var/www/example2/"
<Directory "/var/www/example2/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Related
We have a VUE front end that is within the dist (var/www/dev/dist) folder. We successfully set up when users visit dev.domain.com that it hits the dist folder. The problem we are having is with our api, which is in an api subfolder (var/www/dev/api/public). What we are trying to accomplish is when the URL dev.domain.com/api is called it points to /var/www/dev/api/public and will also handle all requests appended to api (dev.domain.com/api/*).
<VirtualHost *:80>
ServerAdmin webmaster#localhost
Servername dev.domain.com
ServerAlias dev.domain.com
Alias /api /var/www/dev/api/public
<Directory /var/www/dev/api>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
DocumentRoot /var/www/dev/dist
<Directory "/var/www/dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/dev-domain.log
# Possible values include: debug, info, notice, warn, errot, crit
# alert, emerg.
LogLevel warn
Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined
</Virtualhost>
After some more researching and help from the above comment I ended up getting it to work with the following Virtual Hosts config.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
Servername dev.domain.com
DocumentRoot /var/www/dev/dist/
<Directory "/var/www/dev/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /api/ "/var/www/dev/api/public/"
<Directory "/var/www/dev/api/public/">
Options Indexes FollowSymLinks
</Directory>
ErrorLog ${APACHE_LOG_DIR}/dev-domain.log
# Possible values include: debug, info, notice, warn, errot, crit
# alert, emerg.
LogLevel warn
Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined
</Virtualhost>
I have the following as my default virtual host in /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The idea is that it would read the index.html from /var/customers/webs/speed, however, it's still reading the default index.html in /var/www
I have restarted apache and even the server itself, but it just don't seem to want to update.
You must edit /etc/apache2/sites-enabled/default to change default page
If you access http://localhost Apache will load the index.html from Document Root defined in httpd.conf.
If you would like to load Document Root of Virtual Host, try below -
<VirtualHost *:80>
ServerName virtualhost.com
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Go to your Host file and add a new entry 127.0.0.1 virtualhost.com
Apache should now understand which document root to load when you access http://localhost and http://virtualhost.com.
The above code would get you started and then you can add your customization accordingly .
Hope that help!
I'm trying to mask/hide a the URL of our VPS, in which we have installed a wordpress blog under a subdirectory (/var/www/vhosts/vps.url.com/httdocs/blog.
We have a domain pointing to this site (vps.url/blog), so writing the domain URL on the browser redirect us to the VPS, but showing the URL vps.url/blog.
I've tried to mask it with apache2 virtual hosts this way:
<VirtualHost *:7080>
ServerAdmin webmaster#localhost
ServerName domain.es
ServerAlias www.domain.es
DocumentRoot /var/www/vhosts/vps.url.com/httpdocs/domain/
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
This doesn't work as it still showing vps.url.com/domain when we want to show domain.es
Thanks before hand and excuse my bad english.
currently I'm trying to set a VHost but somehow it is not working.
I've disabled the vhosts in my machine and I have just one. The page does not load. If I access localhost I get 403 Forbidden
My vhost:
<VirtualHost *:80>
ServerAdmin admin#myvhost.test
ServerName myvhost.test
DocumentRoot /folder/to/app
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /folder/to/app>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and if I run
apache2ctl -S
I get
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
port 80 namevhost myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
Syntax OK
What am I missing here?
Thank you
On localhost I have a file filename.html and an .htaccess in the same folder.
I need to figure out why my .htaccess is not working:
redirect 301 /filename.html http://www.google.com
I am on linux, I have configured the server:
sudo nano /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo service apache2 restart
I found:
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]
my RewriteEngine is working.