Step 1) Login as root and create httpd.service file
[root@webserverhost ~]# cd /etc/systemd/system/
[root@webserverhost system]# cat>httpd.service
[Unit]
Description=Apache httpd service
After=network.target
[Service]
User=osboxes
Group=osboxes
Type=oneshot
ExecStart=/home/osboxes/instances/apache24/poc-instance/bin/apachectl start
ExecStop=/home/osboxes/instances/apache24/poc-instance/bin/apachectl stop
PIDFile=/home/osboxes/logs/apache24/poc-instance/httpd.pid
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Step 2) Reload systemctl daemon
[root@webserverhost system]# systemctl daemon-reload
Step 3) Enable httpd service
[root@webserverhost system]# systemctl enable httpd
Step 4) Start httpd service
[root@webserverhost system]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
Looks like the service is not started check the status and find out the error
[root@webserverhost system]# systemctl status httpd.service
● httpd.service - Apache httpd service
Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2021-02-13 01:10:17 EST; 54s ago
Process: 2217 ExecStart=/home/osboxes/instances/apache24/poc-instance/bin/apachectl start (code=exited, status=203/EXEC)
Main PID: 2217 (code=exited, status=203/EXEC)
Feb 13 01:10:17 webserverhost systemd[1]: Starting Apache httpd service...
Feb 13 01:10:17 webserverhost systemd[1]: httpd.service: Main process exited, code=exited, status=203/EXEC
Feb 13 01:10:17 webserverhost systemd[1]: httpd.service: Failed with result 'exit-code'.
Feb 13 01:10:17 webserverhost systemd[1]: Failed to start Apache httpd service.
[root@webserverhost system]# journalctl -xe
Feb 13 01:04:01 webserverhost su[2069]: pam_unix(su-l:session): session opened for user root by osboxes(uid=0)
Feb 13 01:07:38 webserverhost systemd[1]: Reloading.
Feb 13 01:08:00 webserverhost systemd[1]: Starting dnf makecache...
-- Subject: Unit dnf-makecache.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit dnf-makecache.service has begun starting up.
Feb 13 01:08:02 webserverhost dnf[2161]: Metadata cache refreshed recently.
Feb 13 01:08:02 webserverhost systemd[1]: Started dnf makecache.
-- Subject: Unit dnf-makecache.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit dnf-makecache.service has finished starting up.
--
-- The start-up result is done.
Feb 13 01:08:32 webserverhost systemd[1]: Reloading.
Feb 13 01:10:17 webserverhost systemd[1]: Starting Apache httpd service...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit httpd.service has begun starting up.
Feb 13 01:10:17 webserverhost systemd[2217]: httpd.service: Failed to execute command: Permission denied
Feb 13 01:10:17 webserverhost systemd[2217]: httpd.service: Failed at step EXEC spawning /home/osboxes/instances/apache24/poc-instance/bin/apachectl: Permis>
-- Subject: Process /home/osboxes/instances/apache24/poc-instance/bin/apachectl could not be executed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The process /home/osboxes/instances/apache24/poc-instance/bin/apachectl could not be executed and failed.
--
-- The error number returned by this process is 13.
Feb 13 01:10:17 webserverhost systemd[1]: httpd.service: Main process exited, code=exited, status=203/EXEC
Feb 13 01:10:17 webserverhost systemd[1]: httpd.service: Failed with result 'exit-code'.
Feb 13 01:10:17 webserverhost systemd[1]: Failed to start Apache httpd service.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Feb 13 01:10:20 webserverhost dbus-daemon[748]: [system] Activating service name='org.fedoraproject.Setroubleshootd' requested by ':1.20' (uid=0 pid=712 com>
Feb 13 01:10:20 webserverhost dbus-daemon[2221]: [system] Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Faile>
Feb 13 01:10:22 webserverhost dbus-daemon[748]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd'
Feb 13 01:10:27 webserverhost setroubleshoot[2221]: SELinux is preventing (pachectl) from execute access on the file apachectl. For complete SELinux message>
Feb 13 01:10:27 webserverhost platform-python[2221]: SELinux is preventing (pachectl) from execute access on the file apachectl.
***** Plugin catchall (100. confidence) suggests **************************
If you believe that (pachectl) should be allowed execute access on the apachectl file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c '(pachectl)' --raw | audit2allow -M my-pachectl
# semodule -X 300 -i my-pachectl.pp
Step 5) SELinux is preventing apache startup so disable selinux and try restart
[root@webserverhost system]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@webserverhost system]# grep -w ^SELINUX /etc/selinux/config
SELINUX=disabled
Step 6) reboot the machine
[root@webserverhost system]# init 6
Step 7) Check the status of your httpd instance
[osboxes@webserverhost ~]$ ps -ef | grep httpd
osboxes 936 1 0 01:37 ? 00:00:00 /home/osboxes/instances/apache24/poc-instance/bin/httpd -k start
osboxes 940 936 0 01:37 ? 00:00:00 /home/osboxes/instances/apache24/poc-instance/bin/httpd -k start
osboxes 942 936 0 01:37 ? 00:00:00 /home/osboxes/instances/apache24/poc-instance/bin/httpd -k start
osboxes 943 936 0 01:37 ? 00:00:00 /home/osboxes/instances/apache24/poc-instance/bin/httpd -k start
No comments:
Post a Comment