Author Topic: How to start, stop, and restart Apache and Nginx Service from shell?  (Read 1730 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
I have tried to find help at google, but I cant find it.
My vps often down without clearly reason. It suddenly got load more than 10%, and then it got down. I dont see any unusual activity inside my vps.
I have made bash script to restart apache when the load get higher. But it didnt work.
So, please tell me how to restart the service for Mysql, Apache, Nginx, PHP-FPM from shell. And how to kill all PHP-cgi and PHP-FPM process from shell.

Thanks.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
****
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #1 on: February 15, 2022, 05:24:37 AM »
systemctl start | stop | restart <Servicename>

Apache  "  systemctl restart httpd   "
Nginx   " systemctl restart nginx   "
PHP-FPM   systemctl restart php-fpm71
               systemctl restart php-fpm72  ...  ETC for each version you have installed
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #2 on: February 15, 2022, 06:54:19 AM »
systemctl start | stop | restart <Servicename>

Apache  "  systemctl restart httpd   "
Nginx   " systemctl restart nginx   "
PHP-FPM   systemctl restart php-fpm71
               systemctl restart php-fpm72  ...  ETC for each version you have installed
Thanks for your help.
But I still wonder, why did my vps down while there is no high activity inside the vps. There is no high traffic site too. But it loads high until getting down. Is there anything I need to know beside restarting the service? I use VPS KVM. Is it possible that it is caused by another vps inside one machine with mine?

Thanks.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
****
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #3 on: February 15, 2022, 07:18:32 AM »
if you check your " top " command while it's high, you'll be able to see what program is using the resources (Most likely SQL ).

If it is indeed in a KVM container, there is very limited chance that another VPS is causing you issues with RAM/CP.  However, if the hardware at the server level hosting the KVM is failing for some reason, or they have too many vps's on a single raid, others could affect it.
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #4 on: February 15, 2022, 07:31:22 AM »
Dear rcschaff,

Thanks for your explanation. At my "top" command there is no high process. But it suddenly get higher and higher then it down. I have the CSF log when it get more than 10% load. But nothing CPU and or Memory consume high resources. Only amavis consume 16% of memory, but it is ok. I have 8Gb Memory. That is why I really confuse.
When it started get higher more than 5%, I run this command to show the highest cpu and memory usage:

Code: [Select]
ps -eo user,pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
But from the result there is nothing. CPU load just average 0.xx% and Memory too, just amavis consume 16%, but I'm sure it wont cause server down.
Ater that, the load get higher and higher so quickly, and vps down. I can access the vps through VNC and I can see it did not down, because the uptime still continuing.

Is it possible CSF Firewall cause high load without able to be monitored?

I use vps KVM from contabo.com. May be you or someone else know about this company.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
****
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #5 on: February 15, 2022, 08:02:16 AM »
Look at your inodes.   Probably not a RAM/Processor issue, as much as it's a harddrive issue waiting for read/writes.  One of the problems with using a VPS, is you don't know how they have it configured.  They could have 30 VPS's all using a standard hard disk, and KVM has to iwait read/writes to the disk.  If your VPS is really slow with no load, I would contact their support about the issue.
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #6 on: February 15, 2022, 08:08:24 AM »
Dear rcschaff,

Thanks. But how do I check the Inode? And is there anyway to check if the hard drive is not good? Sorry, I'm not too expert in Linux.
I have contacted contabo support too. Unfortunately, their support is very slow. The support is not 24/7, but working like normal working hour. So I have to wait 1 day because we have different time zone.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
****
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #8 on: February 15, 2022, 08:41:06 AM »
Hi,

Do you have the suggested tool among those five tools?
And which part I have to see for determining wheter the hard drive is good or not?

Thanks.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
****
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #9 on: February 15, 2022, 01:26:04 PM »
I would suggest picking one, and looking at the man pages for that specific tool.  If you find a problem, you will have to investigate using other tools to find out what the real problem is. 

However, if you have managed help, let them sort it out.
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: How to start, stop, and restart Apache and Nginx Service from shell?
« Reply #10 on: February 16, 2022, 02:59:36 AM »
I would suggest picking one, and looking at the man pages for that specific tool.  If you find a problem, you will have to investigate using other tools to find out what the real problem is. 

However, if you have managed help, let them sort it out.
Ok, thanks for your advise.
Since yesterday, my CWP keep sending alert like this: "monit alert -- Does not exist php-fpm73", then 5 minutes later, it send "monit alert -- Exist php-fpm73".
It happened every one hour. Whats wrong with that? Load server is fine. I have three PHP-FPM, and it has the same alert at the same time.
What should I check?

we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store