New Ubuntu server with Virtual Host show directory instead of website - apache

I'm setting up a new Ubuntu 16.04 server with Apache. I followed this guide to do my setup.
Now when I try to access the site it shows me an empty directory. If I try to access a specific file (index.html) the server doesn't find it. Even trying to see the default website (by accessing my public IP) I get an empty directory.
Here's my .conf file:
ServerAdmin admin#website.com
ServerName website.com
ServerAlias www.website.com
DocumentRoot /var/www/website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
(for the purpose of this public question I changed the name of the site for website.com)
All file's and folder's rights are set to my username as owner and www-data as group. Apache's error log shows nothing wrong and access log is empty.
I banged my head for hours on this issue without any progress so any help is welcome!
Thanks
P.S.: The server is Ubuntu Server 16.04 LTS 64b running on a VirtualBox VM.

Obiviously you have missed out something. Please check that you have
/var/www/example.com/public_html/index.html
with correct spellings.
Also make sure that the config has both index.html and index.php in DirectoryIndex, check this link for more info
If all is correct create a .htaccess file in /var/www/example.com/public_html/
nano /var/www/example.com/public_html/.htaccess file
and then add the followings in it.
DirectoryIndex index.htm index.html index.php

Related

Request to apache2 server always redirects to /var/www (Index of /) site

I am currently trying to setup an virtual hosts following this tutorial on DigitalOcean.
The dummy-site I am trying to serve is under /var/www/example/html/index.html. I have not registered an official domain but setup /etc/hosts/ to resolve example.com to the IP address of my server.
I created another conf file called example.conf under /etc/apache2/sites-available and enabled it with sudo a2ensite example.conf and disabled the 000-default.conf.
Now whenever I go to example.com in my browser I get served:
.
This is the same page I would get when directly going to the IP address of my server. Only when I got directly to example.com/example/html I get served the correct index.html.
My current config looks like this:
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And my /etc/hosts file on my laptop like this:
#<ip-address> <hostname.domain.org> <hostname>
<server-ip> example.com
There are some other folders inside /var/www/ as the company I rented the server from had some maintenance sites preinstalled, but that shouldn't matter in this situation. (See edit, this did actually matter).
It feels like I am missing something obvious here, but I can't find a solution for my problem.
Edit:
The obvious thing I was missing, was that 2 additional sites where enabled by default as well.
One had the following contents:
# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.
<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
ServerName <predefined Server name>
</VirtualHost>
After disabling all the other sites, the request to example.com actually went to the right index.html.
I figure, that the above enabled site actually matched the request coming from my browser and showed the www root directory.
The obvious thing I was missing, was that 2 additional sites where enabled by default as well.
One had the following contents:
# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.
<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
ServerName <predefined Server name>
</VirtualHost>
After disabling all the other sites, the request to example.com actually went to the right index.html.
I figure, that the above enabled site actually matched the request coming from my browser and showed the www root directory.

Drupal 7 multisite not working

I am trying to setup a multisite for an existing drupal 7 site.
What I've done is
Created a db and imported the existing sites db to use with the new site
Created a folder inside sites directory called mysite.local and copied settings.ph and changed the db configurations with the new one.
Added an entry in /etc/hosts file.
127.0.0.1 mysite.local
Added a file mysite.local.conf in /etc/apache2/sites-available and added the following lines.
DocumentRoot "/var/www/html/drupal/sites/mysite.local"
ServerName mysite.local
ServerAlias mysite.local
`
and enabled the site.
Then added a symbolic link to this directory
ln -s /var/www/html/drupal /var/www/html/drupal/sites/mysite.local
But I am getting 403 while accessig mysite.local.
Can any one help me to figure out what is going wrong here
Even if it is a multisite you need to point it to the root directory. Drupal will figure out based off the domain name where to pull the settings.php from. Change your DocumentRoot back to /var/www/html/drupal

How properly set a website and domain (with subdomains) with apache on ubuntu?

First of all, apologies for my English.
I've been reading and reading guides last week a lot hours with no success. I bought a domain + hosting but due bad performance I've got a cheap vps to use as hosting. Currently my setup is:
A domain .com with an A record pointed to my vps ip.
A unmanaged vps with Ubuntu 14.04.2 64 bits to use as hosting for my wordpress with LAMP stack with default setup (I didn't changed any setting on apache, using default virtualhost).
My site works fine but I'm don't know how create subdomains with different directories. For example, my website.com files are in /var/www/html and I'd like to create subdomain.website.com with the files in other directory, let's say /var/www/subdomain.
I checked a lot tutorials and they say to create a virtual server on apache (I use webmin) and then an A record for the subdomain pointing to the server ip.
The problem is that when I enter to subdomain.website.com I see the content from main domain (/var/www/html) and not from "/var/www/subdomain"
I don't want ask you for a full guide step by step, I just need know where I need to start for achieve a subdomain with a different directory because usually I always used hosting services with tools like cpanel to create subdomains pointed to directories in 2 clicks.
I'm a full newbie with Apache/dns management.
Thanks a lot for your time!
Create a virtual host in Apache by creating a file at /etc/apache2/sites-available/subdomain.website.com.conf
In that file, add the following
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now place your subdomain.website.com files at
/var/www/subdomain.website.com/public_html
Then enable the new virtual host by sudo a2ensite subdomain.website.com
After placing the files, if you get a 403 forbidden error, check for permissions of the DocumentRoot folder.
Refer: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

ec2/apache not able to locate files on public web from /var/www/html folder

I just followed the instructions from this page (http://www.alexkorn.com/blog/2011/03/getting-php-mysql-running-amazon-ec2/) to setup apache and mysql on an ec2 instance. I couldn't get their custom file structure to point to my files, so I changed the structure to /var/www/html and change changed the bottom of the http.conf file to show this change. When I do that, I get an Amazon Linux AMI Test Page test page on the server, but when I try to test /index.html or /index.php, I get a file not found error - even though I created the /var/www/html directories and placed both files there - what can I be doing wrong?
Page location: http://ec2-107-20-234-28.compute-1.amazonaws.com/
It based on the Linux OS and how Apache has been setup, as per your statement, it looks you have configured the <VirutalHost> something similar to below (correct me if I am wrong):
<VirtualHost *>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>
Then, you restarted Apache (? - confirm), if this is correct, then I am sure you see what you want.
Update:
If you are using Debian/Ubuntu don't mind looking at the following URL for configuring an OS for web-development: http://rakesh.sankar-b.com/2010/09/10/install-setup-debian-os-server-machine/

Apache and Cakephp application

I am running into issues with cakephp application running with CentOs. I did not change any setting in the default config other than added a file under conf.d which content as :
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/portal/
ServerName abc.mydomain.com
</VirtualHost>
When accessed, home page works i.e. app.mydomain.com shows up but none of the CSS,JS and img files are loaded which are under default structure
i.e. /var/www/portal/app/webroot/img
/var/www/portal/app/webroot/css
/var/www/portal/app/webroot/js
So I tried moving them right under /var/www/portal/ and that worked for homepage but clicking on any link on homepage just does 404. e.g. If link is abc.mydomain.com/test
In apache log I see the errors as 'File Does not exist : /var/www/portal/test' . It seems that apache is not sending the request to cakephp to process the url.
What could be wrong here? Most likely with the apache security settings but am not sure where to lool.
Is your AllowOverride set to all? Only then the CakePHP rewrite directives which are in .htaccess files start working. Alternatively, you can move them to the virtual host configuration and get them to work.
Ok, this is a common mistake. you should enable "rewrite" --> module rewrite. (this is of course a php module). in ubuntu you usually type sudo a2enmod rewrite. Check for CentOS command.