Categories
Tutorial

Keep first N lines of a log file with Cron

If you wish to keep first (top) N lines of a log file and delete the older lines, you can use this command with Cron:

echo "$(head -100 /home/user/public_html/log.txt)" > /home/user/public_html/log.txt

Categories
Tutorial

Keep last N lines of a log file with Cron

If you wish to keep last (bottom) N lines of a log file and delete the older lines, you can use this command with Cron:

echo "$(tail -100 /home/home/public_html/log.txt)" > /home/home/public_html/log.txt

Categories
Tutorial

How to configure YunoHost apps

Some apps require editing the config or .env file to configure app options.

Over YunoHost the app configutation files are usually located at:
/var/www/app_name/
or
/home/yunohost.app/app_name/

You can SFTP to that directory and edit the configuration file. Check out the app documention for the config file name and parameters.

After editing the config file, you may need to restart the app. For that, go to Tools > Services > App Name and then click on “Restart“.

Categories
Solution

FileRun: This software application is registered to a different server hostname

If you have registered your FileRun while running from one domain and then they to use it over another domain, you will get the error: This software application is registered to a different server hostname

To solve it, log into FileRun over the old domain, go to FileRun > License.
Then on top right, click on the “Unregister” link.

You can also remove the file system/data/.filerun.bin

Once unregistered, access FileRun from your new domain and register it again.

Categories
Tutorial

How to enable OpenLiteSpeed WebAdmin on CyberPanel

How to enable OpenLiteSpeed WebAdmin on CyberPanel: https://community.cyberpanel.net/t/tutorial-how-to-setup-and-login-to-openlitespeed-webadmin-console/14052

In short, run this command in ssh:
/usr/local/lsws/admin/misc/admpass.sh

If you are using any firewall, allow TCP 7080

Then access the OpenLiteSpeed WebAdmin by https://server.host.name:7080

Categories
Tutorial

How to install FFmpeg on CentOS cPanel server

How to install FFmpeg on CentOS cPanel server:

Step 1: Update the system
sudo yum install epel-release -y
sudo yum update -y

Step 2: Install the Nux Dextop YUM repo
There are no official FFmpeg rpm packages for CentOS for now. Instead, you can use a 3rd-party YUM repo, Nux Dextop, to finish the job.

On CentOS 7, you can install the Nux Dextop YUM repo with the following commands:

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

For CentOS 6, you need to install another release:

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm

Step 3: Install FFmpeg and FFmpeg development packages
sudo yum install ffmpeg ffmpeg-devel -y

Step 4: Test drive
Confirm the installation of FFmpeg:

ffmpeg

source: https://forums.cpanel.net/threads/ffmpeg-on-cpanel-server.478751/post-2519691

Categories
Tutorial

CyberPanel: Reverse Proxy to Docker Container

How to Reverse Proxy Traffic to Docker Container on CyberPanel:
https://community.cyberpanel.net/t/reverse-proxy-traffic-to-docker-container-on-cyberpanel/30644

Setup Reverse Proxy:
Open and edit: /usr/local/lsws/conf/httpd_config.conf

extprocessor dockerbackend {
  type                    proxy
  address                 127.0.0.1:8080
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

Here “dockerbackend” is a referance name to use later and “8080” is the docker container port.

Use Rewrite Rules to Proxy traffic to your Container:
Now create a website and create the following a .htaccess rewrite rule there.
REWRITERULE ^(.*)$ HTTP://dockerbackend/$1 [P]

If you want to force redirect SSL then use the following:

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ http://dockerbackend/$1 [P]
Categories
Tutorial

Change DirectAdmin user /home location

Say, you have added another drive (or slab) to your server (or vps) and want to create your user home directories to that location instead of /home

To achieve that, first mount your new drive (or slab) as /home2

Then go to /etc/defaut/useradd and set HOME=/home to HOME=/home2.

Categories
Tutorial

How to add swap on CentOS 7

If your vps does not come with swap, you can easily add swap to centos 7 following this guide: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7

Categories
Solution

Disable mod_pagespeed for a single user

If you need to disable mod_pagespeed for a single user or domain, you can do so simply by adding the following to .htaccess

<IfModule pagespeed_module>
    ModPagespeed off
</IfModule>

Works with cpanel, directadmin, centos, ubuntu, apache… anything!