The requested URL /services was not found on this server - apache

I have a LAMP environment. Running Ubuntu 14.04
I have installed and configured everything correctly (or at least I think so) but only the homepage of my website loads.
My domain is www.codeclimb.com but if you navigate to any other pages I get this error
The requested URL /services was not found on this server.
Here is my vhost setting for apache.
<VirtualHost *:80>
ServerAdmin chris#codeclimb.com
DocumentRoot /var/www/codeclimb.com/public_html
ServerName codeclimb.com
ServerAlias www.codeclimb.com
</VirtualHost>
What can possibly be the problem? I can log into my wordpress admin panel but no content loads. I can only see the sidebar with links to "dashboard, posts, settings, ect..." but will not display content on the right side of the page.

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.

How to add a website to the Apache Web Server

I have installed a the following Drupal distribution on an Ubuntu virtual machine at /var/www/html.
https://www.drupal.org/project/social
The Composer script installs the project at /var/www/html/project-folder and index.php can be found in /var/www/html/project-folder/html.
Within the file /etc/apache2/sites-available/000-default.conf I have changed the document root to `/var/www/html/project-folder/html'.
Now when I visit the IP Address for the server, it does load the homepage of the PHP based website, but all of the links to other pages are broken, and none of the images can be found.
What is the correct way to add a new site to the Apache web server? Should a VirtualHost be used, or is it better to change the document root?
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/project-folder/html
</VirtualHost>

Subdomains with Apache Virtualhost

I have a server and registered a domain - say mysite.com - that is pointing to the IP address of the server. I tested the setup with a django project in the default.conf file. This works without a flaw, but my goal is to move this django site to a subdomain. As this didn't work as expected, I tried to get a minimal example working with a redirect.
This is what I have:
sites-available/sub.conf
<VirtualHost *:80>
ServerName sub.mysite.com
RedirectPermanent / https://google.com/
</VirtualHost>
I enabled the site via a2ensite sub and service apache2 reload. When visiting sub.mysite.com all get is
Server not found
What am I missing?

Hosting multiple unnamed sites on same EC2 box

I know that I can have multiple websites hosted on the same EC2 box. The way I'm doing it is pointing Route 53 for the domain to the same box and in my httpd.conf file I'm adding something like this:
<VirtualHost *:80>
ServerName mywebsite.com
DocumentRoot "/var/www/html/website1"
</VirtualHost>
This works great for websites that have an assigned domain name.
What if I am still working on a site/application and don't have a domain name assigned to it?
<VirtualHost *:80>
ServerName <==what goes here if I don't have a domain name yet?
DocumentRoot "/var/www/html/website2"
</VirtualHost>
Is this even possible?
I tried just taking the IP of the box and going here: 54.32.XX.XX/website2/index.html
But this gives a 404.
How do I properly access this subdirectory?
Of note, the side in website1 is what I get when I just go directly to the IP (54.32.XX.XX) which I wouldn't expect since I have another site in the "main" directory /var/www/html/

IP of Web server stays in URL instead of showing Domain Name

So lets say I have the Domain Name "www.example.com" and have a "http-redirect" to server "1.1.1.1" where apache2 is running on Ubuntu 14.04 Server amd64.
I have all my web files on the server and they are working perfect.
What is not working right is the URL. Instead of "www.example.com/sites.php" if have "1.1.1.1/sites.php". How can I fix this?
What I did so far:
Disabled the default Virtual Host and created a new one:
<VirtualHost *:80>
ServerAdmin bla
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www
ErrorLog ...
CustomLog ...
</VirtualHost>
(It's typed, since I can't copy from my console..)
I tried to enter in the /etc/hosts
1.1.1.1 www.example.com
Thanks for any help
As discussed in comments, the reason that you see IP address in your browser is that http-redirect is pointing directly to to IP address, there's no domain name to display. Redirect just tells browser to go elsewhere and browser then fetches website from supplied URL, same as if you'd click on a link. If you redirect URL to 1.1.1.1/sites.php than that is what you will see in browser.