Category: Linux

  • Install PHP 7.1 php-fpm from source

    Lets install the requirements.

    On CentOS, run

    yum -y install libxml2-devel libcurl-devel libmcrypt-devel openssl-devel
    yum -y install libjpeg-turbo-devel libpng-devel freetype-devel libtidy-devel
    

    Before you can install, you need to check MySQL socket location. To do this, run following command in MySQL command prompt.

    show variables like '%socket%;
    

    Find MySQL socket

    Download and install PHP 7.1 from source

    mkdir /usr/local/src
    cd /usr/local/src
    wget http://php.net/get/php-7.1.12.tar.gz/from/this/mirror -O php-7.1.12.tar.gz
    tar xf php-7.1.12.tar.gz
    cd php-7.1.12
    make clean
    ./configure --prefix=/usr/serverok/php-7.1.12 \
    --with-config-file-path=/usr/serverok/php-7.1.12/etc \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-pdo-mysql \
    --with-mysqli \
    --enable-cgi \
    --with-zlib \
    --with-gettext \
    --enable-ftp \
    --enable-calendar \
    --enable-bcmath \
    --enable-sockets \
    --with-curl \
    --with-gd \
    --with-jpeg-dir=/usr/local \
    --enable-mbstring \
    --with-freetype-dir=/usr/local \
    --with-mhash=/usr/local --enable-exif \
    --with-mcrypt=/usr \
    --with-tidy \
    --with-openssl \
    --enable-zip \
    --enable-fpm
    make && make install
    

    Copy the configuration files

    cp /usr/serverok/php-7.1.12/etc/php-fpm.conf.default /usr/serverok/php-7.1.12/etc/php-fpm.conf
    cp /usr/serverok/php-7.1.12/etc/php-fpm.d/www.conf.default /usr/serverok/php-7.1.12/etc/php-fpm.d/www.conf
    cp /usr/local/src/php-7.1.12/php.ini-development /usr/serverok/php-7.1.12/etc/php.ini
    

    Now you will be able to start php-fpm by running

    /usr/serverok/php-7.1.12/bin/php
    

    By default php-fpm will run using tcp port 9000, it is better to change it to use unix socket, for this

    vi /usr/serverok/php-7.1.12/etc/php-fpm.d/www.conf
    

    Find

    listen = 127.0.0.1:9000
    

    Replace with

    listen = /var/run/php-fpm/proxy.sock
    

    php-fpm user

    You need to configure the user account used to run php-fpm, if you don’t use proper account, you may get permission errors.

    The account you use vary depending on OS, Web server. For example, nginx use account nginx. Apache on Ubuntu/Debian use www-data. Apache on CentOS use nobody.

    Here is what i have on a server running Nginx web server

    [root@vps154294 ~]# cat /usr/serverok/php-7.1.12/etc/php-fpm.d/www.conf | grep nginx
    user = nginx
    group = nginx
    listen.owner = nginx
    listen.group = nginx
    [root@vps154294 ~]# 
    

    Systemd Service

    To easily manage php-fpm, lets create a php-fpm.service file.

    Before we do this, edit

    vi /usr/serverok/php-7.1.12/etc/php-fpm.conf
    

    Find

    ;pid = run/php-fpm.pid
    

    Add below

    pid = /run/php-fpm/php-fpm.pid
    

    Find

    ;error_log = log/php-fpm.log
    

    Add below

    error_log = /var/log/php-fpm/error.log
    

    Save and exit.

    Now lets create file /usr/lib/systemd/system/php-fpm.service

    vi /usr/lib/systemd/system/php-fpm.service
    

    Add following content

    [Unit]
    Description=PHP FastCGI process manager
    After=syslog.target network.target
    
    [Service]
    PIDFile=/run/php-fpm/php-fpm.pid
    ExecStartPre=/bin/mkdir --parents /run/php-fpm
    ExecStart=/usr/serverok/php-7.1.12/sbin/php-fpm --nodaemonize
    ExecReload=/bin/kill -USR2 $MAINPID
    Type=simple
    
    [Install]
    WantedBy=multi-user.target
    

    Enable php-fpm with

    systemctl enable php-fpm
    

    Now you will be able to use systemctl to start/stop/restart php-fpm

    systemctl start php-fpm
    systemctl stop php-fpm
    systemctl restart php-fpm
    

    systemctl status php-fpm

  • 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 ~]# 
    
  • huawei e8231 usb modeswitch

    By default, device work in Mass Storage mode

    root@fwhlin:~ # lsusb | grep Huawei
    Bus 009 Device 007: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
    root@fwhlin:~ # 
    

    Create file

    vi /etc/usb_modeswitch.d/12d1:1f01
    

    With following content

    root@fwhlin:~ # cat /etc/usb_modeswitch.d/12d1:1f01
    # Huawei E3531s-2 - switch to modem mode instead of HiLink CDC-Ether mode
    TargetVendor=0x12d1
    TargetProduct=0x1f01
    
    # switch to 12d1:1001 (modem mode, 3 virtual serial ports)
    #MessageContent="55534243123456780000000000000011062000000100000000000000000000"
    
    # switch to 12d1:14dc (default HiLink CDC-Ether mode)
    MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
    
    # switch to 12d1:1442 (debug mode with 2 virtual serial ports)
    # MessageContent="55534243000000000000000000000011060000000000000000000000000000"
    
    root@fwhlin:~ # 
    

    To switch to Modem Mode, run

    usb_modeswitch -I -W -c /etc/usb_modeswitch.d/12d1\:1f01
    

    If it worked, device will change to modem mode

    root@fwhlin:~ # lsusb | grep Hu
    Bus 009 Device 003: ID 12d1:14dc Huawei Technologies Co., Ltd. 
    root@fwhlin:~ # 
    

    Notice it changed name, also device ID changed to 14dc.

    ifconfig will list a new network interface usb0

    usb0      Link encap:Ethernet  HWaddr 9a:82:a1:91:20:32  
              inet6 addr: fe80::9882:a1ff:fe91:2032/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:236 errors:0 dropped:0 overruns:0 frame:0
              TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:111083 (111.0 KB)  TX bytes:15412 (15.4 KB)
    
  • getting huawei e8231 work on ubuntu 14.04

    After connecting, i get following in lsusb

    root@fwhlin:~ # lsusb | grep 12d1
    Bus 009 Device 004: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
    root@fwhlin:~ # 
    

    It says “Mass storage mode”. If you check demesg, you will see

    [ 2385.775523] usb 9-2: New USB device found, idVendor=12d1, idProduct=1f01
    [ 2385.775527] usb 9-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 2385.775529] usb 9-2: Product: HUAWEI Mobile
    [ 2385.775531] usb 9-2: Manufacturer: HUAWEI
    [ 2385.775532] usb 9-2: SerialNumber: FFFFFFFFFFFFFFFF
    [ 2385.837882] usb-storage 9-2:1.0: USB Mass Storage device detected
    [ 2385.838108] scsi15 : usb-storage 9-2:1.0
    [ 2386.858462] scsi 15:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
    [ 2386.859826] sr1: scsi-1 drive
    [ 2386.859946] sr 15:0:0:0: Attached scsi CD-ROM sr1
    

    Last line says, device mounted as “/dev/sr1”

    root@fwhlin:~ # df -h | grep sr
    /dev/sr1        4.3M  4.3M     0 100% /media/boby/MobileWiFi
    root@fwhlin:~ # 
    

    Changing Device Mode to Modem

    I found some information about the device in file

    sudo -s
    cd /usr/share/usb_modeswitch
    tar zxvf configPack.tar.gz
    
    root@fwhlin:~ # cat /usr/share/usb_modeswitch/12d1:1f01
    # Huawei E353 (3.se) and others
    TargetVendor=0x12d1
    TargetProductList="14db,14dc"
    MessageContent="55534243123456780000000000000011062000000101000100000000000000"
    NoDriverLoading=1
    root@fwhlin:~ # 
    

    It says device can operate as products “14db” and “14dc”.

    I tried changing device mode to product id 14db, it did not work, so tried 14dc and it worked.

    usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14dc -M "55534243123456780000000000000011062000000101000100000000000000"
    
    root@fwhlin:~ # usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14dc -M "55534243123456780000000000000011062000000101000100000000000000"
    Look for target devices ...
     No devices in target mode or class found
    Look for default devices ...
       product ID matched
     Found devices in default mode (1)
    Access device 002 on bus 009
    Current configuration number is 1
    Use interface number 0
    Use endpoints 0x01 (out) and 0x81 (in)
    
    USB description data (for identification)
    -------------------------
    Manufacturer: HUAWEI
         Product: HUAWEI Mobile
      Serial No.: FFFFFFFFFFFFFFFF
    -------------------------
    Looking for active driver ...
     No active driver found. Detached before or never attached
    Set up interface 0
    Use endpoint 0x01 for message sending ...
    Trying to send message 1 to endpoint 0x01 ...
     OK, message successfully sent
    Reset response endpoint 0x81
    Reset message endpoint 0x01
    -> Run lsusb to note any changes. Bye!
    
    root@fwhlin:~ #
    

    Now “ifconfig” shows usb0.

    root@fwhlin:~ # ifconfig
    ...
    ...
    ...
    usb0      Link encap:Ethernet  HWaddr be:69:7c:b1:a3:b6  
              inet addr:192.168.8.100  Bcast:192.168.8.255  Mask:255.255.255.0
              inet6 addr: fe80::bc69:7cff:feb1:a3b6/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:15 errors:0 dropped:0 overruns:0 frame:0
              TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:6315 (6.3 KB)  TX bytes:8138 (8.1 KB)
    
    root@fwhlin:~ # 
    

    If you check “lsusb”, now device have different product id.

    root@fwhlin:~ # lsusb | grep 12d1
    Bus 009 Device 003: ID 12d1:14dc Huawei Technologies Co., Ltd. 
    root@fwhlin:~ # 
    

    Connecting To Internet

    You will need to disable eth0 or all traffic will be routed through it by default.

    suo ifconfig eth0 down
    
    root@fwhlin:~ # curl http://iptools.bizhat.com/ipv4.php
    59.98.137.87
    root@fwhlin:~ # sudo ifconfig eth0 down
    root@fwhlin:~ # curl http://iptools.bizhat.com/ipv4.php
    106.77.164.191
    root@fwhlin:~ #
    
  • set default view to list in nemo file manager

    By default files are displayed with “Icon View”

    linux mint nemo

    I prefer list view.

    linux mint nemo

    To set default view in Nemo, go to

    Edit -> Preferences -> Views (tab) -> View new folders using -> List View
    

    linux mint nemo Preferences

  • Disable hot corner in Linux Mint

    To disable hot corner in linux mint, go to settings

    linux mint system settings

    Go to advanced settings

    linux mint advanced settings

    Click Hot Corners,

    From the dorp down, select Disabled.

  • Can’t locate File/Type.pm in @INC

    Xpanel FTP not deleting .exe file uploads.

    [root@server1 ~]# /usr/local/xpanel/uploadscript.pl
    Can't locate File/Type.pm in @INC (@INC contains: /usr/local/xpanel/ /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/xpanel/uploadscript.pl line 27.
    BEGIN failed--compilation aborted at /usr/local/xpanel/uploadscript.pl line 27.
    [root@server1 ~]#
    

    To fix, install File::Type cpan module.

    cpan
    install File::Type
    

    See Errors

  • modinfo radeon

    radeon is the open source driver.

    bizhat ~ # modinfo radeon
    filename:       /lib/modules/3.11.0-12-generic/kernel/drivers/gpu/drm/radeon/radeon.ko
    license:        GPL and additional rights
    description:    ATI Radeon
    author:         Gareth Hughes, Keith Whitwell, others.
    firmware:       radeon/R520_cp.bin
    firmware:       radeon/PALM_pfp.bin
    ----REMOVED LOT OF JUNK TEXT----
    firmware:       radeon/BONAIRE_pfp.bin
    srcversion:     E46AD784A528F70150F5BFD
    alias:          pci:v00001002d000099A4sv*sd*bc*sc*i*
    ----REMOVED LOT OF JUNK TEXT----
    alias:          pci:v00001002d00001304sv*sd*bc*sc*i*
    depends:        drm,drm_kms_helper,ttm,i2c-algo-bit
    intree:         Y
    vermagic:       3.11.0-12-generic SMP mod_unload modversions 
    parm:           no_wb:Disable AGP writeback for scratch registers (int)
    parm:           modeset:Disable/Enable modesetting (int)
    parm:           dynclks:Disable/Enable dynamic clocks (int)
    parm:           r4xx_atom:Enable ATOMBIOS modesetting for R4xx (int)
    parm:           vramlimit:Restrict VRAM for testing (int)
    parm:           agpmode:AGP Mode (-1 == PCI) (int)
    parm:           gartsize:Size of PCIE/IGP gart to setup in megabytes (32, 64, etc) (int)
    parm:           benchmark:Run benchmark (int)
    parm:           test:Run tests (int)
    parm:           connector_table:Force connector table (int)
    parm:           tv:TV enable (0 = disable) (int)
    parm:           audio:Audio enable (1 = enable) (int)
    parm:           disp_priority:Display Priority (0 = auto, 1 = normal, 2 = high) (int)
    parm:           hw_i2c:hw i2c engine enable (0 = disable) (int)
    parm:           pcie_gen2:PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable) (int)
    parm:           msi:MSI support (1 = enable, 0 = disable, -1 = auto) (int)
    parm:           lockup_timeout:GPU lockup timeout in ms (defaul 10000 = 10 seconds, 0 = disable) (int)
    parm:           fastfb:Direct FB access for IGP chips (0 = disable, 1 = enable) (int)
    parm:           dpm:DPM support (1 = enable, 0 = disable, -1 = auto) (int)
    parm:           aspm:ASPM support (1 = enable, 0 = disable, -1 = auto) (int)
    bizhat ~ #
    
  • Can’t locate Parallel/ForkManager.pm in @INC

    On running a perl program, i get error

    Can't locate Parallel/ForkManager.pm in @INC
    

    Lets search with yum and see which package provide ForkManager.

    [root@linux ~]# yum search forkmanager
    =============== Matched: forkmanager ===============
    perl-Parallel-ForkManager.noarch : Simple parallel processing fork manager
    [root@linux ~]#
    

    To fix install perl-Parallel-ForkManager.noarch

    yum install perl-Parallel-ForkManager.noarch
    

    See errors