Apache does not run - apache

I have a Centos 7 server with the names of one to play and another to use with Apache. Everything works correctly until I enable https for both domains. As of this moment, apache will not know if you have enabled the gitlab server.
-I get the following to the journalctl -xe exercise:
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID 1806 has been created for the user root.
--
-- The leading process of the session is 21782.
sep 25 17:54:07 centOS sshd[21782]: pam_unix(sshd:session): session opened for user root by (uid=0)
sep 25 17:54:07 centOS systemd[1]: Started Session 1806 of user root.
-- Subject: Unit session-1806.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-1806.scope has finished starting up.
--
-- The start-up result is done.
sep 25 17:54:07 centOS systemd[1]: Starting Session 1806 of user root.
-- Subject: Unit session-1806.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-1806.scope has begun starting up.
sep 25 17:54:32 centOS polkitd[488]: Registered Authentication Agent for unix-process:21855:10383292 (system bus name :1.3661 [/usr/bin/pkttyagent --notify-fsep 25 17:54:32 centOS systemd
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
sep 25 17:54:32 centOS httpd[21861]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
sep 25 17:54:32 centOS httpd[21861]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
sep 25 17:54:32 centOS httpd[21861]: no listening sockets available, shutting down
sep 25 17:54:32 centOS httpd[21861]: AH00015: Unable to open logs
sep 25 17:54:32 centOS systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
sep 25 17:54:32 centOS kill[21863]: kill: cannot find process ""
sep 25 17:54:32 centOS systemd[1]: httpd.service: control process exited, code=exited status=1
sep 25 17:54:32 centOS systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
sep 25 17:54:32 centOS systemd[1]: Unit httpd.service entered failed state.
sep 25 17:54:32 centOS systemd[1]: httpd.service failed.
sep 25 17:54:32 centOS polkitd[488]: Unregistered Authentication Agent for unix-process:21855:10383292 (system bus name :1.3661, object path /org/freedesktoplines 5302-5347/5347 (END)

It looks like that the port 80 is already in use from an other application. Go to your httpd.conf file in Apache and try to change to port Listen 80 just to find out if thats the issue. Tell me if this works.
Change from:
Listen 80
ServerName localhost:80
To:
Listen 8012
ServerName localhost:8012
Enter: http://localhost:8012 in browser to check if this works for you.

Related

haproxy.service start failed when I set up load balancer on the same machine which serves the website [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
I have 2 machines
192.46.209.80 # server1
192.46.209.82 # server2
I was setting up HAProxy load balancer on the same machine server1 which is also serving my website.
So now server1 will be running HAProxy as well as the webserver.
I setup Apache2 and HAProxy according to this tutorial
On 192.46.209.80 server1 this is my hosts file
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
HAproxy 192.46.209.80
192.46.209.80 HAProxy
192.46.209.80 server1
192.46.209.82 server2
On 192.46.209.82 server2 this is my hosts file
127.0.0.1 localhost
The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
HAproxy 192.46.209.80
then after installing HAProxy on server1
sudo sudo apt install haproxy
I edited and appended in sudo nano /etc/haproxy/haproxy.cfg
#HAProxy for web servers
frontend web-frontend
bind 192.46.209.80:80
mode http
default_backend web-backend
backend web-backend
balance roundrobin
server server1 192.46.209.80 check port 80
server server2 192.46.209.82 check port 80
After running
sudo systemctl restart haproxy.service
I am getting error
Job for haproxy.service failed because the control process exited with error code.
See "systemctl status haproxy.service" and "journalctl -xe" for details.
This is the result of journalctl -xe
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit haproxy.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Oct 19 14:13:18 localhost systemd[1]: haproxy.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit haproxy.service has entered the 'failed' state with result 'exit-code'.
Oct 19 14:13:18 localhost systemd[1]: Failed to start HAProxy Load Balancer.
-- Subject: A start job for unit haproxy.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit haproxy.service has finished with a failure.
--
-- The job identifier is 6245 and the job result is failed.
Oct 19 14:13:18 localhost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit haproxy.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Oct 19 14:13:18 localhost systemd[1]: Stopped HAProxy Load Balancer.
-- Subject: A stop job for unit haproxy.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit haproxy.service has finished.
--
-- The job identifier is 6314 and the job result is done.
Oct 19 14:13:18 localhost systemd[1]: haproxy.service: Start request repeated too quickly.
Oct 19 14:13:18 localhost systemd[1]: haproxy.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit haproxy.service has entered the 'failed' state with result 'exit-code'.
Oct 19 14:13:18 localhost systemd[1]: Failed to start HAProxy Load Balancer.
-- Subject: A start job for unit haproxy.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit haproxy.service has finished with a failure.
--
-- The job identifier is 6314 and the job result is failed.
Since my Apache web server is listening on Port 80, therefore I cannot configure the same for my HAProxy.
Changed it to another port and it worked.
frontend web-frontend
bind 192.46.209.80:541
mode http
default_backend web-backend
backend web-backend
balance roundrobin
server server1 192.46.209.80 check port 80
server server2 192.46.209.82 check port 80

Cant's start Apache2

I reinstall Apache2 and if I type sudo systemctl status apache2 it goes
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Thu 2021-09-30 10:31:41 KST; 1min 30s ago
Main PID: -- (code=exited, status=0/SUCCESS)
9월 30 10:31:41 -- systemd[1]: Starting The Apache HTTP Server...
9월 30 10:31:41 -- apachectl[30008]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
9월 30 10:31:41 -- apachectl[30008]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
9월 30 10:31:41 -- apachectl[30008]: no listening sockets available, shutting down
9월 30 10:31:41 -- apachectl[30008]: AH00015: Unable to open logs
9월 30 10:31:41 -- apachectl[30008]: Action 'start' failed.
9월 30 10:31:41 -- apachectl[30008]: The Apache error log may have more information.
9월 30 10:31:41 -- systemd[1]: apache2.service: Control process exited, code=exited status=1
9월 30 10:31:41 -- systemd[1]: apache2.service: Failed with result 'exit-code'.
9월 30 10:31:41 -- systemd[1]: Failed to start The Apache HTTP Server.
I already tried remove and reinstall by sudo apt-get purge apache2 and sudo apt-get install apache2 but it keep says failed...
Please help me.
Thank you.
I installed nextcloud by snap which is why i couldn't delete 80 port. After i tried sudo snap remove nextcloud i could restart apache2.

Apache2 on starts then immediately fails on debian9

when starting Apache2 on my debian 9 (stretch) it starts then immediately fails.
there is nothing in the error log.
the syslog says this.
Aug 4 11:56:31 debian systemd[1]: Starting The Apache HTTP Server...
Aug 4 11:56:38 debian systemd[1]: Started The Apache HTTP Server.
Aug 4 11:56:38 debian systemd[1]: apache2.service: Main process exited, code=killed, status=11/SEGV
Aug 4 11:56:38 debian apachectl[2414]: httpd (no pid file) not running
Aug 4 11:56:38 debian systemd[1]: apache2.service: Unit entered failed state.
Aug 4 11:56:38 debian systemd[1]: apache2.service: Failed with result 'signal'.
Aug 4 11:56:38 debian systemd[1]: apache2.service: Service hold-off time over, scheduling restart.
Aug 4 11:56:38 debian systemd[1]: Stopped The Apache HTTP Server.
Any have any ideas on how I can trace exactly what is causing my server to shut down.
I have done a conf test and all confs are fine.
Can you send the result the command below? Maybe if it fail show something more.
# service apache2 status
Well, if you see the port number, you can check any possible conflicts.
Try the command:
# lsof -i :"port_number"
"port_number" must be the port your apache service are using. This command will listing the programs that are use it. If there is another than apache2, you find the problem. Stop the other one service or program and restart apache2.
If the port that apache2 is free, and the error continue, show the content of status of apache2 service.

404 Not Found on previously working website

I previously had a website that I was hosting personally on a ubuntu server 16.04 LTS, sort of just a project to show that I knew what I was doing. (Turns out I don't have a clue!)
The site was/is structured such that I have a landing page located in /var/www/html. a second directory located in /var/www/agv-guru and a third directory located in /var/www/owncloud/.
I have an alias set up for both owncloud and the agv-guru folder and everything was working properly for months.
For whatever reason I decided that instead of having a separate server (raspberry-pi) running pi-hole, I would go ahead and install it on my existing server. I quickly realized that my website was down and I un-installed Pi-Hole, which may or may not have made matters worse.
I'm looking for help troubleshooting this one as I am not entirely sure whats going on.
Here is what i know so far.
The folders are still located in the same directory just like before.
The folders are owned by www-data.
The Document Root is /var/www/html.
The Alias is still set up for both agv-guru and owncloud.
/var/www/html/index.html still runs as normal with the exception of one photo not loading that was being pulled from the agv-guru folder.
Webserver is Apache2
Edit 1.
I just cleared the logs hoping to just reload the service but I get an error.
usr#Server:/var/log/apache2# service apache2 reload
apache2.service is not active, cannot reload.
So I ran the status as shown below.
usr#Server:/var/log/apache2# service apache2 status
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: inactive (dead) since Tue 2017-10-17 22:16:29 CDT; 58s ago
Docs: man:systemd-sysv-generator(8)
Process: 14594 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 14577 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
Oct 17 22:16:29 Server apache2[14577]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Oct 17 22:16:29 Server apache2[14577]: no listening sockets available, shutting down
Oct 17 22:16:29 Server apache2[14577]: AH00015: Unable to open logs
Oct 17 22:16:29 Server apache2[14577]: Action 'start' failed.
Oct 17 22:16:29 Server apache2[14577]: The Apache error log may have more information.
Oct 17 22:16:29 Server apache2[14577]: *
Oct 17 22:16:29 Server apache2[14594]: * Stopping Apache httpd web server apache2
Oct 17 22:16:29 Server apache2[14594]: *
Oct 17 22:16:29 Server systemd[1]: Started LSB: Apache2 web server.
Oct 17 22:16:36 Server systemd[1]: apache2.service: Unit cannot be reloaded because it is inactive.
Edit 2
sudo netstat -natp | grep ':80.*LISTEN'
Yields
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
1636/lighttpd
Solution
With sborsky's help the solution was found.
When installing pi-hole lighttpd was also installed. This webserver was occupying the port preventing apache from running.

apache not starting and does not have proper message on logs

I have tried to configure apache using puppet. When I try to start apache it is failing with out any proper error message. I am not figure out why it is failing. I tried executing the below commands it just say failed to start and does not show any specific reason why it failed to start. Could you please let me know how to figure out what is happening? I am attaching my log file below.
systemctl status httpd.service
journalctl -xe
Aug 15 22:56:03 hostname systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Aug 15 22:56:03 hostname httpd[18999]: no listening sockets available, shutting down
Aug 15 22:56:03 hostname httpd[18999]: AH00015: Unable to open logs
Aug 15 22:56:03 hostname systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Aug 15 22:56:03 hostname kill[19001]: kill: cannot find process ""
Aug 15 22:56:03 hostname audispd[414]: node=hostname type=SERVICE_START msg=audit(1471316163.292:57410): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=
Aug 15 22:56:03 hostname systemd[1]: httpd.service: control process exited, code=exited status=1
Aug 15 22:56:03 hostname systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Aug 15 22:56:03 hostname systemd[1]: Unit httpd.service entered failed state.
Aug 15 22:56:03 hostname systemd[1]: httpd.service failed.
Aug 15 22:56:03 hostname polkitd[532]: Unregistered Authentication Agent for unix-process:18984:32063862 (system bus name :1.15792, object path /org/freedesktop/P
I think your best hint is
Aug 15 22:56:03 hostname httpd[18999]: no listening sockets available, shutting down
Looks like another process is listening on the socket that tomcat is trying to listen on, which is 8080 by default or you can check conf to see what is set
You can use command like
lsof -i TCP |grep 8080
To get process id of what is listening on that port and track it down in top or whatever
I was able to figure out the problem, the default configuration of puppet has commented out the listen port in httpd.conf and added a port.conf. But as i have not explicitly configured the listen port, apache did not had a default port to listen. I have configured the port and it started working.