Category Archives: Mysql

Session timeout in Zorin OS Terminal

session timeout in Zorin Terminal

Session was geting auto logged off after 5 minutes of in-activity

journalctl -f showing below errors

pam_unix(cron:session): session opened for user root by (uid=0)

This was fixed by editing the file name /etc/pam.d/common-session-noninteractive

sudo vim /etc/pam.d/common-session-noninteractive

and adding new line

session [success=1 default=ignore] pam_succeed_if.so service in cron quiet use_uid

and restart crond

sudo service cron restart

This fixed the issue

Redirect from www to non www with https

To Redirect from www to now www with https follow below steps

open .htacess file and add below rule

Replace domain.tld with your domain name

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.tld [NC]
RewriteRule ^(.)$ http://domain.tld/$1 [L,R=301]

RewriteCond %{HTTPS} !=on

RewriteRule ^(.)$ https://%{HTTP_HOST}/$1 [L,R=301]

Change Postfix Mail IP address

Change postfix mail sending IP

To change mail IP in Postfix need to change parameters in below file

vi /etc/postfix/main.cf

add this option

smtp_bind_address=192.168.10.10

once done restart postfix

Installing Python 3.4 on cPanel

cPanel comes with Default version Python 2.7

If you want to install second version Python 3.4 on server using rpm and via Source

First install epel repository

yum install epel-release

yum install python34

To install PIP on python2.4

yum install python3-pip

Disable ProxyPass cpanel

You can disable the Proxypass from httpd.conf using below command

This issue occurs in live migration in cpanel to cpanel server

whmapi1 unset_all_service_proxy_backends username=cpanelusername

mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’

One of our server had Mysql failing to start on reboot with below error

tail -n 100 /var/log/mysqld.log
2022-03-08 3:53:37 0 [Note] Crash recovery finished.
2022-03-08 3:53:37 0 [Note] Server socket created on IP: ‘127.0.0.1’.
2022-03-08 3:53:37 0 [ERROR] mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2 “No such file or directory”)
2022-03-08 3:53:37 0 [ERROR] Can’t start server: can’t create PID file: No such file or directory
2022-03-08 3:58:38 0 [Note] InnoDB: Using Linux native AIO
2022-03-08 3:58:38 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

Solution to this was

Create a new folder mkdir -p /var/run/mysqld/

Chown mysql.mysql /var/run/mysqld/

[root@ok1146s1 run]# mkdir /var/run/mysqld
[root@ok1146s1 run]# chown mysql:mysql /var/run/mysqld/
[root@ok1146s1 run]# /scripts/restartsrv_mysql
Waiting for “mysql” to start ……waiting for “mysql” to initialize ………finished.

Service Status
mariadb (/usr/sbin/mysqld) is running as mysql with PID 5809 (systemd+/proc check method).

Startup Log
Mar 08 04:08:14 ok1146s1.kvchosting.com systemd[1]: Starting MariaDB 10.3.34 database server…
Mar 08 04:08:16 ok1146s1.kvchosting.com mysqld[5809]: 2022-03-08 4:08:16 0 [Note] /usr/sbin/mysqld (mysqld 10.3.34-MariaDB) starting as process 5809 …
Mar 08 04:08:17 ok1146s1.kvchosting.com systemd[1]: Started MariaDB 10.3.34 database server.

mysql started successfully.
[root@ok116s1 run]#

Service Unavailable

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

While accessing one of the website saw the error mentioned above

Normally this 503 error are related to module PHP-fpm.

You just need to restart it from WHM to fix the issue

PHP Fatal error: Uncaught Error: Call to undefined function wp()

This issue is due to some core files in wordpress being corrupt.

The solution to this issue is to download new version of wordpress and upload new files and folders mentioned below

wp-includes , wp-admin and below files

wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config.php
wp-config-sample.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php

This resolved the issue and wordpres site was working fine