Wednesday, April 18, 2018

RHEL7/CENTOS 7 custom apache on httpd.service


if httpd.service file is present then take backup  then add below line or else  if file not present  create a file httpd.service inside

 /usr/lib/systemd/system/httpd.service  and /usr/lib/systemd/httpd.service

add below parameter , i have installed my  Apache on /opt/apache2.2.34


[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=forking
#EnvironmentFile=/etc/sysconfig/httpd
PIDFile=/opt/apache2.2.34/logs/httpd.pid
ExecStart=/opt/apache2.2.34/bin/apachectl -k start
ExecStop=/opt/apache2.2.34/bin/apachectl -k stop
ExecReload=/opt/apache2.2.34/bin/apachectl  -k graceful
#ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
#KillSignal=SIGCONT
PrivateTmp=true
LimitNOFILE=infinity

[Install]

WantedBy=multi-user.target

run below command:-

#systemctl daemon-reload

test your script by running

# service httpd stop
#service httpd start

#chkconfig httpd on 

if script is  complaining that  it cannot bind the port  80 or 443 kill or stop the apache running and test the script once again.

No comments:

curl and cacert

curl -v --cacert cacert.pem https://www.example/cgi-bin/f ile.xgi -I -X POST