LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   CentOS 7 - httpd and systemd problem! (https://www.linuxquestions.org/questions/centos-111/centos-7-httpd-and-systemd-problem-4175538543/)

masterross 03-31-2015 05:54 AM

Installing Apache, php, Mysql from source and systemd?
 
Hi,

Till now I used CentOS 6.x with SysV and there wasnt prob with services.
But in CentOS 7.x is used Systemd and I dont know how to setup services for Apache, php, Mysql installed from source.
Can you guide me plz?

Thx!

sag47 03-31-2015 08:40 PM

Why not install them via package management? systemd supports SysV scripts in /etc/init.d as well. Otherwise, see the man pages (man systemd) and look to the "See also" sections for references to other man pages and man page levels for further reading.

John VV 04-01-2015 01:23 AM

use yum to install the software group

Code:

su -
yum grouplist
---- then from that list it should be ----
yum groupinstall "web server"


masterross 04-01-2015 11:02 AM

I dont want want to use versions of apps supplied by yum.
I want specific versions. Thats why I compiled from source but this systemd makes my crasy!

John VV 04-01-2015 12:49 PM

then use slack or LFS
you are using CentOS ( aka RHEL) for a reason
it is DEAD STABLE and almost never crashes
it is very WELL tested and very stable AND DOSE NOT CRASH


have you read the redhat documentation
https://access.redhat.com/documentat...h_systemd.html

you will have to manually make the needed files

TobiSGD 04-01-2015 01:54 PM

Most server software nowadays comes with .service files for systemd, just copy them to /etc/systemd/system and enable them using systemctl. Alternatively, use the distribution provided .service files, you can extract them from the respective RPMs.

masterross 04-01-2015 02:55 PM

Hi TobiSGD,

Thx for reply.
I've already did that.
I put tthe httpd.service and edited to point to binaries.
Enabled the service.
But I still cant start the service via systemctl

TobiSGD 04-02-2015 08:32 AM

Which error messages do you get?

masterross 04-02-2015 10:07 AM

CentOS 7 - httpd and systemd problem!
 
Hi guys.

I have problems with Apache v2.2.29 build from source and systemd.
My /usr/lib/systemd/system/httpd.service

Quote:

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/apache2/logs/httpd.pid
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/local/apache2/bin/apachectl start
ExecStop=/usr/local/apache2/bin/apachectl graceful-stop
ExecReload=/usr/local/apache2/bin/apachectl graceful

# 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

[Install]
WantedBy=multi-user.target
I can start it via systemctl stop httpd.service
But the web server is not available trough internet.

systemctl status httpd.service gives:

Quote:

httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Thu 2015-04-02 17:53:04 EEST; 1min 45s ago
Process: 18354 ExecStop=/usr/local/apache2/bin/apachectl graceful-stop (code=exited, status=0/SUCCESS)
Process: 18398 ExecStart=/usr/local/apache2/bin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 18401 (httpd)
CGroup: /system.slice/httpd.service
18401 /usr/local/apache2/bin/httpd -k start
18402 /usr/local/apache2/bin/httpd -k start
18403 /usr/local/apache2/bin/httpd -k start
18404 /usr/local/apache2/bin/httpd -k start
18405 /usr/local/apache2/bin/httpd -k start
18406 /usr/local/apache2/bin/httpd -k start
18407 /usr/local/apache2/bin/httpd -k start
18408 /usr/local/apache2/bin/httpd -k start
18409 /usr/local/apache2/bin/httpd -k start
18410 /usr/local/apache2/bin/httpd -k start
18411 /usr/local/apache2/bin/httpd -k start
18412 /usr/local/apache2/bin/httpd -k start
18413 /usr/local/apache2/bin/httpd -k start
18414 /usr/local/apache2/bin/httpd -k start
18415 /usr/local/apache2/bin/httpd -k start
18416 /usr/local/apache2/bin/httpd -k start
18417 /usr/local/apache2/bin/httpd -k start
18418 /usr/local/apache2/bin/httpd -k start
18419 /usr/local/apache2/bin/httpd -k start
18420 /usr/local/apache2/bin/httpd -k start
18421 /usr/local/apache2/bin/httpd -k start
18422 /usr/local/apache2/bin/httpd -k start
18423 /usr/local/apache2/bin/httpd -k start
18424 /usr/local/apache2/bin/httpd -k start
18425 /usr/local/apache2/bin/httpd -k start
18426 /usr/local/apache2/bin/httpd -k start
18459 /usr/local/apache2/bin/httpd -k start
18460 /usr/local/apache2/bin/httpd -k start
18461 /usr/local/apache2/bin/httpd -k start
18462 /usr/local/apache2/bin/httpd -k start
18463 /usr/local/apache2/bin/httpd -k start
18464 /usr/local/apache2/bin/httpd -k start
18467 /usr/local/apache2/bin/httpd -k start
18468 /usr/local/apache2/bin/httpd -k start
18471 /usr/local/apache2/bin/httpd -k start
18472 /usr/local/apache2/bin/httpd -k start
18473 /usr/local/apache2/bin/httpd -k start
18476 /usr/local/apache2/bin/httpd -k start
18477 /usr/local/apache2/bin/httpd -k start
18478 /usr/local/apache2/bin/httpd -k start
18479 /usr/local/apache2/bin/httpd -k start

Apr 02 17:53:04 m018 systemd[1]: PID file /usr/local/apache2/logs/httpd.pid not readable (yet?) after start.
Apr 02 17:53:04 m018 systemd[1]: Started The Apache HTTP Server.
Is it possible the service cant read httpd.conf?
And where should be set the path to httpd.conf?
Couse if I start it with:
/usr/local/apache2/bin/apachectl start

Apache starts w/o problem and all is OK.

Waiting for your hints guys.

Edit1:
Actually the web is working but cant connect to mysql when is started with systemctl
Mysql is again build from source
Still investigating...

Edit2:
Just saw in phpinfo (when started with systemctl) that a lot things missing from Environment section.

masterross 04-02-2015 10:13 AM

Hi

I have little progress after reading about 200 pages but still have probs.
Thats why I made a new thread in CentOS forum:
http://www.linuxquestions.org/questi...em-4175538543/

kmhuntly 04-02-2015 01:41 PM

Systemd runs as root so its likely able to read the apache configuration fine. Is the pidfile directive in the service configuration the same as in httpd configuration?

For MySQL, what errors are seen? Are you able to connect to the DB on the command line from the same system?

masterross 04-02-2015 02:41 PM

Hi mate,

I'm not sure why it gives warning about pidfile but httpd start/reboot/stop ok with systemd.
Now the problem with mysql still exist.
When httpd is ran via systemd I see environment that mysql missing from the PATH:
Quote:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
And when stared directly via /usr/local/apache2/bin/apachectl mysql exist in the env PATH:
Quote:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin
So I guess path to mysql binaries should be added somewhere?

Thx!

masterross 04-03-2015 04:12 AM

I tried add export PATH=$PATH:/usr/local/mysql/bin
to
/usr/lib/systemd/system/httpd.service

But still I'm getting:
Connection failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Quote:

mysql> show variables like 'socket%';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
1 row in set (0.00 sec)

masterross 04-04-2015 05:06 AM

Anyone?

kmhuntly 04-05-2015 11:16 AM

Sorry I've been away sick... so very sick.

Couple things to check:

Is the socket actually in that location? Seems a little off to me, usually under /var/run/mysql

If it is there, is it readable by the user that runs Apache?


All times are GMT -5. The time now is 09:08 AM.