Why I can't reload apache2 on Ubuntu? - apache

On Ubuntu, each time I use sudo service apache2 reload command to reload apache2 service , my terminal showed
apache2.service is not active, cannot reload.
And, I'm trying to add phpMyAdmin as virtual host, using phpmyadmin.local as local-area-network domain name; can anyone tell me how? I have tried many times today, I searched many methods, but until now, it's still 404 not found.

I had the same problem with Ubuntu 16.04. This was causing problems with logrotate, because it could not reload Apache after rotating logs.
The full error I was getting:
/etc/init.d/apache2 reload
[....] Reloading apache2 configuration (via systemctl): apache2.serviceapache2.service is not active, cannot reload.
failed!
The problem went away after stopping Apache with apachectl and starting it with /etc/init.d/apache2:
apachectl stop
/etc/init.d/apache2 start
You can now reload Apache:
/etc/init.d/apache2 reload
[ ok ] Reloading apache2 configuration (via systemctl): apache2.service.
If you start Apache with apachectl start, it is not being marked as an active service, so you can't reload it with service apache2 reload. You have to start Apache with /etc/init.d/apache2 start or service apache2 start.
I'm not sure if it's intended or a bug. I can't reproduce this with an older system.

Actually you should check if another service/server is running in the port 80 :
sudo netstat -tulpn | grep :80
If it's not apache2, stop it (for me it was lighttpd so sudo service lighttpd stop.
Then start apache2 (sudo service apache2 start) and enjoy!

check if you are missing /usr/sbin/apache2
Then if you are run: sudo apt install --reinstall apache2-bin

Related

ERR_EMPTY_RESPONSE when active mpm_event

I try to activate mpm_eventon my Apache (OS Debian 9 ) and disable mpm_prefork for active http/2 on my site.
But When I do that, my site goes down and shows ERR_EMPTY_RESPONSE on the browser.
The following commands I used to do that:
sudo apt-get install php7.4-fpm
sudo a2enmod proxy_fcgi
sudo a2dismod php7.4
sudo a2enconf php7.4-fpm
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo service apache2 restart
In the apache log I see just this error:
AH00052: child pid 27520 exit signal Aborted (6)
Is there anyone who knows what should I do to fix that?
I found out that the problem is because of Mod_Ruid2 conflicts with PHP_fpm.
When I disabled Mod_Ruid2 the site was back up and running without any problems.
a2dismod ruid2
The purpose of mod_ruid2 is to allow run of scripts with the users
permission when Apache is using mod_php. In that mode Apache is ran
with root and child processes are being setuid-ed to the proper user
so they can't touch other user files.
The php-fpm is completely different approach. With php-fpm the apache
does not compile php scripts - everything is done by external binary
(called php-fpm). Therefore there is absolutely no need for mod_ruid2
when you are using php-fpm.
https://forum.directadmin.com/threads/php-fpm-and-mod_ruid2-with-php7-1.56552/
https://forum.vestacp.com/viewtopic.php?t=16041

Apache not starting alongside Nginx

Have a development server with 2 static ips. Apache runs on one, Nginx on the other. Everything seems fine except after reboot. Nginx starts Apache doesn't. Can someone please tell me where to look outside log files for what the issue could be...or tell me the process on how to make this work..
Thanks in advance...
12/19/2018
Rebuilt the server using only Apache. When binding it to a single ip to one interface it still does not start after boot. When I unbind it, it boots fine. Doesn't seem to be a conflict with Nginx on the other ip, seems to do with the binding of Apache itself...still perplexed...
I went to sudo nano /etc/apache2/ports.conf
Changed Listen 80 to Listen 8080 and I was able to restart apache2 after that with the following command:
sudo systemctl restart apache2
It's probably because default port for both nginx and apache is 80. So for example when nginx starts, the port will be in use, and apache can't access to that port.
in ypur httpd.conf of apache, find the line that says Listen 80 and change that port to whatever you want. then restart apache.
If this is not the issue, then report results of these commands in your post plz:
$ systemctl status httpd // or apache2 instead of httpd
$ systemctl status nginx
$ jourcanctl -xe

How to stop tomcat and start apache2?

I have this server, that i have not installed personally. There are Apache2 and Tomcat6 running together. I want to stop Tomcat6 and use Apache2 but when i do
sudo service tomcat6 stop
sudo service apache2 restart
if i type 'localhost' in my browser i get a '503 service unavailable' error. So how i can get Apache2 'take control'? I mean i want the default site of Apache2 to be displayed on 'localhost' instead of tomcat'one.
(If i type locahost with Tomcat running i get an "it works" welcome page.)
Apache2 will have control when Tomcat is stopped and you start Apache. With Tomcat running on same port, you are unable to start Apache. Solution to 503 error is in Apache logs.

Starting web server apache2 failed

I have a Virtual Server. Till yesterday everything works fine on it.
Today my Hostcompany restarted my server to config something on I/O.
When I trying to get to my address I get
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
I tried to sudo service apache2 start and get these Error Message:
* Starting web server apache2
(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.
*
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
Does someone know how I can fix this problem?
Stop Nginx service nginx stop
Restart Apache service apache2 restart
You have another webserver that's running on the host (probably as part of the startup during the restart) You need to shut that off first.
You can run netstat -tulpn | grep :80 and that'll tell you what that process is
The problem is this, Nginx (another web server engine) it's using your port 80 so apache it's unable to start, a fast fix it turn of nginx and then restart apache.
You can do it with service nginx stop and service apache2 restart if you are using Ubuntu or Debian based release, if you are using an RHEL distro then use service nginx stop and service httpd restart
Here is my solution
first: sudo update-rc.d -f nginx remove
than: sudo rm /etc/init.d/nginx
after restarting VM almost everything works fine. Some strange thing is almost there.
When I goto www.myfoobarwebpage.com now apache is working and it's all ok!
When I goto myfoobarwebpage.com (without www.) I get "Welcome to nginx! ..."
Try this. My Apache config has 2 extra lines by mistake.
"Include conf/extra/httpd-8080.conf"
"Include conf/extra/httpd-8080.conf"
Therefore, it was saying address already in use because it already loaded the Virtual host once and was trying again.
Solution was to delete this extra line and have only one include.

How can I configure Virtual Host without restarting Apache web server?

I created a new virtual host in apache web server and I dont want to restart Apache
Does Anybody know How can I configure VirtualHost without restarting Apache web server?
Also Is it possible to do it on windows server?
this is not possible .... you have to restart the server to get new / changed vhost.
what you can do is: restart the server without kill any active connections by:
/etc/init.d/apache2 -graceful [*]
[*] /etc/init.d/apache2 is your executable file
You can reload apache2 for get affect newly changes.
$ sudo systemctl reload apache2