Apache2 virtual host not updating correctly - apache

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!

Related

Apache Virtual Host multiple routes

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>

ServerAlias in apache, ubuntu

I have a virtual host in ubuntu on apache, this is not my main config, i have another web page as my main, so i wanted to set this one up on the same IP using a virtual host.
urologyexpert.mx is my server name, and this works perfect, but i want to have several aliases to access this page
I put as server alias:
www.urologyexpert.mx (doesn't work)
urologoexpertomonterrey.mx (doesn't work)
www.urologoexpertomonterrey.mx (working)
The one's that does not work gets routed to my default webpage on this IP,
here's my apache config in /etc/apache2/sites-enabled
A records are set up for urologyexpert.mx and urologoexpertomonterrey.mx, both pointing at the same IP, and i have a CNAME for www for urologyexpert.mx
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName urologyexpert.mx
ServerAlias www.urologyexpert.mx, urologoexpertomonterrey.mx, www.urologoexpertomonterrey.mx
DocumentRoot /var/www/urologyexpert.mx
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/urologyexpert.mx>
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>
Can someone help me with this? i just can't figure out why one alias is working and two aren't
Ok, I actually know now what was the problem,
The multiple ServerAlias have to be separated by a space, and not a comma, thats why only the ServerName and the last Alias was working
ServerAlias www.urologyexpert.mx urologoexpertomonterrey.mx www.urologoexpertomonterrey.mx
I hope this helps someone

Virtual Host not recognized

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

apache2 not working for different ports

I want to be able to run apache on two ports having two different document roots one with var/www folder and another with some other folder.Below is my default file in sites available. But whenever I hit 127.0.0.1 the index in the first virtual host gets displayed.
I want to be able to access index in /home/somefolder/tmp if I hit 127.0.0.1:8080 url but instead i get "Browser could not connect to 127.0.0.1:8080". What am I missing?
<VirtualHost *:80>
ServerAdmin webmaster#localhost
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>
<VirtualHost *:8080>
ServerAdmin webmaster#localhost
DocumentRoot /home/somefolder/tmp
<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>
You need to make sure that Apache is setup to listen on port 8080, therefore you will need
Listen 8080
and
NameVirtualHost *:8080
set in your main configuration, which will vary from distro to distro.
You can check what ports Apache is listening on using the following command:
sudo netstat -ntlp | egrep 'apache|httpd'
Sounds like you'll see 80 in there but not 8080.
Try this,
Listen 80
Listen 8080
NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.1:8080
<VirtualHost 127.0.0.1:80>
#ServerName eightzero.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
#ServerName eightzeroeightzero.com
DocumentRoot /var/www-8080
</VirtualHost>
I hope this will help you. Try to do a prompt restart/reload of httpd/apache2 after making changes with apache conf file. :)

virtually hosted typo3 site returns a 503 after backend logout

I am trying to host multiple typo3 managed sites on my remote webserver but whenever I logout from a brand new install I get a 503 error and can't get past that. but I can re-install a typo3 site from the same link. but the default typo3 installed which can be referenced via <www.mydomain_name.com/typotest> works fine. below is my default site setup:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /srv/www/
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/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 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>
############### All other demo sites ################
<VirtualHost *:80>
DocumentRoot /srv/www/site1/
ServerName www.site1.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/WFS>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site1/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site1/access.log combined
</VirtualHost>
######## Site2 ########
<VirtualHost *:80>
DocumentRoot /srv/www/site2/
ServerName www.site2.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/Monassier>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site2/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site2/access.log combined
</VirtualHost>
######## site 3 ########
<VirtualHost *:80>
DocumentRoot /srv/www/site3/
ServerName www.site3.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/HandP>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site3/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site3/access.log combined
</VirtualHost>
I will also say that I tried copying the .htaccess from the working site to the virtually hosted site but got no results. At this point I am at a loss as to what could be causing this.
Server OS is Debian Lenny and apache 2.2.16.
I would like to add that I have checked the error logs (php ones included) and all I see are access errors
As you are not getting a Apache error log entry, I presume you have got the maintanence mode enabled.
Check your localconf.php for the entry:
$GLOBALS['TYPO3_CONF_VARS'][BE][adminOnly] = 1;
and change it to
$GLOBALS['TYPO3_CONF_VARS'][BE][adminOnly] = 0;
Slight misunderstanding of the framework caused this. It turns out that I had installed a blank package instead of the introduction package. So I was getting the 503 due to there not being any frontend pages created in the blank, and I was trying to access the backend via the front end address.