Category: Linux

  • 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:~#
    
  • OpenLiteSpeed

    OpenLiteSpeed

    OpenLiteSpeed is an open-source version of the popular commercial web server LiteSpeed. OpenLiteSpeed contains all of the essential features found in LiteSpeed Enterprise.

    You can get OpenLiteSpeed from

    https://openlitespeed.org

    Here is a benchmark from the OpenLiteSpeed website that compares OpenLiteSpeed with Nginx.

    OpenLiteSpeed Benchmark

    OpenLiteSpeed configuration file

    /usr/local/lsws/conf/httpd_config.conf

    To start/stop/restart, use

    /usr/local/lsws/bin/lswsctrl start
    /usr/local/lsws/bin/lswsctrl stop
    /usr/local/lsws/bin/lswsctrl restart
    /usr/local/lsws/bin/lswsctrl status

    OpenLiteSpeed web server stores cache in directory /usr/local/lsws/cachedata. This can grow big over time. You can delete this folder to free up space or move it to another partition with free disk space and create a symlink.

    To set/reset the WebAdmin password, run

    /usr/local/lsws/admin/misc/admpass.sh

    Update OpenLiteSpeed

    /usr/local/lsws/admin/misc/lsup.sh -v 1.8.1

    You can login to WebAdmin at

    https://server-ip:7080

    Web Server