I've wrongly removed /etc/apache2 - apache

I'm wondering whether it's possible to install apache2 from scratch, I tried to install it and many times I was informed that a configuration file was removed, and everytime I chose to install the package responsible version. When starting apache service I have this apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName and the localhost url shows Page Web inaccessible.
How can I fix this?
Thanks in advance.

Just add to apache2.conf
Servername localhost
into last line.
(PATH)
sudo nano /etc/apache2/apache2.conf

Related

How to change Apache root directory

I know that there are several other questions asking this. However, I still have problems.
I am trying to change my Apache root server directory from the default /var/www/html on my Debian server. To do this, I modified /etc/apache2/sites-available/000-default.conf to have DocumentRoot /var/www instead of DocumentRoot /var/www/html. After doing this and saving it, I ran apache2ctl restart to reload the server. However, the server still looks for files in /var/www/html instead of /var/www. Is there something else I need to change?
Just make sure you are "landing" in the VirtualHost you are modifying.
You can check the virtualhosts being loaded with this command:
apachectl -S
Note: It is not ServerRoot what you are describing, it is DocumentRoot, there is a big diffrence between each, so better name them properly.

How to enable Apache SSL Reverse Proxy on HTTP application

I've been having problems attempting to implement a reverse SSL proxy on Apache for an HTTP application on Ubuntu 14.04. As a baseline, the application works fine when I access it via port 8000 in the browser normally. For all intents and purposes, let's say the IP of my app is 192.141.56.11 (I do not have a domain name yet). The application runs with HTTP Basic Auth, I don't know if it's relevant. Basically I'm fishing for some glaring error here and would be grateful if you could help me out. Here is a log of my process:
I created my SSL cert and key and put them in the following locations:
/etc/apache/ssl/apache.crt (I performed chmod 644 here)
/etc/apache/ssl/apache.key (I performed chmod 400 here)
I then installed:
apt-get install apache2
a2enmod proxy
a2enmod ssl
a2enmod proxy_http
I then disabled the default config with:
a2dissite 000-default
I created the file "/etc/apache2/sites-available/redirect.conf"
I then created the file "/etc/apache2/sites-available/redirect.conf" and copied the text below:
<VirtualHost *:80>
Redirect "/" "https://192.141.56.11"
</VirtualHost>
After, I created the file "/etc/apache2/sites-available/reverse_proxy.conf" and copied below:
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache/ssl/apache.crt
SSLCertificateKeyFile /etc/apache/ssl/apache.key
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
and did:
service apache2 restart
I now attempt to access the UI of the application on another machine in the Chrome browser. When trying:
https://192.141.56.11
I get a general SSL connection error.
However, trying
http://192.141.56.11:8000
gives me the application, as if none of my config changed anything. However,
192.141.56.11:80
gives me an "Index Of" page with an html folder that says "Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 80"
192.141.56.11:443
gives me the same result except with "Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 443"
I've tried all manners of configurations but can't get what I want -- any ideas here?
EDIT: I tried https[:]//192.141.56.11 and got a more specific SSL error:
received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)
EDIT2: After running apache, I get this warning;
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
I suppose this is fine as I am using an IP and not a domain name.
EDIT3: It turns out I needed to do:
a2ensite reverse_proxy.conf.
Now https[:]//192.141.56.11 works but defaults to an apache page. working on this.
EDIT4: I had to do
a2dissite default-ssl.conf
Now It actually redirects to the app on https[:]//192.141.56.11!! But I can still access the app via port 8000, which is bad {still working on}
EDIT5: IN the end, I couldn't figure out how to block access to the original app via port 8000 on Apache. Instead, I just implemented iptables on the server so that it can only be accessed via HTTPS. This is probably not the correct method. but all I could think of.

Apache set up mac os yosemite

I am trying to get Apache to run on my yosemite machine, but when i try to access localhost i get http://i.stack.imgur.com/ZzZzB.png.
I ran an apache configtest and got the following
Angus-Mac:mysql root# apachectl configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Angus-Mac.local. Set the 'ServerName' directive globally to suppress this message
Syntax OK
What am i getting wrong? any ideas?
Uncommenting the ServerName and changing it to the domain name solved the issue.
change the group permissions on that folder to _www
sudo chgrp -R _www /Library/WebServer/Documents (all web content is now group _www)
chmod -R go-rwx /Library/WebServer/Documents (nobody other than owner can access web content)
chmod -R g+rx /Library/WebServer/Documents (all web content is now readable/executable/enterable by _www)
then restart apache
It seems your user in httpd.conf is different that the one on the web directory
I found the solution here
Please uncomment the ServerName in line 212 (httpd.conf) and change the domain www.example.com to your domain.
Restart apache

How do I point Apache document root to a specific folder in Ubuntu?

I have a site that the root points to /var/www
I have set up two folders under /var/www
/var/www/old
/var/www/new
for the old folder, I have used the following to deny any access:
touch /var/www/old/.htaccess && echo deny from all >> /var/www/old/.htaccess
I now want the server to point the root to /var/www/new so that when people visit http://example.com the content in /var/www/new will serve, what should I do?
In Ubuntu the Apache configuration is located at /etc/apache2. There should be two folders, sites-available and sites-enabled. Inside sites-enabled are symlinks to config files in sites-available.
You simply have to change the document root in your activated configuration. Thats probably /etc/apache2/sites-enabled/000-default
Have a look for DocumentRoot and change it to /var/www/new, then reload your apache.
depends a LOT on how your apache server is configured.
I don't have an Ubuntu machine around, but what you're looking for is the DocumentRoot directive. On RedHat based machines it's normally in /etc/httpd/conf/httpd.conf but if memory serves Debian based systems use apache instead of httpd.
If that doesn't work be sure to check in /etc/httpd/conf.d since the files there are loaded dynamically.
Hope this helps :)

Specific Port Configuration on Apache

So I'm trying to develop a php website locally on my macbook. I'm using apache as my webserver, I have php and mysql installed, and I can use the php index file in my sites folder, but I would like to move all of my development over to a different.
I've been trying to configure apache to run on a different port, so far I've made these changes to my /etc/apache2/extras/httpd-vhost.conf
<VirtualHost *:2727>
ServerAdmin foobar#gmail.com
DocumentRoot "/Users/brianWheeler/Foobar"
ServerName local.foobar.com
</VirtualHost>
And i've edited my /etc/apache2/httpd.conf to say
listen 127.0.0.1:2727 http
I've started apache, but when I go to 127.0.0.1:2727 I get the google chrome page not found type thing.
I've run apachectl -t command to see whats wrong, and I just get this one error
httpd: Could not reliably determine the server's fully qualified domain name, using Foo-Bars-MacBook.local for ServerName
So my questions are, how do I configure the DocumentRoot/index page, and what kind of diagnostics can I run to see why this won't work?
-Brian
httpd: Could not reliably determine the server's fully qualified domain name, using Foo-Bars-MacBook.local for ServerName - this error possibly is not related with your problem.
most of my test server are giving this error but they are running with no problem.
please try to insert the line without ip and http,
listen 2727
edit: can you try following:
NameVirtualHost *:2727
Listen 2727