Once I a2enmod the ssl module and restart apache I get the following error:
Restarting web server apache2
AH00548: NameVirtualHost has no effect and will be removed in the next
release /etc/apache2/ports.conf:14
(98)Address already in use: AH00072: make_sock: could not bind to address
[::]:443
(98)Address already in use: AH00072: make_sock: could not bind to address
0.0.0.0:443
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
To stop it I can either disenmod or comment out the following module lines in the ports.conf file:
Listen 80
#<IfModule mod_ssl.c>
# Listen 443
#</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Any help would be much appreciated
The following lines of your output state that an other programme is already listening on port 443 and due to the fact that Apache does not support port sharing it is unable to bind to that port and so it shuts down.
(98)Address already in use: AH00072: make_sock: could not bind to address
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443
Thus I recommend you to shut the programme listening to that port down. You can determine which programmes are listening on TCP port 443 with the following command (must be executed as super user):
netstat -tlpn | grep 443
Then shut down the already listening programme (for example by using service <programme> stop or by using kill <processID> (the process ID is also supplied by netstat). Afterwards, you can start Apache by using service apache2 start or by executing /etc/init.d/apache2 start. Both commands work when you are working with Ubuntu/Debian. If you are working with CentOS/RedHat Apache is named httpd.
The error "AH00015: Unable to open logs" is indicative of a missing file or directory in one of your log definitions. If you have a web server with a lot of virtual named sites running on it, it is easy to delete an old directory and forget to update the httpd-vhosts.conf or httpd-ssl.conf files to remove the config.
I run FreeBSD 10.3 with Apache 2.4, so my files may be in another location that yours. But once you find where your virtual hosts files are located, the solution is the same. This is what you need to do to solve this:
Change into the directory where your virtual named hosts are defined:
cd /usr/local/www/conf/extra
Use grep to pull all of the log file references out of your named
virtual host definitions:
grep -i log * > x.tmp
This will create a file with entries that show the name of the file, the apache log directive (ErrorLog, CustomeLog, TransferLog), and the name of the log file.
Use the bash shell to setup a while read loop to pull the file apart
and capture the names of the log files in another file:
cat x.tmp | while read a b c d; do echo $c >> y.tmp; done
Use your favorite editor to edit the y.tmp file to remove anything
that does not look like the name of a log file (junk). This junk is
inevitable with using grep to search for text in a big file. Once
you have a list of files (and nothing else), insert "ls -la " in
front of the file names. With the vi editor you can do this with
the following command:
:%s/^/ls -la /
Run the file as a script using sh or bash as follows:
sh y.tmp
It will show the individual file if it exists, and if it does not
exists it will display an error similar to the following:
ls: /usr/local/www/virtual/nsr/logs/access.log: No such file or directory
This could be caused by a misspelling, a missing directory, or some
other cause (a symlink that points to a non existent object). Either
edit your virtual named hosts definitions to remove it from the
configuration, or define the directory with the correct permissions
for the web server to access it.
Restart the web server (apachectl start) and verify the httpd
daemons are running using ps awx | grep http.
Based directly on this answer, you should kill httpd (it has server.port = 80 in its lighttpd.conf) and then try to start apache.
= Show processes hung =
ps wax | grep httpd
= Kill Process ID 1234 =
kill 1234
= Start Apache24 =
apachectl start
= Verify it is running =
service apache24 status
Related
Inside the box, I have two virtual hosts:
<VirtualHost *:80>
HostName my.site1
...
</Virtualhost *:80>
<VirtualHost *:80>
HostName my.site2
...
</VirtualHost>
How can I connect to the vhosts inside the guest from the host? In my (host) /etc/hosts I have:
127.0.0.1 my.site1
127.0.0.1 my.site2
Because of the Vagrant's port mapping, the guest is accessible only as my.site1:port, e.g., my.site:3000. With that, the Apache inside the guest takes me just to the root (the Apache's welcome site). It is the same for both vhosts: my.site1:3000 and my.site2:3000.
apachectl -S logs:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server stretch.localdomain (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost stretch.localdomain (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost my.site1 (/etc/apache2/sites-enabled/001-site1.conf:1)
port 80 namevhost my.site2 (/etc/apache2/sites-enabled/002-site2.conf:1)
Is that because of improper configuration of vhosts or am I missing some point in the name/port or host/guest configuration?
Am I right it should work this way?
my.site1:3000 -> contents of my.site1
my.site2:3000 -> contents of my.site2
Okay, so the problem here is the networking. I was able to reproduce this problem. First of all, please disable the port forwarding in Vagrant. Just comment config.vm.network "forwarded_port", guest: 80, host: 8070 and do a vagrant reload .To get this working, you need to check your host's IP address and then go to your Vagrant file and edit config.vm.network "private_network", ip: "X.X.X.X" so that the ip address here is actually on the same network as your host. What I did is just incremented the last octet by 1. e.g. My local IP address is 192.168.23.45 so I assigned 192.168.23.46 to the Vagrant guest.
Once this is done, perhaps, you can save yourself all the trouble by just using this shell script to create Virtual hosts for yourself. I have pasted the output below which you can go through to see that I have setup my two virtual hosts with mysite1 and mysite2 names.
Then just put the host file entries on your host like below:
192.168.23.46 mysite1
192.168.23.46 mysite2
And accessing the website using http://mysite1 and http://mysite2. You might want to change the content of the index.php placed by script under the respective document roots so that you can be sure that the requests are being handled by correct virtual hosts since this scripts just deals with the default index.php of apache which will be found under both your document roots.
The other option is to make the Vagrant box available on public network and then
access it using the public IP and for that, you will have to enable config.vm.network "public_network" in your Vagrant file and the rest of the process of creating the Virtual host is the same (Using this script).
[root#localhost vagrant]# bash test.sh
Enter the server name your want (without www) : mysite1
Enter a CNAME (e.g. :www or dev for dev.website.com) : mysite1
Enter the path of directory you wanna use (e.g. : /var/www/, dont forget the /): /var/www/mysite1/
Enter the user you wanna use (e.g. : apache) : apache
Enter the listened IP for the server (e.g. : *): *
Web directory created with success !
/etc/httpd/conf.d/mysite1.conf
Virtual host created !
Would you like me to create ssl virtual host [y/n]?
n
Testing configuration
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Would you like me to restart the server [y/n]?
y
Redirecting to /bin/systemctl restart httpd.service
======================================
All works done! You should be able to see your website at http://mysite1
Share the love! <3
======================================
Wanna contribute to improve this script? Found a bug? https://gist.github.com/mattmezza/2e326ba2f1352a4b42b8
[root#localhost vagrant]# bash test.sh
Enter the server name your want (without www) : mysite2
Enter a CNAME (e.g. :www or dev for dev.website.com) : mysite2
Enter the path of directory you wanna use (e.g. : /var/www/, dont forget the /): /var/www/mysite2/
Enter the user you wanna use (e.g. : apache) : apache
Enter the listened IP for the server (e.g. : *): *
Web directory created with success !
/etc/httpd/conf.d/mysite2.conf
Virtual host created !
Would you like me to create ssl virtual host [y/n]?
n
Testing configuration
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Would you like me to restart the server [y/n]?
y
Redirecting to /bin/systemctl restart httpd.service
======================================
All works done! You should be able to see your website at http://mysite2
Share the love! <3
======================================
Wanna contribute to improve this script? Found a bug? https://gist.github.com/mattmezza/2e326ba2f1352a4b42b8
Please let me know in case you need more clarification.
I am trying follow the guide here:
http://www.servermom.org/how-to-add-new-site-into-your-apache-based-ubuntu-server/
to host a few PHP files on the web. Everything works until the second to last step: the command in the title. The console message I get is below:
bitnami#ip-*not important*:~$ sudo service apache2 restart
* Restarting web server apache2
AH00112: Warning: DocumentRoot [/var/www/html] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified do
main name, using 127.0.0.1. Set the 'ServerName' directive globally to suppres
s this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]
:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.
0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
* The apache2 instance did not start within 20 seconds. Please read the log f
iles to discover problems
I open the access.log and error.log files in /var/log/apache2 with nano and both appear empty. Any ideas on why "Action 'start' failed"?
Thanks in advance for any help
Bitnami puts the systems under it's control into a non-standard location. They can be found under /opt/bitnami. I'd recommend checking out their Documenation on the configuration of Apache.
Common differences:
Configuration is stored in /opt/bitnami/apps/myapp/conf/
Base folders like /var/www are application specific like /opt/bitnami/apps/<app_name>/htdocs/, where is the name of your app.
Restarting Apache can be done with sudo /opt/bitnami/ctlscript.sh restart apache
Access and Error logs can be found at /opt/bitnami/apache2/logs/access_log and /opt/bitnami/apache2/logs/error_log respectively
Hope that helps get you in the right direction.
When i try to start my apache2 in ubuntu, it displays following error.
* Starting web server apache2
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:8
AH00558: 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
(98)Address already in use: AH00072: make_sock: could not bind to address 127.0.0.1:8080
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
*
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
And My log files in var/log/apache2/ files error.log,acces.log files not updated after i emptied it.
Please help me to solve it.
Probably some other service is already using port 8080. Run
# netstat -lnpt
to see what it is.
I am using Apache 2.2.17 with XAMPP Control Version 2.5 but and apache is using port 8080 but when I start apache service it shows:
ERROR : Apache service not started [-1]
and to see the port is used by any other program i did
netstat -a -n -o
from where i got PID 2952 is using that port which is java.exe as I need that to run my program.
I had changed port in the apache/conf/httpd.conf file as
#Listen 0.0.0.0:87
#Listen [::]:87
Listen 87
and ServerName localhost:87 and restarted my pc but the port was not changed .Please help to get access to localhost/phpmyadmin
Take care of a few things.
Firstly, close Xampp completely before editing the httpd.conf file. Xampp tends to run Apache and other stuffs in the background even after you quit it. To check if it's closed completely, use the Task Manager.
Secondly, try any other Port number. To check which ports are unused, open command prompt and type netstat -an. You can view the list of ports that are open.
I have installed Apache 2.0.58 together with PHP 5.1.4. When I start the server using ./apachectl start, I manage to get the server running to serve HTTP as well as PHP pages, but when I try to start SSL for HTTPS using ./apachectl startssl, I get the error below:
(125)Address already in use: make_sock: could not bind to address [::]:54912
no listening sockets available, shutting down
Unable to open logs
When I run netstat -an | grep 54912 I don't see that port 54912 is being used at all. For reference, I hosted my HTTPS page on port 54912, and while in "httpd.conf" it already has the Listen 54912 directive, I also changed the file "ssl.conf" to Listen 54912 from the default Listen 443for https.
Any idea how I can get my server to run and serve HTTPS?
It's probably because apachectl startssl was deprecated in version 2.0 (and was removed in has version 2.2)
It's likely that apache start has already started the SSL virtual hosts, in particular if these virtual hosts (or other SSL-related options) haven't been defined in a <IfDefine SSL> section (because in Apache 2.0, apachectl startssl is equivalent to apachectl -k start -DSSL): they would be part of the main configuration.
Got the server running! :)
As mentioned by #EJP, the problem is because there are 2 Listen 54912 inside config. So by changing the file httpd.conf to Listen 14912 and retaining the file ssl.conf to Listen 54912, I can now run apachectl startssl and after entering the password, the server is up and running!
Special thanks to Tim Yencken for the help. (Dunno if he's here or not).