Author Topic: Cwppro - Huge log files in  (Read 9879 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Cwppro - Huge log files in
« on: November 18, 2020, 05:46:38 PM »
in /usr/local/apache/domlogs I saw some huge logs. I deleted them and after 24 hours I again see logs around 300GBs (server full  :P)

How can I put a size limit to this or tie them with the users quota space?

Thank you.

Offline
*
Re: Cwppro - Huge log files in
« Reply #1 on: November 18, 2020, 06:52:29 PM »
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?

Re: Cwppro - Huge log files in
« Reply #2 on: November 18, 2020, 10:59:32 PM »
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?
You read/learn about logrotate and CWP even provide you with a GUI to configure.

Offline
*
Re: Cwppro - Huge log files in
« Reply #3 on: November 19, 2020, 09:33:04 AM »
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?

Are you using wordpress or similar software on your website?

If so, you may be getting this error due to the plugins you use on your website.

Recently, 150 GB of log file of one of our customers had accumulated due to the YOAST extension.

After deleting the log file, follow it instantly, the records to be written to the file will be useful for solution.

Offline
*
Re: Cwppro - Huge log files in
« Reply #4 on: November 19, 2020, 04:05:03 PM »
So I found a semi solution here http://forum.centos-webpanel.com/index.php?topic=6156.0
But the question still stands How can I put a size limit to this or tie them with the users quota space?
You read/learn about logrotate and CWP even provide you with a GUI to configure.

Thank you for the answer, thats what I did, but it is not logical for this to happen in the first place. (it does not happen with other panels for example).

Logs should be moved inside users directories (so each user should be responsible for his space) and their size should be contained with the installation of cwp.
What if a user creates huge logfiles on purpuse in minutes? Logrotate cannot help you (in my knowleage) in this case and a user can destroy the whole server.

I think yoast or user activity monitor caused the issue.

Re: Cwppro - Huge log files in
« Reply #5 on: November 19, 2020, 07:51:41 PM »
So you haven't used open_basedir protection? Otherwise, other panels are the same, IIRC.

Offline
*
Re: Cwppro - Huge log files in
« Reply #6 on: November 20, 2020, 02:23:58 PM »
No I have not. I supposed that its enabled by default.
I could not find any option for this in the panel. Only this article.
https://wiki.centos-webpanel.com/php-open_basedir
So I will have to manually create the php file for each user? Thats .... extreme :D

Re: Cwppro - Huge log files in
« Reply #7 on: November 20, 2020, 02:53:24 PM »
Engage brain and use lateral thinking..
Adapt:
Code: [Select]
#!/usr/bin/bash
for i in /home/*
 do
  cp /root/restricted-php.ini /home/$i/php.ini
 done

Offline
*
Re: Cwppro - Huge log files in
« Reply #8 on: November 20, 2020, 03:44:13 PM »
much wow, very thanx.

Just for reference
Code: [Select]
cd
Code: [Select]
nano phpopenbasedir
Code: [Select]
#!/usr/bin/bash
for i in /home/*
 do
   FILE=$i/php.ini
   if [[ -f "$FILE" ]]; then
     echo "$FILE exists."
   else
     echo "open_basedir = $i/:/tmp:/var/tmp:/usr/local/lib/php/" > $i/php.ini
     chown root.root $i/php.ini
     chmod 555 $i/php.ini
   fi
 done

(I did not need the second home in "/home/$i/php.ini)

Code: [Select]
chmod +x phpopenbasedir
Now I need a way to run this at every account creation.

PS. Unfortunately phpinfo() shows open_basedir as empty. Maybe its because I have chosen in cwp the nginx, apache, varnish option with the php-fpm option forced?
« Last Edit: November 20, 2020, 04:11:13 PM by Orlox »

Re: Cwppro - Huge log files in
« Reply #9 on: November 20, 2020, 05:22:17 PM »
(I did not need the second home in "/home/$i/php.ini)

Code: [Select]
chmod +x phpopenbasedir
...
PS. Unfortunately phpinfo() shows open_basedir as empty. Maybe its because I have chosen in cwp the nginx, apache, varnish option with the php-fpm option forced?
You should/must put the full path in, otherwise i will create the files relative to your current path and likely fail.
You're not making it clear where your storing the script. ;)
I don't use that web stack so won't comment on that.
« Last Edit: November 20, 2020, 05:24:47 PM by cynique »

Offline
*
Re: Cwppro - Huge log files in
« Reply #10 on: November 20, 2020, 05:49:58 PM »
Thank you for taking interest on a noob.
I think, the files where created where they should have been:
Code: [Select]
[root@srv ~]# ./phpopenbasedir
/home/byron/php.ini exists.
/home/Byron/php.ini exists.
/home/chalioti/php.ini exists.
/home/estudy1n/php.ini exists.
/home/jfoundis/php.ini exists.
and
Code: [Select]
[root@srv ~]# cat /home/byron/php.ini
open_basedir = /home/byron/:/tmp:/var/tmp:/usr/local/lib/php/

I think there is an issue with fpm and php.ini / .user.ini

Someone else also reported it at http://forum.centos-webpanel.com/index.php?topic=294.0

I think the fpm simply is not reading the php.ini from inside the users root directory.

PS. You are already setting the full path for i at /home/ thats why it is not needed. If you use it as you have written it will produce a "/home/home/username....".

Re: Cwppro - Huge log files in
« Reply #11 on: November 20, 2020, 06:04:59 PM »
Ahh, it's prepending from the directory listing - gotcha.
PHP-FPM ignores php.ini and uses .user.ini
Risky, though it will just take the last entry, if one exists
Code: [Select]
echo "open_basedir = $i/:/tmp:/var/tmp:/usr/local/lib/php/" >> $i/.user.ini


Offline
*
Re: Cwppro - Huge log files in
« Reply #12 on: November 20, 2020, 06:33:41 PM »
Unfortunately it is the same for .user.ini.
The only way i could affect the php info is to put the open_basedir= /home:/tmp:/var/tmp:/usr/local/lib/php/
inside /opt/alt/php-fpm73/usr/php/php.ini using the cwp php.ini editor from "PHP FPM SELECTOR" menu and reloading php-fpm

Re: Cwppro - Huge log files in
« Reply #13 on: November 20, 2020, 08:03:44 PM »
Have you been remembering to restart all the services; Apache/ngix/Varnish/PHP?
Code: [Select]
open_basedir= /home:/tmp:/var/tmp:/usr/local/lib/php/.. is not great as it allows users access above the level that they should have access to.
Try
Code: [Select]
open_basedir= ~/:/tmp:/var/tmp:/usr/local/lib/php/Note: I have NOT tested this.

https://serverfault.com/questions/431200/how-to-add-an-open-basedir-path-in-nginx-vhost
« Last Edit: November 20, 2020, 08:10:01 PM by cynique »

Re: Cwppro - Huge log files in
« Reply #14 on: November 21, 2020, 10:32:45 AM »
@Oriox
See @Studio4host comprehensive reply to:
http://forum.centos-webpanel.com/index.php?topic=294.msg34521