fbpx

Archive

How to install DirectAdmin on Centos 8

I decided to install DirectAdmin on Centos8 for my new server. I bought a new license and SSL Certificate too. I have been using DirectAdmin on my Centos 7 server for a few years and I love it. As you know Centos EOL is 2024 it is not soon but still I want to use newer OS system so that is why I choose to install DirectAdmin on Centos 8.

 

This guide covers general steps to install DirectAdmin on Centos 8. If you have any questions regarding the steps just contact me on discord. (Bottom of the page)

 

I freshly installed Centos 8 on my VDS server. I set up my hostname during installation still need to check the server hostname.

Command to chek server hostanme

 

uname -n
hostname

 

Here is the output from my server:+

 

Seems right. Lets move on.

 

Make sure your domain hostname is the same one you got the DirectAdmin license for. If it is not you can change it with this command:

 

hostnamectl set-hostname hostname.yourdomain.com

After that you can verify if you corrently change it with this command:

hostnamectl status

 

After that let’s update our Centos 8 Server because we just installed it.

Command to update server

yum update -y

 

After the update is finished, please follow these steps to add these repositories. We need them for the new version of PHP 7.4 and Memcached extension. Also, you can follow these commands to enable PowerTools On your centos 8 servers.

yum clean all
yum -y install yum-utils wget gcc gcc-c++ flex bison make perl-libwww-perl perl-DBI bind bind-libs bind-utils libaio libcom_err-devel openssl openssl-devel perl quota libcurl-devel gd zlib-devel zip unzip libcap-devel cronie bzip2 cyrus-sasl-devel perl-ExtUtils-Embed autoconf automake libtool which patch mailx bzip2-devel lsof glibc-headers kernel-devel expat-devel psmisc net-tools systemd-devel libdb-devel xfsprogs rsyslog logrotate crontabs file kernel-headers nano cmake cmake3 sysstat mlocate bc
# EPEL & Remi YUM repo
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

# disable Remi & EPEL by default and only enable manually when needed
yum-config-manager --disable remi epel
yum -q list jq nghttp2 redis memcached memcached-devel libmemcached-devel libmemcached screen GeoIP-devel GeoIP --enablerepo=powertools,epel,remi
yum -y install jq nghttp2 redis memcached memcached-devel libmemcached-devel libmemcached screen GeoIP-devel GeoIP --enablerepo=powertools,epel,remi
updatedb

We installed everything we need. We have to disable the SELINUX:

Command to update server
Disabling SELINUX

setenforce 0
sed -i 's|enforcing|disabled|g' /etc/selinux/config

After all these updates and SELINUX changes we have to reboot our server.

Command to reboot the server

reboot

Our server is ready lets install DirectAdmin on Centos 8
First we need to create a folder to store our install scripts. After that give execution permiosn the script.


mkdir -p /root/tools
cd /root/tools
wget -4 https://www.directadmin.com/setup.sh
chmod 755 setup.sh

Our DirectAdmin install file is ready bu we should to get ready our DirectAdmin Licence Iformatin before starting to install DirectAdmin. Because it will ask us during installation.
Also you have to know your server’s interface name. You can learn with this code:

Command to get server’s entherent interface name

/sbin/ifconfig

Output of the command:

Make sure your hostanme is like subdomain.domain.com otherwise it make things corrupt durinf the installation.

Before it will ask you :
Would you like to install these required pre-install packages? (y/n): y

You can see DirectAdmin asks Client ID, License ID and Hostname. If you don’t have license you should buy one from https://www.directadmin.com/

Also I want to choose php version myself so I said no for the first question

Would you like the default settings of apache and php 7.4 as php-fpm? (yes/no, default): n
Here my answers: (If you see empty answers it means i chose default.)

After all questions finished DirectAdmin installation starts on Centos 8 server. Installiation takes times depends on your server power.

Installation continues in screenmode :

If you disconnected from current SSH connection you can reattached the directadmin install screen with this code:

screen -r directadmin

Get screen ID and Detached

screen -D IDofYourScreen.directadmin

After that,

screen -r directadmin


After installiation finised if you didn’t lost your ssh connection you can use exit command to log out from screen session.

Setup will give you directadmin login information , after it finish. However you can’t connect DirectAdmin panel unless you disable you firewall or enable 2222 port access.


Command to disable fireall

firewall-cmd --permanent --zone=public --add-port=2222/tcp

Check the firewall status :

service firewalld status

if its active and you just allow 2222 port lets see if it works:

firewall-cmd --zone=public --list-ports

if you get empty after this command you need to reload the firewall to apply changes

firewall-cmd --reload After that you can see the port is allowed 

Output:

[root@webhosting ~]# firewall-cmd --zone=public --list-ports 
2222/tcp

Lets enable other ports and services with firewall-cmd

firewall-cmd --permanent --zone=public --add-port=22/tcp
firewall-cmd --permanent --zone=public --add-port=2222/tcp
firewall-cmd --permanent --zone=public --add-port=9418/tcp
firewall-cmd --permanent --zone=public --add-port=35000-35999/tcp
firewall-cmd --permanent --zone=public --add-service=dns
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-service=imap
firewall-cmd --permanent --zone=public --add-service=imaps
firewall-cmd --permanent --zone=public --add-service=pop3
firewall-cmd --permanent --zone=public --add-service=pop3s
firewall-cmd --permanent --zone=public --add-service=smtp
firewall-cmd --permanent --zone=public --add-service=smtps
firewall-cmd --permanent --zone=public --add-service=smtp-submission
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --list-services

You can check if you can access your direct admin panel : http://subdomain.domain.com:2222

Post-Install DirectAdmin Configuration

Our DirectAdmin Server is ready but we need to do some tweaks for better security and performance.

 

First, Apache settings ServerSignature is already set to Off so nothing to change. ServerTokens should be changed from Major to Prod. Follow the commands.

Check  Apache settings:

egrep '^ServerTokens|^ServerSignature' /etc/httpd/conf/extra/httpd-default.conf
ServerTokens Major
ServerSignature Off

Replace the settings :

sed -i 's|^ServerTokens .*|ServerTokens Prod|' /etc/httpd/conf/extra/httpd-default.conf
sed -i 's|^ServerSignature .*|ServerSignature Off|' /etc/httpd/conf/extra/httpd-default.conf

After that verify the changes in Apache settings:

egrep '^ServerTokens|^ServerSignature' /etc/httpd/conf/extra/httpd-default.conf 
ServerTokens Prod
ServerSignature Off

DirectAdmin overwrites config files after every updates. Thus, we need to crate a custom folder for extra config files to prevet DirectAdmin overwrite our custom settings.

cd /usr/local/directadmin/custombuild/
mkdir -p custom/ap2/conf/extra/
cp -p /etc/httpd/conf/extra/httpd-default.conf /usr/local/directadmin/custombuild/custom/ap2/conf/extra/
cp -p /etc/httpd/conf/extra/httpd-mpm.conf /usr/local/directadmin/custombuild/custom/ap2/conf/extra/

Let’s test our config file if it is free from any syntax error:

httpd -t
Syntax OK

Don’t forget to restart the Apache service

service httpd restart

Apache version information is hidden now:

lets set up directadmin notifications for updates:

options.conf includes cron settings for notifications. File is under /usr/local/directadmin/custombuild

Open with editor:

nano  /usr/local/directadmin/custombuild/options.conf

Change settings as you wish. Don’t forget to change email.

#Cronjob Settings
cron=yes
cron_frequency=weekly
[email protected]
notifications=yes
da_autoupdate=yes
updates=no
webapps_updates=yes

after made changes, type:

./build cron

It will write your settings.

Example output:

Cronjob is set for MYEMAILADDRESS:
Cronjob frequency: weekly
Automatic notifications: yes
Automatic updates: no

Directadmin we need to disable username access for security. ( Disable /~username access )
Use CustomBuild 2.0 for that. Follow the commands:

cd /usr/local/directadmin/custombuild
./build set userdir_access no
./build rewrite_confs

We can install many addons with CustomBuild 2.0. For exmaple ClamAV, maldet, AWStats or php modules..

Security if most important thing and Directadmin files are important to keep clean. Thus, We will install scaning modules.
Installing  ClamAV with CustomBuild 2.0. Also for emails, we will add Exim ClamAV support.

 

cd /usr/local/directadmin/custombuild

./build update
./build set clamav yes
./build set clamav_exim yes
./build set exim yes
./build set eximconf yes
./build set eximconf_release 4.5
./build clamav
./build exim
./build exim_conf

After that, we can install Maldet

cd /usr/local/src
wget -4 http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar -zxvf maldetect-current.tar.gz
cd $(ls -1d maldetect-*/ | tail -1)
./install.sh

 

 

 

 

 

 

Add support for Malware. Expert definitions

echo "DatabaseCustomURL http://cdn.malware.expert/malware.expert.ndb" >> /etc/freshclam.conf
echo "DatabaseCustomURL http://cdn.malware.expert/malware.expert.hdb" >> /etc/freshclam.conf
echo "DatabaseCustomURL http://cdn.malware.expert/malware.expert.ldb" >> /etc/freshclam.conf
echo "DatabaseCustomURL http://cdn.malware.expert/malware.expert.fp" >> /etc/freshclam.conf
service freshclam restart
ls -la /usr/local/share/clamav/malware.expert.* /var/lib/clamav/malware.expert.*

 

 

 

 

 

 

Web analytics is an open-source analytic tool so Installing AWStats on DirectAdmin with CustomBuild 2.0 follow these steps:

cd /usr/local/directadmin/custombuild
./build set awstats yes
./build awstats

Image conversions are very popular due to new webp converter plugins for wordpress recommened it a lot. Installing Imagick with CustomBuild on DirectAdmin is very easy.

cd /usr/local/directadmin/custombuild
./build update
./build set imagick yes
./build imagick


If you used DirectAdmin before you might heard poralix before. They provide custom scripts for DirectAdmin.
If you use centos 7 or 8 you need to modify poralix settings becase defaults one now work with newer centos version.
We will install Memcached, Memcache extensions, GeoIP, PHP Redis

 

Install Memcache PHP Extensions for Memcached on Centos 8 follow these commands: (This is for DirectAdmin – Install Memcached for DirectAdmin)

 

Follow theesse commands:

mkdir -p /root/tools/poralix
cd /root/tools/poralix
wget -4 https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh
./php-extension.sh install redis
./php-extension.sh install geoip  --beta
./php-extension.sh install memcached
./php-extension.sh install memcache --beta

If you get any error about libmemcached like :

  • Error: Unable to find a match: libmemcached-devel
  • memcached support requires libmemcached
  • Unable to find memcached.h under /usr/include/libmemcached
  • configure: error: no, libmemcached sasl support is not enabled. Run configure with –disable-memcached-sasl to disable this check

Please re-install pre-requirements on the first paragrapfh.

 

If your server has more than 2 cpu you shoul definitly enable pigz support for DirectAdmin. It will use all CPU threads when you
backup folders. It is very hand and time saver.

First, check you server CPU Threads with this command :

grep -c "processor" /proc/cpuinfo

If it is CPU thread is above 2 you can enable pigz support  in DirectAdmin

 

As always we will use CustomBuild 2.0 for enabling pigz:

cd /usr/local/directadmin/custombuild
./build update
./build pigz

 

If you planning to use Letsencrypt in your DirectAdmin you have to add additional settings for DirectAdmin.

Firstly, you have to Verify  SNI and Letsencrypt are enabled or not. if not please follow these commands:

Check current settings:

egrep 'enable_ssl_sni=|letsencrypt=' /usr/local/directadmin/conf/directadmin.conf

if it gets onyl letsencrypt entry, We need to enable both of them.

Before making changes lets copy our conf file:

cp /usr/local/directadmin/conf/directadmin.conf /usr/local/directadmin/conf/directadmin.conf.bak

Add enable_ssl_sni end of the DirectAdmin conf file :

 

echo "enable_ssl_sni=1" >> /usr/local/directadmin/conf/directadmin.conf

lets check again :

egrep 'enable_ssl_sni=|letsencrypt=' /usr/local/directadmin/conf/directadmin.conf
chown diradmin:diradmin /usr/local/directadmin/conf/directadmin.conf

if you want wildcard domain SSL certificate support via Let’s Encryptopen in new window, ensure dns_ttl=1 is set in the directadmin.conf.

echo "dns_ttl=1" >> /usr/local/directadmin/conf/directadmin.conf

We need to apply changes so lets restart DirectAdmin:

echo "action=directadmin&value=restart" >> /usr/local/directadmin/data/task.queue; /usr/local/directadmin/dataskq d2000

Add the /.well-known Alias with custombuild:

cd /usr/local/directadmin/custombuild
./build rewrite_confs

Install the most recent version of the Letsencrypt with these commands :

cd /usr/local/directadmin/custombuild
./build update
./build letsencrypt

I have own a paid SSL certificate so i upload my SLL files to : /usr/local/directadmin/conf

and edit directadmin.conf

nano /usr/local/directadmin/conf/directadmin.conf

this is my ssl settings with cutom SSL Certificate

ssl=1
force_hostname=webhosting.domain.com
ssl_redirect_host=webhosting.domain.com
cacert=/usr/local/directadmin/conf/server.crt
cakey=/usr/local/directadmin/conf/server.key
carootcert=/usr/local/directadmin/conf/server.ca  

After that restart directadmin

service directadmin restart

you can use directadmin with SSL

Phpmyadmin ssl settings on DirectAdmin

Phpmyadmin use SSL files with Apache so Install your SSL files in /etc/httpd/conf/

/etc/httpd/conf/ssl.crt/server.ca
/etc/httpd/conf/ssl.crt/server.crt
/etc/httpd/conf/ssl.crt/server.crt.combined

/etc/httpd/conf/ssl.key/server.key

Inside of the ssl.crt folder dhparams.pem should be there. It is default so don’t delete it.

phpmyadmin use apache conf you can check this config file:

nano /etc/httpd/conf/extra/httpd-ssl.conf

server.crt.combined and server.crt are the same file bot different name. Directadmin creates user’s nginx file
and point their ssl settins : server.crt.combined. Thats why I have both file different name.
Also Apache use /etc/httpd/conf/ssl.crt/server.crt.combined on created new httpd.conf file for domains. I’dont know why.

/etc/httpd/conf/ssl.crt/server.crt.combined contains in order:

SSL CERTIFICATE.txt
AlphaSSL Intermediate CA.txt
Root Certificates.txt

it is same as server.crt

https://forum.directadmin.com/threads/ssl-location-is-different-apache-cant-restart.64932/

After all settings set up :

service httpd restart 
service directadmin.service restart 

Install CSF Firewall for DirectAdmin

 

CSF Firewall is easy to use rather than Firewalld. Thus, We will remove Firewalld and install CSF Firewall on Centos 8.

removing firewalld:

systemctl disable firewalld
systemctl stop firewalld

Install iptables:

yum -y install iptables-services
systemctl start iptables
systemctl start ip6tables
systemctl enable iptables
systemctl enable ip6tables

 

We will use CSF Firewall with Brute Force Monitor (BFM). We need to add BFM support to CSF Firewall in order to use that.

You rememver poralix right? Lets use their csf-bfm-install.sh script to install it :

mkdir -p /root/tools/poralix
cd /root/tools/poralix
wget -4 -O csf-bfm-install.sh https://raw.githubusercontent.com/poralix/directadmin-bfm-csf/master/install.sh
chmod 700 csf-bfm-install.sh
./csf-bfm-install.sh

To upgrade using Poralix’s script:

mkdir -p /root/tools/poralix
cd /root/tools/poralix
wget -4 -O csf-bfm-update.sh https://raw.githubusercontent.com/poralix/directadmin-bfm-csf/master/update.sh
chmod 700 csf-bfm-update.sh
./csf-bfm-update.sh

check if testing is neabled ?

grep '^TESTING =' /etc/csf/csf.conf

also check the ports

Inspecting whitelisted CSF Firewall ports

 

egrep '^TCP_|^TCP6_|^UDP_|^UDP6_' /etc/csf/csf.conf

Output:

Check CSF Firewall profile backup

csf --profile list

create a backup

csf --profile backup after-csf-bfm-install

Check CSF Firewall profile backup again

csf --profile list

Finally ensure, CSF Firewall and LFD daemon starts up on server reboots

chkconfig lfd on
chkconfig csf on

Double check CSF Firewall works via csftest.pl

perl /etc/csf/csftest.pl

after installing it

check the config file :

cat /root/directadmin-bfm-csf.conf

If it is not created, create one:

nano /root/directadmin-bfm-csf.conf
USE_PORT_SELECTED_BLOCK="1";
CSF_GREP_API_CALL="0";
DEBUG="0";
FTP_PORTS="20 21";
SSH_PORTS="22";
WEB_PORTS="80 443";
EXIM_PORTS="25 465 587";
DOVECOT_PORTS="110 143 993 995";
DIRECTADMIN_PORTS="2222";

If you change the default DirectAdmin port don’t forget to change it with your own port number.

DIRECTADMIN_PORTS="you port number";

You will get a lot  of IP attacks so If you want to block a IP to access your all ports enable this command :

USE_PORT_SELECTED_BLOCK="0";

A large number of attacker IPs will consume your server’s power. We will use IPSET to lower that consumption. IPSET support is disabled on directAdmin. If your Linux server kernel version support  IPSET  you should follow these steps:

Check IPSET  settings:

grep -w '^LF_IPSET' /etc/csf/csf.conf
LF_IPSET = "0"

Here a script to check If your server’s Linux Kernel supports IPSET.

nano csf_ipset.sh
#!/bin/bash
#####################################################
# CSF Firewall IPSET configuration for DirectAdmin
# routine partially borrowed from centminmod.com 
# CSF Firewall setup
######################################################
KERNEL_NUMERICVER=$(uname -r | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }')
ipset_setup() {
  if [[ ! -f /usr/sbin/ipset ]]; then
    # CSF now has ipset support to offload large IP address numbers 
    # from iptables so uses less server resources to handle many IPs
    # does not work with OpenVZ VPS so only implement for non-OpenVZ
    yum -q -y install ipset ipset-devel
    sed -i 's/LF_IPSET = \"0\"/LF_IPSET = \"1\"/' /etc/csf/csf.conf
  elif [[ -f /usr/sbin/ipset ]]; then
    sed -i 's/LF_IPSET = \"0\"/LF_IPSET = \"1\"/' /etc/csf/csf.conf
  fi
}
if [[ ! -f /proc/user_beancounters ]] && [[ "$(uname -r | grep linode)" || "$(find /lib/modules/`uname -r` -name 'ipset')" ]]; then
  ipset_setup
elif [[ -f /proc/user_beancounters && "$KERNEL_NUMERICVER" -ge '3000000000' ]]; then
  # openvz7's 3.10 linux kernels support IPSET
  ipset_setup
fi

chmod +x csf_ipset.sh
./csf_ipset.sh

Lets check LF_IPSET setting is enabled = 1 or not :

grep -w '^LF_IPSET' /etc/csf/csf.conf
LF_IPSET = "1"

As the image shows we enabled IPSET on our server. We can now increse CSF Firewall IP address limits because it is now handle much more IP datas.

sed -i 's/^DENY_IP_LIMIT = .*/DENY_IP_LIMIT = \"3000\"/' /etc/csf/csf.conf
sed -i 's/^DENY_TEMP_IP_LIMIT = .*/DENY_TEMP_IP_LIMIT = \"3000\"/' /etc/csf/csf.conf

After these settings restart your CSF Firewall

csf -ra

Cloudflare Settings in DirectAdmin

If you use Cloudflare as much as I do, You should follow these steps. We need to whitelist Cloudflare’s IP addresses so CSF Firewall doesn’t block them. We will use the Centmin Mod LEMP stack script for this. The script will fetch Cloudflare latest IPs and add them to Whitelist.

Follow these steps:

mkdir -p /root/tools
cd /root/tools
wget -4 -O /root/tools/csfcf.sh https://github.com/centminmod/centminmod/raw/123.09beta01/tools/csfcf.sh
chmod 700 /root/tools/csfcf.sh
# run once to whitelist CF IPs
/root/tools/csfcf.sh apache /root/tools/csfcf.sh auto-apache

Script creates httpd-includes-remoteip.conf file that contains cloudfalre IPs.We need to manually add that config for apache settings.

Open /etc/httpd/conf/extra/httpd-includes.conf :

nano /etc/httpd/conf/extra/httpd-includes.conf

add this line:

Include /etc/httpd/conf/extra/httpd-includes-remoteip.conf

After that check, if everything is ok:

httpd -t
Syntax OK

Then don’t forget to restart Apache

service httpd restart

Also add a crontab for regular check new CloudFlare IP Addresses.

23 */12 * * * /root/tools/csfcf.sh auto-apache >/dev/null 2>&1

Also I regularly back up my directadmin backups:

 

DirectAdmin Backup Remover

#!/bin/sh

backup_directory="/home/admin/admin_backups" # No trailing /
backup_time="1" # Remove backups how many days old? Number variable only!

#### Commands ####

find_files=$(find $backup_directory/* -maxdepth 0 -mtime +$backup_time)

#### Begin Script ####

##

echo ""
echo "Looking for old backups... Older then $backup_time days old."
echo "----"
if [ -z "$find_files" ]; then
echo "None Found!"
else
echo "$find_files"
fi
echo "----"
echo ""
echo "If any folders were found they have deleted."
find $backup_directory/* -maxdepth 0 -mtime +$backup_time -exec rm -rv {} +
echo ""
echo "Done."
echo ""

 

Create a Cronjob :

5 0 * * * /root/backup_remover.sh > /var/logs/backup_remover_`date +\%d-\%m-\%Y_\%H-\%M`.log 2>&1

 

It will output logs in  /var/logs/

 

If you have any questions just ask.

 

Resources:

George from https://centminmod.com/ Thank you.

403 User Rate Limit Exceeded Error | SOLUTION – Google Drive Fixed !

If you are getting; googleapi User Rate Limit Exceeded,  gdrive 403 Rate Limit Exceeded we have a solution for you.

We have been using Gdrive to upload some of our essential files for many months. Recently, we noticed that our daily backup was not working as expected. Gdrive error logs show us, Failed to get file: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded and Failed to get file: googleapi: Error 404: File not found: Failed., notFound errors.

 

We tried rebooting our servers refreshing our auth logins etc. none of them fixed our gdrive User Rate Limit Exceeded errors. The problem was an API related issue so we need to create a new API and build Gdrive from source. The solution is simple but takes times, If you are figuring out how to do it. However, It took a couple of our hours to do it but it will take minutes of your time, if you follow this guide you will solve your google drive 403 Rate Limit Exceeded error.

 

PS: We applied all the steps on our Centos server, but it will be the same with all platforms.

 

Part 1

Carefully follow the steps to fix google drive User Rate Limit Exceeded Error.

Downloading and Installing GO

You will need root privileges or sudo for ubuntu.

Download the files :

To download the Go binary on your linux server you can use wget or curl:

wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz

You need to extract Go binary files from go1.11.5.linux-amd64.tar.gz After successful extraction; you will have a go named folder. You should move it to /usr/local location because it is recommended by publishers.

tar -xzf go1.11.5.linux-amd64.tar.gz
mv go /usr/local

 

Creating Workspace Folder for Go

For better-organized projects, create a projects folder with bin and src folder together in user home directory.

 

mkdir  -p ~/projectss/{bin,src}

 

Setting Environment Variables for Go

We need to set a $PATH Environment variable for Go to use it like any other commands in our UNIX system.

Create path.sh script in /etc/profile.d directory location

nano /etc/profile.d/path.sh

Add the following to the file, save and exit. (/etc/profile.d/path.sh)

/usr/local/go/bin

Additionally, we need to define GOPATH and GOBIN Go environment variables in the user’s  .bash_profile file to point to the recently created projects folder. GOPATH is our Go source files GOBIN is our compiled Go binary files. Open the .bash_profile file:

nano ~/.bash_profile

Append the following to the end of the file, save and exit: (~/.bash_profile)

export GOBIN="$HOME/projects/bin"
export GOPATH="$HOME/projects/src"

Apply to changes in our system; we need to update profiles with source command

 

source /etc/profile && source ~/.bash_profile

Let’s test our Go if it is working

[root@host ~]# go version 
go version go1.11.5 
linux/amd64

We needed to have Go in our system to compile Gdrive so that’s all for installing Go. We can continue Part 2 where we will compile Gdrive from source files.

Part 2

We will continue to solve googleapi 403 Rate Limit Exceeded error. Keep following the steps…

Creating Google API for Gdrive

If you see these errors while running Gdrive on your system:

Failed to get file: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded

You need your own Google Drive API to use with Gdrive so you can get information from your usages. Google API’s provide  Quotas Information which is very helpful in our situation. We need to know if we Exceed our limits.

Visit https://console.developers.google.com/apis/dashboard

Top of the page, click Select a project then New Project. 

Fill Project name as you want it.

Google API New Project

 

Choose your newly created project at the top of the page. At the dashboard, click  ENABLE APIS AND SERVICES

It will redirect you API Library. Search Drive keyword and find Google Drive API. You need to enable Google Drive API to use it in your project.

 

Add and Enable Google Drive API

We successfully add Google Drive API in our project. Gdrive requries Google Drive API’s credentials. Let’s create one.

 

Google Drive API Credentials

Create Credentials Details and choose the option ” Help me choose.”

Google API Credentials

Choose the settings as I did:

Google API Credentials Settings

 

I filled Client Name as same as my API Name.

Google API Name

Next step, fill your mail address and write a Product name.

 

Google API OAuth Name

After that, It will give us the Credentials we need.

 

Google Drive Error 403 User Rate Limit Exceeded Solution

Click download and done.

It will download a JSON file which contains our Credentials for Gdrive. Open the client_id.json file with a text editor. Notepad++ is a good option.

You will see,

“client_id”:”205xxxxxxxxx-22imoxxxxxxxxxxxxxxxxpsm.apps.googleusercontent.com”

“client_secret”:”NxxxxxxG-4HxxxxxxxxxxxxxxxwZA”

We need that two value so note it.

 

Getting Source Files of Gdrive

We need Gdrive projects files from Github so that we can compile it with Go. Let’s download files into our ~/projects/ folder that we created earlier.

 

cd ~/projects/

Use GO to download Gdrive src files from GitHub.

 

go get github.com/prasmussen/gdrive

We need to change Credentials in handlers_drive.go where is located in the gdrive folder.

 

cd ~/projects/src/src/github.com/prasmussen/gdrive/

nano handlers_drive.go

const ClientId = "3671xxxxxxxxxxxxxxxxxxxxxxeg.apps.googleusercontent.com"
const ClientSecret = "1qsNxxxxxxxxhoO"

 

No More googleapi User Rate Limit Exceeded

Change ClientId and ClientSecret with your own Google Drive API Credentials form client_id.json 

Save and exit.

We are ready to build Gdrive.

Let’s build it:

 

cd ~/projects/src/src/github.com/prasmussen/gdrive/
go build

 

After the build, you will see gdrive executable file. Copy it to /usr/bin/ folder to use it.

 

cp gdrive /usr/bin/gdrive

 

Note: If you had gdrive on your system, you need to delete old token_v2.json.

 

cd ~/.gdrive

rm token_v2.json

Now, we have gdrive installed in our system with our Google Drive API settings.

Let’s test it.

 

gdrive list

 

If it is your first time to use Gdrive or deleted token file, Gdrive needs Authentication from you.

 

Authentication needed
Go to the following url in your browser:

Enter verification code:

Paste the link in your browser and get the verification code.

 

Execute gdrive list again

We Solved google drive 403 Rate Limit Exceeded

That is it is working without errors!

 

Let’s check if our API is working too.

Gdrive Quotas – gdrive User Rate Limit Exceeded

Yes ! it is working too. Now we can see our Quota limit.

For Windows, please check this: https://github.com/prasmussen/gdrive/issues/426#issue-404775200

If you have any question, please leave a comment below. We will answer them ASAP.

 

Thanks.

 

How to install and update GCC on Centos 7

I will show you How to install and update GCC on Centos 7 step by step. Just follow my steps and if you get any error just comment on this post i will reply as soon as possible.

If your centos 7 is freshly installed you need to update our centos 7.

yum update

After that just install some basic requirements that will be needed nex steps.

yum install bzip2
yum install wget
yum install nano

How to install GCC on Centos 7

Just follow same steps as centos 6 and compile GCC on your machine. You must made a change for centos 7. Only one difference is at 7 step when you are compiling GCC.

Adjust your command as your need :

../gcc-6.1.0/configure –enable-languages=c,c++ –disable-multilib && make -j <number of CPU cores> && sudo make install && echo “success”

you have too add these paramaters : –enable-languages=c,c++ –disable-multilib

Other step as same as follows

How To Install Newer Version Of GCC on CentOS 6.x

 

How to solve GLIBCXX Not Found Error on Centos 7

 

Just follow these steps (You must compile newer version of GCC):

cd /usr/local/lib64
cp libstdc++.so.6.0.22 /usr/lib64/
cd /usr/lib64/
mv libstdc++.so.6 libstdc++.so.6.OLD
ln -sf libstdc++.so.6.0.22 libstdc++.so.6

This will solve these problems :

libstdc++.so.6 not found CentOS 7.3
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21′ not found

 

Lets Check :

strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

Output :

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22

How to Update glibc Newer Version on Centos 6.x

You tried to runs some commands and got error about your glibc version is not high enough to complete your command. Thus, You may need newer version glibc on your Centos 6.x VPS server. I will show you how to update glibc.

How to Update glibc Newer Version on Centos 6.x

We have two way to accomplish this task. One way is that compile from source which take too long time to do that. Another way is that get files from repo which is relatively easy step.

Lets first check our glibc versions that installed in our VPS server:

strings /lib64/libc.so.6 | grep GLIBC

Result:

GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12

 

1.  Compile glibc From Source

We can get soruce file in 2 ways, using git or ftp. You can get latest version from git. We need GLIBC_2.17 version for our centos 6.x so we will use ftp.

mkdir ~/glibc-install; cd ~/glibc-install
wget http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
tar -zxvf glibc-2.17.tar.gz

After Download and extract all source files we need to create a build folder. It is better way to have another folder for build.

cd glibc-2.17
mkdir build

We need to put files  separete place in order to not corrput our linux system. /opt/glibc-2.17

cd build
../configure --prefix=/opt/glibc-2.17

We can start compiling our source files. It will take hours depending your CPU cores. You can find your <number of CPU Cores> by using nproc command.

make -j<number of CPU Cores>
make install

After compiling is done we need to show place of our new glibc to program we are gonna use. In order to do that follow step below;

 

LD_LIBRARY_PATH=/opt/glibc-2.17/lib

export LD_LIBRARY_PATH.

Furing your current login session on VPS Library is exposed

Another way is that creating symbolic link :

ln -sf /opt/glibc-2.17/glibc-2.17.so /lib/libc.so.6.

I do not recommend this step because linux use older version of glibc and if you create a symbolic link somethings will sure go wrong.

If you are not experienced system administrator do not play with glibc, it might break your Linux system.

2. Using RPM to install new version of glibc

Update glibc to 2.17 for CentOS 6

I found a script from github. We will use it. Lets appreciated his work : https://gist.github.com/harv/f86690fcad94f655906ee9e37c85b174

Script :


#! /bin/sh

# update glibc to 2.17 for CentOS 6

wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-common-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-devel-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-headers-2.17-55.el6.x86_64.rpm

sudo rpm -Uvh glibc-2.17-55.el6.x86_64.rpm \
glibc-common-2.17-55.el6.x86_64.rpm \
glibc-devel-2.17-55.el6.x86_64.rpm \
glibc-headers-2.17-55.el6.x86_64.rpm

You might ecounter some errors: “error: Failed dependencies:

To fix it just add this parameter --force --nodeps at the end of the all command.

After finished up lets check again :

strings /lib64/libc.so.6 | grep GLIBC

Result :

GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_PRIVATE

We have GLIBC_2.17 on our centos 6.x VPS server.

If you have a question just post as a comment and i will reply it as soon as possible.

GLIBCXX_3.4.xx Not Found – Install Newer Version Of GLIBCXX on Centos 6

Centos 6.x user might face it the GLIBCXX version error on their VPS server. You can solve this error switching your OS version to more newer ones like centos 7.x. However, if you want to stick with centos 6.x and have newer version of GLIBCXX just follow steps i will show on this article.

 

GLIBCXX_3.4.xx Not Found Error means that version on your Cenots 6.x VPS machine is not high enough to run the binary. Thus we will need  to upgrade GLIBCXX version.

Lets first check our Centos 6.x VPS’s GLIBCXX versions.

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

Here is the result:

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

We need more newer version to run our programs on centos 6.x.

Fixing  /lib/libstdc++.so.6: version GLIBCXX_3.4.xx not found Error

We need libstdc++.so.6.0.22 file in order to have higer version of GLIBCXX. You can create the file by following the steps from this article : How To Install Newer Version Of GCC on CentOS 6.x

After you created libstdc++.so.6.0.22 file just follow these steps :

cd /usr/local/lib64
cp libstdc++.so.6.0.22 /usr/lib64/
cd /usr/lib64/
mv libstdc++.so.6 libstdc++.so.6.OLD
ln -sf libstdc++.so.6.0.22 libstdc++.so.6

Lets check GLIBCXX versions again:

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

Result :

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

We have new version of GLIBCXX on our centos 6.x VPS server now. You can try to run your program and check that you are not getting same error anymore.

 

If you have any question just write a comment and i will reply as soon as possible.