Category: Linux

  • Gitlab find version

    To find version of hosted Gitlab installation, run

    gitlab-rake gitlab:env:info
    

    Example

    root@simplegitlab:~# gitlab-rake gitlab:env:info
    
    System information
    System:		Ubuntu 16.04
    Current User:	git
    Using RVM:	no
    Ruby Version:	2.5.3p105
    Gem Version:	2.7.9
    Bundler Version:1.17.3
    Rake Version:	12.3.2
    Redis Version:	3.2.12
    Git Version:	2.21.0
    Sidekiq Version:5.2.7
    Go Version:	unknown
    
    GitLab information
    Version:	11.11.0
    Revision:	3e8ca2fb781
    Directory:	/opt/gitlab/embedded/service/gitlab-rails
    DB Adapter:	PostgreSQL
    DB Version:	9.6.11
    URL:		https://gitlab.simplecloud.co.za
    HTTP Clone URL:	https://gitlab.simplecloud.co.za/some-group/some-project.git
    SSH Clone URL:	[email protected]:some-group/some-project.git
    Using LDAP:	no
    Using Omniauth:	yes
    Omniauth Providers: 
    
    GitLab Shell
    Version:	9.1.0
    Repository storage paths:
    - default: 	/var/opt/gitlab/git-data/repositories
    GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
    Git:		/opt/gitlab/embedded/bin/git
    root@simplegitlab:~# 
    

    Back to Gitlab

  • ISPmanager

    ISPmanager

    ISPmanager is a hosting control panel. The price starts at $5 per month for the lite version.

    To install ISPmanager, run

    wget http://download.ispsystem.com/install.sh
    sh install.sh ISPmanager
    
  • APCu

    APCu

    APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables.

    APCu only supports userland caching of variables. APCu is APC stripped of opcode caching.

    https://github.com/krakjoe/apcu/

    Install PHP APC Cache on CentOS 7 using yum

  • apt force IPv4

    One of my internet provider only provide IPv4 connection. When i run apt install command, it failed with error as it try to connect using IPv6.

    boby@sok-01:~$ sudo apt install php7.3-curl
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following NEW packages will be installed:
      php7.3-curl
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 29.6 kB of archives.
    After this operation, 123 kB of additional disk space will be used.
    Err:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-curl amd64 7.3.13-1+ubuntu18.04.1+deb.sury.org+1
      Could not connect to ppa.launchpad.net:80 (2001:67c:1560:8008::15). - connect (101: Network is unreachable) Could not connect to ppa.launchpad.net:80 (91.189.95.83), connection timed out
    E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php7.3/php7.3-curl_7.3.13-1+ubuntu18.04.1+deb.sury.org+1_amd64.deb  Could not connect to ppa.launchpad.net:80 (2001:67c:1560:8008::15). - connect (101: Network is unreachable) Could not connect to ppa.launchpad.net:80 (91.189.95.83), connection timed out
    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
    boby@sok-01:~$
    

    To force apt to use IPv4 only, edit

    sudo vi /etc/apt/apt.conf.d/99-force-ipv4
    

    Add

    Acquire::ForceIPv4 "true";
    

    If you want to force IPv6, add

    Acquire::ForceIPv6 "true";
    
  • Set tab width in vim

    To set tab width in Vim, run

    :set tabstop=4

    To make it permanent, edit ~/.vimrc and add

    set tabstop=4

    back to vim

  • CentOS 7 resolv.conf make changes permanent

    On rebooting the CentOS 7 server, changes made to resolv.conf is lost. This is because one of the network interface is configured to use DNS server.

    [root@server ~]# grep DNS /etc/sysconfig/network-scripts/ifcfg-*
    /etc/sysconfig/network-scripts/ifcfg-eno1:DNS1="127.0.0.1"
    [root@server ~]# 

    To fix, edit

    vi /etc/sysconfig/network-scripts/ifcfg-eno1

    Remove the line

    DNS1="127.0.0.1"

    Now NetworkManager will not modify /etc/resolv.conf file on boot.

    Or you can set valid DNS servers in network config file like

    [root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1 | grep DNS
    DNS1="1.1.1.1"
    DNS2="8.8.8.8"
    [root@server ~]# 

    If your network configuration use DHCP, set set PEERDNS=no.

    BOOTPROTO=dhcp
    PEERDNS=no

    Another solution is to make file immutable with

    chattr +i /etc/resolv.conf

    Related Posts

    Domain Resolver

  • Install Pure-FTPd on CentOS with Virtual Users

    To install Pure-FTPd on CentOS, run

    yum install -y pure-ftpd
    

    Edit configuration file

    vi /etc/pure-ftpd/pure-ftpd.conf
    

    To disable anonymous FTP, find

    NoAnonymous                  no
    

    Replace with

    NoAnonymous                  yes
    

    To enable Virtual Users, find

    # PureDB                        /etc/pure-ftpd/pureftpd.pdb
    

    Uncomment the line.

    PureDB                        /etc/pure-ftpd/pureftpd.pdb
    

    To Allow Apache user to login via FTP, find

    MinUID                      1000
    

    Replace with

    MinUID                      47
    

    I set MinUID value to 47, as apache user have UID/GID of 48. By setting MinUID below that apache user should be able to login.

    Set pureftpd to start on Boot

    systemctl enable pure-ftpd
    

    Restart pure-ftpd

    systemctl start pure-ftpd
    

    Create a Virual User

    To create a virtual user, run

    pure-pw useradd  USER_NAME_HERE -u apache -g apache -d /var/www/html/
    

    It will ask you to enter password two times.

    Now run

    pure-pw mkdb
    systemctl restart pure-ftpd
    

    Change Password of an existing Virual User

    pure-pw passwd USER_NAME_HERE
    

    It will ask you to enter new password.

    Rebuild password database and restart pure-ftpd with

    pure-pw mkdb
    systemctl restart pure-ftpd
    

    Related Posts

    Install pureftpd on Ubuntu

    pureftpd

  • Install vim from source on CentOS

    To install vim from source on the CentOS server, run

    yum -y install  ncurses-devel
    cd /usr/local/src
    wget https://github.com/vim/vim/archive/master.zip	
    unzip master.zip
    cd vim-master/src/
    ./configure
    make
    make install

    This will install the latest version of Vim. You can start it with the command

    vim
    

    To get it work with “vi” command, i removed preinstalled vim editor with command

    rpm -e --nodeps  vim-minimal

    Now create a symlink with

    ln -s /usr/local/bin/vim /bin/vi
  • Updating Kernel on Oracle Linux with Ksplice

    Updating Kernel on Oracle Linux with Ksplice

    Oracle Linux come with Ksplice, it allow you to upgrade Kernel with out rebooting.

    To update kernel, run

    uptrack-upgrade
    

    Example

    Oracle Ksplice

  • Install clamav Antivirus on CentOS 7

    ClamAV is provided by the EPEL repo. Install epel repo

    yum install -y epel-release
    

    Install ClamAV with

    yum install clamav
    

    Back to ClamAV

  • Install OpenLiteSpeed on CentOS

    Install OpenLiteSpeed on CentOS

    To install OpenLiteSpeed web server on CentOS, install repository for your CentOS version

    For CentOS 6

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm
    

    For CentOS 7

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
    

    For CentOS 8

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
    

    To install OpenLiteSpeed, run

    yum install openlitespeed
    

    Before you can install PHP, you need epel repository enabled with

    yum install epel-release
    

    Install PHP with

    yum install lsphp73 lsphp73-common lsphp73-mysql lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath lsphp73-json lsphp73-mysqlnd
    

    Set symlink

    ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5
    

    Start OpenLiteSpeed with

    /usr/local/lsws/bin/lswsctrl start
    

    To stop OpenLiteSpeed, run

    /usr/local/lsws/bin/lswsctrl stop
    

    By default, OpenLiteSpeed will run on port 8088

    http://YOUR_SERVER_IP_HERE:8088
    

    You can login to Admin Interface at

    http://YOUR_SERVER_IP_HERE:7080
    User = admin
    PW = 123456
    

    By default, you see an example application. The configuration file for this is at

    /usr/local/lsws/conf/vhosts/Example/vhconf.conf
    

    Default DocumentRoot is /usr/local/lsws/Example/html. To change, edit file

    vi /usr/local/lsws/conf/vhosts/Example/vhconf.conf
    

    Find

    docRoot $VH_ROOT/html/
    

    Replace $VH_ROOT/html/ with whatever path you need. You need to restart OpenLiteSpeed to make the change go live

    /usr/local/lsws/bin/lswsctrl restart
    
  • Ubuntu 18.04 MariaDB 10.2 Too many open files

    Ubuntu 18.04 MariaDB 10.2 Too many open files

    On my computer running Ubuntu 18.04, MriaDB stopped working. PHP application i run on my computer failed with error

    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ok_test.feeds' doesn't exist (SQL: select * from `feeds` where `processed` = 0)
    

    Application can’t find the table. So i tried to login to MySQL and see if table is there or not. But i get error

    boby@sok-01:~$ mysql
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2504
    Server version: 10.2.30-MariaDB-1:10.2.30+maria~bionic-log mariadb.org binary distribution
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> show databases;
    ERROR 1018 (HY000): Can't read dir of '.' (errno: 24 "Too many open files")
    MariaDB [(none)]>
    

    Next i checked if this is due to any MySQL upgrade. I found MySQL got updated today

    root@sok-01:~# grep mariadb /var/log/dpkg.log
    2019-12-13 08:02:46 status triggers-pending mariadb-server-10.2:amd64 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 upgrade mariadb-common:all 1:10.2.29+maria~bionic 1:10.2.30+maria~bionic
    2019-12-13 08:02:46 status half-configured mariadb-common:all 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 status unpacked mariadb-common:all 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 status half-installed mariadb-common:all 1:10.2.29+maria~bionic
    

    To fix this error, run

    systemctl edit mysql
    

    This wil open a text editor. Add following

    [Service]
    LimitNOFILE=8192
    

    Save and quit the editor. Restart MaraDB with

    systemctl restart mysql
    

    MySQL will work properly now. systemctl edit mysql will create file /etc/systemd/system/mysql.service.d/override.conf

    root@sok-01:~# cat /etc/systemd/system/mysql.service.d/override.conf 
    [Service]
    LimitNOFILE=8192
    
    root@sok-01:~#