Apache don't load all virtualhost - apache

i have a problem with apache and the virutalhosts on ubuntu server.
The software installed on my machine is:
Ubuntu 14.04.3 LTS
Apache 2.4.7
The virtualhost are configured in /etc/apache2/sites-avaiable/ directory and i have 4 files:
000-default.conf
default-ssl.conf
I maked these files:
site-one.example.com.conf
site-two.example.com.conf
The only difference is the name of subdomain an domain, so, the configuration of both files is:
site-one.example.com.conf:
<VirtualHost *:9292>
ServerName site-one.example.com:9292
ServerAlias www.site-one.example.com:9292
ServerAdmin webmaster#localhost
DocumentRoot /var/www/prod/
alias /a /var/www/prod/a
alias /a-test /var/www/test/a
alias /f /var/www/prod/f
alias /p /var/www/prod/p
alias /p-test /var/www/test/p
alias /t /var/www/prod/t
alias /w /var/www/prod/www/w
alias /t-test /var/www/test/t/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
site-two.example.com.conf
<VirtualHost *:9292>
ServerName site-two.example.com:9292
ServerAlias www.site-two.example.com:9292
ServerAdmin webmaster#localhost
DocumentRoot /var/www/prod/
alias /s /var/www/prod/www
alias /s-test /var/www/test/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The problem is when i try to load the url "site-one.example.com/a" the server not found the files but the url by "site-two.example.com/s" works good, i've been trying restarting Apache(sudo service apache2 restart or reload or stop/start) but when i do that site-one.example.com works fine and the other stop working and said "The requested URL /a was not found on this server."
¿How can i find some log file about the virutalhost?

I found the problem, the server fist read the configuration of 000-default.conf file, so i commented all the lines, i restarted apache and works fine.
however, i would like to know, why sometimes apache takes one *.conf file or other???

Related

Apache2 not outputting errors on webpage

Im on Linux (debian based), and my apache2 localhost doesn't give any warning / error messages. The apache error.log located at var/log/apache2/error.log gives errors / warnings but it will never output something on my website.
I made a file called /etc/apache2/sites-available/html.conf with the neccesary info:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
ServerAlias www.localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
however, If i change line 6 to the location of my error.log file (var/log/apache2/error.log), It does nothing.
EDIT:
I solved the problem
I had to change this line: log_errors = Off
to: log_errors = On
In the php.ini file (Line 503)

Issues with Apache and Virtual Hosts

I'm, trying to run both MediaWiki and Wordpress on an Apache server. I've got the MediaWiki site set up with a couple of sub-domain Virtual Hosts, so everything is fine there. This is installed at /var/www/html/mediawiki.
I'm trying to install Wordpress on it's own directory, /var/www/wordpress.
In my config file for Wordpress' virtual host, I've got:
<VirtualHost *:80>
ServerName domain.com
ServerAdmin admin#domain.com
DocumentRoot /var/www/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/wordpress/> AllowOverride All</Directory>
Obviously domain.com is not the domain.
Whenever I visit domain.com, however, it seems to be loading the MediaWiki install from /var/www/html/mediawiki, which is obviously not what I want.
Anyone got any ideas what I'm doing wrong here?
Run apachectl to see all the servers/vhosts running on your server both port 80 and 443
apachectl -S
Also I believe that:
<Directory /var/www/wordpress/> AllowOverride All</Directory>
should be inside of your virtual host block

Apache2 ServerName and ServerAlias not working

On a nearly fresh Ubuntu 20.04 LTS computer, I would like to set up a virtual host on my local machine. So I created a index.html under /var/www/test/ with the following content:
you have entered a test page
I have set up a test.conf file under /etc/apache2/sites-available/
with the following content:
<VirtualHost *:80>
ServerAdmin webmaster#zhihu.com
DocumentRoot /var/www/test/
ServerName zhihu.com
ServerAlias www.zhihu.com
<Directory /var/www/test/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The localhost is working:
/etc/hosts config is probably working as indicated by ping
ping zhihu.com
PING zhihu.com (127.0.1.1) 56(84) bytes of data.
64 bytes from xxx (127.0.1.1): icmp_seq=1 ttl=64 time=0.045 ms
but browser cannot bring me to the domain which should now be hosted in /var/www/test/.
I have also a2ensite test.conf and a2dissite 000-default.conf and service apache2 reload
So I think the only possible place for error to occur is ServerName and ServerAlias. Why are they not working?
Could you please enable VirtualHost using a2ensite and access site in incognito mode.
Ensure that the ssl certificate for the site includes both example.com and www.example.com
and ServerAlias is set to www.example.com

Creating Virtual Hosts on ubuntu mint apache

I am working Linux Mint 17.3 and trying to create virtual hosts on Apache 2.4. I have followed the following procedure, but still can't browse the site:
Create two new virtual hosts
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf
modify each host
sudo vim /etc/apache2/sites-available/site1.com.conf
ServerName site1.com
ServerAlias www.site1.com
ServerAdmin admin#site1.com
DocumentRoot /var/www/site1.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
3.Enable the New Virtual Host Files
sudo a2ensite site1.com
// Disable original html host
sudo a2dissite 000-default.conf
sudo service apache2 reload
Add host info
sudo vim /etc/hosts
127.0.0.1:88 site1.com
127.0.0.1:89 site2.com
I have checked out everything online, that I could. Today is my second day. Thanks in advance for your help.
In your second step, you should declare that host as a VirtualHost in the conf file:
<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
ServerAdmin admin#site1.com
DocumentRoot /var/www/site1.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Setup vhost ubuntu

I am trying to setup a vhost in ubuntu, my file is like
/var/www/vhost/domain1.com/app
/var/www/vhost/domain1.com/public
/var/www/vhost/domain2.com/app
/var/www/vhost/domain2.com/public
the vhost in /etc/apache2/site-avalable/domain1.com.conf is :
<virtualhost *:80>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
ServerAdmin webmaster#domain1.com
ServerName domain1.com
ServerAlias *.domain1.com
DirectoryIndex index.php
DocumentRoot /var/www/vhosts/domain1.com/public
LogLevel warn
ErrorLog /var/www/vhosts/domain1.com/log/error.log
CustomLog /var/www/vhosts/domain1.com/log/access.log combined
</virtualhost>
problem
the vhost folder and all the files after that (the children) are accessible in the web browser. I know I have to put some sort of htaccess but i don't know how and where I have to put it.
If you use apache 2.4 and you develop on a local machine:
Create a new configuration file for your website:
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain1.com.conf
Edit the file like so:
<VirtualHost *:80>
ServerName domain1.com
ServerAlias *.domain1.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/vhost/domain1.com/public
ErrorLog /var/www/vhosts/domain1.com/log/error.log
CustomLog /var/www/vhosts/domain1.com/log/access.log combined
</VirtualHost>
Enable the website
$ sudo a2ensite domain1.com
Restart apache
$ sudo service apache2 restart
Add the following line to your /etc/hosts file
127.0.1.1 domain1.com
Now it should work, go to http://domain1.com and check it out.