Wednesday, March 31, 2021

How to install JDK on linux

 Login to the server

wget https://files-cdn.liferay.com/mirrors/download.oracle.com/otn-pub/java/jdk/8u121-b13/jdk-8u121-linux-x64.rpm

rpm -ivh jdk-8u121-linux-x64.rpm

java -version

vi /etc/profile.d/java.sh

#!/bin/bash

JAVA_HOME=/usr/java/jdk1.8.0_121/

PATH=$JAVA_HOME/bin:$PATH

export PATH JAVA_HOME

export CLASSPATH=.


chmod +x /etc/profile.d/java.sh

source /etc/profile.d/java.sh

java -version

Wednesday, March 24, 2021

How to check which users logged and its time in linux server

 Someone in the server deleted a file. I need to know which user logged in also I need the IP


cat /var/log/secure | grep Accepted | awk '{print $1,$2,$3,$6,$11}'

Mar 22 03:52:19 Accepted 157.49.207.225

Mar 22 04:23:55 Accepted 202.83.59.155

Friday, March 12, 2021

Auto redirection of urls from http to https

Normally when a site is enabled with SSL, we need to auto redirect urls from http to https

Go to your web site's default document root folder.

Open your .httaccess file or create one ( I assume mod redirect is enabled in your web server)

Paste the below code.

RewriteEngine On 
RewriteCond %{HTTPS}  !=on 
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 

Test your domain without http, it will automatically redirect to https

Wednesday, February 10, 2021

The server requested authentication method unknown to the client

 Mysql Version : 8.0.23

PHP version : 5.6.40

CentOS Linux release 7.9.2009 (Core)

Take a backup of /etc/my.cnf

[mysqld]

default_authentication_plugin= mysql_native_password

Restart Mysql service

systemctl restart mysqld

Login to Mysql root prompt

alter user 'user'@'localhost' identified with mysql_native_password by 'your_password';

After this, if you get an error "If it is FULL_GROUP_GROUP_BY exist, then we need to disable it:"

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Failed to connect to MySQL: Server sent charset unknown to the client. Please, report to the developers

 Mysql Version : 8.0.23

PHP version : 5.6.40

CentOS Linux release 7.9.2009 (Core)


Take a backup of /etc/my.cnf

[mysqld]

character-set-server=utf8

Restart MysQl service

systemctl restart mysqld


Saturday, September 26, 2020

fwrite() expects parameter 1 to be resource, bool given in

Sometimes in Opencart you may get these kind of warnings in browser.

fwrite() expects parameter 1 to be resource, bool given in /var/www/html

Solution to fix:
Check your selinux status, if selinux is enabled, you need to disable selinux and reboot the machine.

Saturday, September 5, 2020

How to restrict wp-admin access from one IP

 How to restrict wp-admin access from one IP

As you know, wordpress is a easy to hack content management system. If you want to restric the admin area of your wordress (wp-admin), you can easily do this by adding the below line in .htaccess

Go to the folder where your blog hosts

vi .htaccess

<IfModule mod_rewrite.c>

<Files wp-login.php>

order deny,allow

deny from all

allow from 121.15.102.0/255.255.255.0    (Add your IP or range here)

</Files>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

Save the file and test.