Apache version conflict (cont) - apache

Concerning the post Apache versions conflict. I tried again the installation of apache following the steps from https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions
I still have some problems if I want to test localhost from my local Site folder.
Result of apache log
Regarding the error
Could not reliably determine the server's fully qualified domain name,
using 127.0.0.1. Set the 'ServerName'...
I tried the option of adding ServerName localhost in the file /etc/apache2/apache2.conf https://askubuntu.com/questions/454497/apache2-could-not-reliably-determine-the-servers-fully-qualified-domain-name but I don't know if that is that is the right file, because i'm working with apache 2.4 (/usr/local/etc/apache2/2.4/httpd.conf)
Additionally, if I run the command sudo apachectl -k restart I got this
(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
In my file /etc/apache2/httpd.conf
I have this:
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User amhg
Group staff
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost
DocumentRoot /Users/amhg/Sites
<Directory /Users/amhg/Sites>
#
AllowOverride All
and I uncommented LoadModule rewrite_module libexec/mod_rewrite.so
Any suggestions?
Thank you in advance!

you can see all of your apache installed version with command :
rpm -qa | grep httpd
in your log file I do not see any error.
can you sent all of your log file?
and can you explain what do you see in browser when go to :
http://localhost

Related

Apache HTTPD: How to setup Virtual Host correctly

I've installed Apache httpd on my Mac and "It works".
Now I need to configure a Virtual Host in order to expose my application (Java Spring) with httpd as reverse proxy in front of it.
This is what I have into /usr/local/etc/httpd/extra/httpd-vhosts.conf file
<VirtualHost *:443>
ServerName my.domain.it:443
SSLEngine on
SSLCertificateFile /path/to/cert.crt
SSLCertificateKeyFile /path/to/cert.key
ProxyPreserveHost On
ProxyPass / http://localhost:8080/myapp
ProxyPassReverse / http://localhost:8080/myapp
</VirtualHost>
In /etc/hosts I've mapped to server address in this way:
127.0.0.1 my.domain.it
And The Tomcat Connector configuration is:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" proxyPort="443" scheme="https"/>
If I run the application with Eclipse it responds correctly at http://localhost:8080/myapp/ but If I try to call https://my.domain.it/myapp/ It doesn't work and Google Chrome tells me: "This site can't be reached".
What's wrong with my configuration?
P.S.
The httpd Apache instance is configured to Listen on port 80
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
Thanks.
EDIT: SOLVED
Unfortunately I was not able to solve with Apache Httpd but now with Nginx it works. Thanks for your answers
In mod_ssl.conf (file name might be different) you should have the following line
Listen 443
It tells apache to listen on port 443 (it's include in the configuration file when you install mod_ssl to be able to expose your site over HTTPS).
The same configuration file should include all the shared configuration about the TLS.
If apache is running, you can check if port 443 is listening, using netstat:
netstat -an | grep -i list
The output should include port 80 and 443 (and some other according to the services running on the server such as ssh).
If the port is shown in the list, next step is to check apache logs for errors.

Config VirtualHosts on Debian/Apache

On my debian/apache server at http://localhost I'm redirected to my api on port 3000 (this is ok)
Now I would like to open another port (8090), in http://localhost:8090 redirected to /var/www/html/
How to make?
Find the default virtual host conf file by running
ls /etc/apache2/sites-available/
There should be a file called deault.conf, or similar. We want to edit this file
sudo nano /etc/apache2/sites-available/default.conf
Make sure that apache actually is listening to your port 8090 by adding, to the top of that document
Listen 8090
Change the rest of the conf file to match your site, so it may look something like this
Listen 8090
<VirtualHost *:8090>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
# Other directives here
</VirtualHost>
Save the file with a different name in the same folder. The files must end with ".conf". Add the virtual host to enabled sites by running
sudo a2ensite virtual_host_file_name.conf
replacing "virtual_host_file_name.conf" with the name of the file you select in the previous step.
Then restart the apache server
sudo service apache2 reload
It seems like you're only interested in accessing it from localhost, but if you want to access it remotely you might need to check your firewalls.

WAMP server name not found for virtual host in apache

System: Windows7 64-bit
WAMP server 32-bit version: Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 SqlBuddy : 1.3.3 XDebug : 2.2.5
My issue is that when I navigate to my project "local.blamo1.com" - via WAMP "Localhost" chrome returns: "Oops! Google Chrome could not find local.blamo1.com"
I am able to access my project folder with "localhost/local.blamo1.com" - But as I understand it, this is bad practice as it will throw off server mapping by one directory. I would like to be able to access the project with the designated server alias. I have implemented the following...
httpd-vhosts.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.config"
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/local.blamo1.com"
ServerName local.blamo1.com
ServerAlias local.blamo1.com
<Directory "c:/wamp/www/local.blamo1.com">
AllowOverride All
Require local
</Directory>
</VirtualHost>
hosts file
Location: "C:\Windows\System32\drivers\etc\hosts"
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 local.blamo1.com
#::1 localhost
#::1 local.blamo1.com
httpd.conf
Location: "C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
I have un-commented these lines
Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Current Diagnosis
Apache httpd -t return: "Syntax OK"
I think this has something to do with my DNS or ports, or whatev - as I do not have enough experience with this level or how the DNS is not able to resolve the domain:
after I tried to ping the project:
ping local.blamo1.com
"Ping request could not find host local.blamo.com. Please check the name and try again.
Please help me understand why I am getting this issue. I have been working on this for a day and a half. Apologies if there is not adequate information for your to make a diagnosis of the problem. I will provide more information as necessary.
All my best.
I was able to solve this issue - props to this post: http://www.tweaksforgeeks.com/windows7/2011/02/windows-7-hosts-file-ignored
The issue appeared to be a corrupted "hosts" files - all I know for sure was that the solution was to delete the hosts file and create a new one with raw text from the old. The causality is inexplicable.
This solve my problem. After hours of making it work. Turns out I was careless about the host file. Saving as txt and then just removing the extension to replace the original file.

Creating subdomains on apache2 server with dynamic IP

So basically I'm having issues creating a subdomain on my server. I'm running apache2 on a Ubuntu 12.04 server and have dynamic IP set up with No-IP.com.
I have mydomain.com working, but want to create test.mydomain.com directing towards a subfolder in my /var/www/ directory (where everything for my website is located).
I modified the code on apache vhosts examples page and put this in my httpd.conf file:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost localhost:80
<VirtualHost localhost:80>
DocumentRoot /var/www/
ServerName mydomain.com
# Other directives here
</VirtualHost>
<VirtualHost localhost:80>
DocumentRoot /var/www/test
ServerName test.mydomain.com
# Other directives here
</VirtualHost>
When I try and restart the service:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
Any help is greatly appreciated. Please let me know if I'm forgetting to include any necessary information.
Update
I tried using *:80 but I still got an error, that's why I switched to localhost.
sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Nov 21 15:03:51 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Nov 21 15:03:51 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
UPDATE I figured out what was going on. I had a matching configuration entry in my ports.conf file. Once I removed that, everything worked fine.
Your apache conf seems correct if you replace localhost with *. That means that you should use NameVirtualHost *:80 and <VirtualHost *:80>
However, you must tell the DNS server to forward subdomains to your dynamic IP. Since you have a .com domain from a paid DNS service, you must login to your DNS provider and setup A records or CNAME records to your IP (add the same settings you have in your main .com domain). If you use the a ddclient or similar client to automatically update the domains, you can configure it to update the subdomain as well.
In any case, use command nslookup yourdomain.com and nslookup subdomain.domain.com to see if the subdomain is updated successfully. Note that updates in DNS may take hours before they are actually in effect.
EDIT:
Sorry just noticed : (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80. This means that somebody else is already using port 80, so the apache server cannot bind to that address. Use sudo netstat -anltp | grep :80 to see which program has bound port 80. Also, check your conf files to make sure that you have no more NameVirtualHost *:80 directives.
Last, apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName is not an error, it's just a warning so you shouldn't be worried about this
Possible that there a service using port :80
Try netstat -tulpn |grep :80 on command line to see which service is occupying this port. In my case, it was nginx. I stopped the service then started the one I wanted to use (apache2).

Apache error: _default_ virtualhost overlap on port 443

I get this error when trying to start Apache.
_default_ virtualhost overlap on port 443
I'm trying to set up SSL. Almost every solution online says add:
NameVirtualHost *:443
to the conf file but Apache still fails to start and just says
Action start failed. the apache logs may have more information
There is zero information in the Apache logs.
To resolve the issue on a Debian/Ubuntu system modify the /etc/apache2/ports.conf settings file by adding NameVirtualHost *:443 to it. My ports.conf is the following at the moment:
# /etc/apache/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
NameVirtualHost *:443
Listen 443
</IfModule>
Furthermore ensure that 'sites-available/default-ssl' is not enabled, type a2dissite default-ssl to disable the site. While you're at it type a2dissite by itself to get a list and see if there is any other site settings that you have enabled that might be mapping onto port 443.
On a vanilla Apache2 install in CentOS, when you install mod_ssl it will automatically add a configuration file in:
{apache_dir}/conf.d/ssl.conf
This configuration file contains a default virtual host definition for port 443, named default:443. If you also have your own virtual host definition for 443 (i.e. in httpd.conf) then you will have a confict. Since the conf.d files are included first, they will win over yours.
To solve the conflict you can either remove the virtual host definition from conf.d/ssl.conf or update it to your own settings.
It is highly unlikely that adding NameVirtualHost *:443 is the right solution, because there are a limited number of situations in which it is possible to support name-based virtual hosts over SSL. Read this and this for some details (there may be better docs out there; these were just ones I found that discuss the issue in detail).
If you're running a relatively stock Apache configuration, you probably have this somewhere:
<VirtualHost _default_:443>
Your best bet is to either:
Place your additional SSL configuration into this existing VirtualHost container, or
Comment out this entire VirtualHost block and create a new one. Don't forget to include all the relevant SSL options.
I ran into this problem because I had multiple wildcard entries for the same ports. You can easily check this by executing apache2ctl -S:
# apache2ctl -S
[Wed Oct 22 18:02:18 2014] [warn] _default_ VirtualHost overlap on port 30000, the first has precedence
[Wed Oct 22 18:02:18 2014] [warn] _default_ VirtualHost overlap on port 20001, the first has precedence
VirtualHost configuration:
11.22.33.44:80 is a NameVirtualHost
default server xxx.com (/etc/apache2/sites-enabled/xxx.com.conf:1)
port 80 namevhost xxx.com (/etc/apache2/sites-enabled/xxx.com.conf:1)
[...]
11.22.33.44:443 is a NameVirtualHost
default server yyy.com (/etc/apache2/sites-enabled/yyy.com.conf:37)
port 443 namevhost yyy.com (/etc/apache2/sites-enabled/yyy.com.conf:37)
wildcard NameVirtualHosts and _default_ servers:
*:80 hostname.com (/etc/apache2/sites-enabled/000-default:1)
*:20001 hostname.com (/etc/apache2/sites-enabled/000-default:33)
*:30000 hostname.com (/etc/apache2/sites-enabled/000-default:57)
_default_:443 hostname.com (/etc/apache2/sites-enabled/default-ssl:2)
*:20001 hostname.com (/etc/apache2/sites-enabled/default-ssl:163)
*:30000 hostname.com (/etc/apache2/sites-enabled/default-ssl:178)
Syntax OK
Notice how at the beginning of the output are a couple of warning lines. These will indicate which ports are creating the problems (however you probably already knew that).
Next, look at the end of the output and you can see exactly which files and lines the virtualhosts are defined that are creating the problem. In the above example, port 20001 is assigned both in /etc/apache2/sites-enabled/000-default on line 33 and /etc/apache2/sites-enabled/default-ssl on line 163. Likewise *:30000 is listed in 2 places. The solution (in my case) was simply to delete one of the entries.