Category: CentOS

  • Install PHP 7.2 on CentOS from yum

    First you need to install Remi repository

    https://rpms.remirepo.net

    Enable epel repo with

    yum install epel-release -y
    

    On CentOS 7

    rpm -ivh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    

    On CentOS 6

    rpm -ivh https://rpms.remirepo.net/enterprise/remi-release-6.rpm
    

    Enable PHP 7.2

    yum install yum-utils
    yum-config-manager --enable remi-php72
    

    To install PHP, run

    yum install -y php php-bcmath php-cli php-common php-devel php-gd \
        php-imap php-intl php-json php-ldap php-lz4 php-mbstring php-mysqlnd \
        php-soap php-intl php-opcache php-xml php-pdo
    

    Downgrading PHP version

    if you ever want to change PHP version, lets say PHP 7.0, do the following. Remove current PHP

    rpm -qa | grep php | xargs yum remove -y
    

    Disable PHP 7.2 repo.

    yum-config-manager --disable remi-php72
    

    Enable PHP 7.0 repo

    yum-config-manager --enable remi-php70
    

    Now install PHP as above.

    PHp Binary

    PHP cli will be installed in /usr/bin/php72, you can create a symlink if you want.

    PHP-FPM

    To install php-fpm module, run

    yum install php72-php-fpm -y
    

    To start php-fpm, run

    systemctl start php72-php-fpm
    

    See CentOS, php

  • Install Google Chrome on CentOS 7 64 bit

    To install Google Chrome on CentOS 7 (Chrome won’t work on CentOS 6 as it is using older version of libraries required for Chrome).

    First create repo file

    vi /etc/yum.repos.d/google-chrome.repo
    

    Add following content

    [google-chrome]
    name=google-chrome
    baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
    enabled=1
    gpgcheck=1
    gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
    

    Now you can install google chrome with command

    yum -y install google-chrome-stable
    

    See CentOS

  • Delta RPMs disabled

    When i install software on CentOS server, i get following warning

    Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

    You can install deltaparm package

    yum install deltarpm -y
    

    This will save you some bandwidth as yum will only download difference between previous package.

  • install sysstat on centos

    To install sysstat/sar on CentOS, run

    yum install sysstat
    

    Enable and start sysstat

    systemctl enable sysstat
    systemctl start sysstat
    systemctl status sysstat
    

    Allow several minutes to collect data, then you will be able to see stats with sar ommand.

    See sar

  • Install tmux on CentOS 6

    tmux is a terminal emulator. It work like screen, but have more features.

    CentOS 6 do not come with tmux, you need to enable rpmforge repository.

    http://repoforge.org/use/

    On CentOS 6 64 bit, run

    rpm -ivh http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
    yum install tmux
    
  • CentOS 7 Cannot find autoconf

    When install redis php module, i get error

    Cannot find autoconf. Please check your autoconf installation and the
    $PHP_AUTOCONF environment variable. Then, rerun this script.

    [root@vps154294 phpredis]# /usr/serverok/php-7.1.12/bin/phpize
    Configuring for:
    PHP Api Version:         20160303
    Zend Module Api No:      20160303
    Zend Extension Api No:   320160303
    Cannot find autoconf. Please check your autoconf installation and the
    $PHP_AUTOCONF environment variable. Then, rerun this script.
    
    [root@vps154294 phpredis]#
    

    This is fixed by installing autoconf package with yum.

    yum install -y autoconf
    

    Once autoconf installed, phpize command worked properly.

    [root@vps154294 phpredis]# /usr/serverok/php-7.1.12/bin/phpize
    Configuring for:
    PHP Api Version:         20160303
    Zend Module Api No:      20160303
    Zend Extension Api No:   320160303
    [root@vps154294 phpredis]# 
    
  • CentOS 7 configure: error: Cannot find libtidy

    When compiling PHP 7 on CentOS 7, i got error

    configure: error: Cannot find libtidy
    

    To fix this, install libtidy-devel module.

    yum install -y libtidy-devel
    
  • Installing Redis PHP module CentOS 7

    Lets search for available redis packages

    [root@vps154294 smartfst]# yum search redis
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * epel: mirror.us.leaseweb.net
     * remi-safe: repo1.ash.innoscale.net
    ============================================================================================ N/S matched: redis ============================================================================================
    collectd-redis.x86_64 : Redis plugin for collectd
    collectd-write_redis.x86_64 : Redis output plugin for collectd
    hiredis.x86_64 : Minimalistic C client library for Redis
    hiredis-devel.x86_64 : Development files for hiredis
    hiredis-last.x86_64 : Minimalistic C client library for Redis
    opensips-redis.x86_64 : Redis connector
    pcp-pmda-redis.x86_64 : Performance Co-Pilot (PCP) metrics for Redis
    perl-Apache-Session-Redis.noarch : Redis driver for Apache::Session::NoSQL
    perl-Redis.noarch : Perl binding for Redis database
    php-nrk-Predis.noarch : PHP client library for Redis
    php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php-phpiredis.x86_64 : Client extension for Redis
    php54-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php54-php-phpiredis.x86_64 : Client extension for Redis
    php55-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php55-php-phpiredis.x86_64 : Client extension for Redis
    php56-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php56-php-phpiredis.x86_64 : Client extension for Redis
    php70-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php70-php-phpiredis.x86_64 : Client extension for Redis
    php71-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php71-php-phpiredis.x86_64 : Client extension for Redis
    php72-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php72-php-phpiredis.x86_64 : Client extension for Redis
    python-redis.noarch : Python 2 interface to the Redis key-value store
    python-trollius-redis.noarch : Redis client for the Python event loop PEP3156 for Trollius.
    python2-django-redis.noarch : Full featured redis cache backend for Django
    redis-trib.noarch : Cluster management script for Redis
    rubygem-redis.noarch : A Ruby client library for Redis
    rubygem-redis-doc.noarch : Documentation for rubygem-redis
    syslog-ng-redis.x86_64 : redis support for syslog-ng
    uwsgi-logger-redis.x86_64 : uWSGI - redislog logger plugin
    uwsgi-router-redis.x86_64 : uWSGI - Plugin for Redis router support
    redis.x86_64 : A persistent key-value database
    
      Name and summary matches only, use "search all" for everything.
    [root@vps154294 smartfst]# 
    

    In this server, we have PHP 7.0 installed. So we need to install packages for PHP 7.0

    Here are the two packages for PHP 7.0

    php70-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
    php70-php-phpiredis.x86_64 : Client extension for Redis
    

    Install it with yum

    yum install -y php70-php-pecl-redis.x86_64 php70-php-phpiredis.x86_64
    

    Now you need to restart web server, generally restarting apache will do. In this cause PHP is running as php-fpm under nginx, so we need to restart php-fpm with

    systemctl restart php-fpm
    
  • Installing Redis On CentOS 7

    To install Redis on CentOS, run

    yum install redis

    Start redis with

    service redis start
    

    Set redis to start on boot

    systemctl enable redis
    

    Verify redis is running with

    [root@vps154294 ~]# netstat -antp | grep redis
    tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      32367/redis-server  
    [root@vps154294 ~]# 
    
  • Install vnc server on CentOS 5

    NOTE: CentOS 5 reached its End of Life on March 31, 2017. For installing VNC desktop on CentOS 7, see Install Xfce VNC remote desktop on CentOS 7

    Install GUI on Sever

    To find available desktop environments

    yum grouplist
    

    To install gnome

    yum groupinstall "GNOME Desktop Environment"
    

    For KDE

    yum groupinstall "KDE (K Desktop Environment)"
    

    For XFCE, install

    yum groupinstall "XFCE"
    

    XFCE file size in fedora 12 Total download size: 105 M, Installed size: 363 M

    Install VNC Server

    yum install vnc vnc-server
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    You will require a password to access your desktops.
    
    Password:
    Verify:
    xauth:  creating new authority file /root/.Xauthority
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Now stop vnc server with

    pkill -9 vnc
    rm -rf /tmp/.X*
    

    Set Password for VNC Server

    vncpasswd /root/.vnc/passwd
    
    [root@pc7 ~]# vncpasswd /root/.vnc/passwd
    Password:
    Verify:
    [root@pc7 ~]#
    

    Edit xstartup

    vi  /root/.vnc/xstartup
    

    Find

    twm &
    

    Replace it with

    For Gnome

    gnome-session &
    

    For XFCE

    startxfce4 &
    

    For KDE

    startkde &
    

    For FVWM2

    fvwm2 &
    

    After change, it will look like

    [root@pc7 ~]# cat /root/.vnc/xstartup
    #!/bin/sh
    
    vncconfig -iconic &
    # Uncomment the following two lines for normal desktop:
    # unset SESSION_MANAGER
    # exec /etc/X11/xinit/xinitrc
    
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    gnome-session &
    [root@pc7 ~]#
    

    Create VNC Users

    vi /etc/sysconfig/vncservers
    

    Add

    VNCSERVERS="1:flashwebhost"
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Connecting

    Start tightVNC Viewer, connect to IP-ADDR:1 to connect as user root.

    See VNC server