Updates from starway Toggle Comment Threads | 快速鍵

  • starway 3:24 pm on March 11, 2019 固定鏈結 | 回應  

    How to Install PHP OPCache APC/APCu Memcached and Redis on VestaCP CentOS 

    來源:https://www.mysterydata.com/how-to-install-php-opcache-apc-apcu-memcached-and-redis-on-vesta-cp-centos/

    In this tutorial we’ll implement and install various type of opcache and object cache in order to increase the performance of your websites and lower the loads for server.

    OPCache and object cache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

    In other words, a PHP script when it is executed, is compiled into opcode/object cache (memcache and redis), code that is understandable by the machine. OPCache and object cache stores this code into memory on the first execution, to be reused afterwards, thus leading to performance boosts.

    Lets get Started :

    First install Remi repo :

    CentOS 7

    wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm
    

    CentOS 6

    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm

    To install Zend Opcache :

    OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

    yum install php-opcache
    

    After installation you need to restart Apache/php-fpm :

    if you’re using Apache (mod_php) :

    service httpd restart
    

    If you’re using PHP-FPM :

    service php-fpm restart
    

    To install APC/APCu :

    APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.

    yum install php-pecl-apcu
    

    After installation you need to restart Apache/php-fpm :

    if you’re using Apache (mod_php) :

    service httpd restart
    

    If you’re using PHP-FPM :

    service php-fpm restart
    

    To install Memcached :

    Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

    For PHP 5.xx

    yum install memcached memcached-devel php-pecl-memcache
    

    For PHP 7.xx

    yum install memcached memcached-devel php-pecl-memcached
    

    Start memcached Service :

    service memcached start
    

    Start the memcached on boot :
    Centos 6 :

    chkconfig memcached on
    

    Centos 7 :

    systemctl enable memcached
    

    After installation you need to restart Apache/php-fpm :

    if you’re using Apache (mod_php) :

    service httpd restart
    

    If you’re using PHP-FPM :

    service php-fpm restart
    

    To install Redis :

    Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

    yum install redis php-pecl-redis
    

    Start Redis Service :

    service redis start
    

    Start the Redis on boot :
    Centos 6 :

    chkconfig redis on
    

    Centos 7 :

    systemctl enable redis
    

    After installation you need to restart Apache/php-fpm :

    if you’re using Apache (mod_php) :

    service httpd restart
    

    If you’re using PHP-FPM :

    service php-fpm restart
    
    廣告
     
  • starway 9:48 am on March 8, 2019 固定鏈結 | 回應  

    How to Upgrade PHP 5.6 to PHP 7.3 on CentOS VestaCP 

    來源:https://www.mysterydata.com/how-to-upgrade-php-5-6-to-php-7-3-on-centos-vestacp/

    In this tutorial I’ll show you how to upgrade PHP 5.6.xx which is by default installed by Vesta CP during installation to PHP 7.3.xx latest, I’ve tested on many server before writing this tutorial and its just working fine without any issue hence it is safe to upgrade to PHP 7.3 please be sure your script is compatible with php 7.3, part of this tutorial is copied from remi repository.

    Why upgrade to php 7.3 –  Because it will give you security & performance boost + KICK, since WordPress will load much faster and uses less resources. And php 7.3 is 5% faster than any other previous version.

    Upgrade to php 7.2 : https://www.mysterydata.com/upgrade-php-5-6-php-7-2-centos-vesta-cp/

    STEP 1 :

    Install Remi Repository and EPEL Repository on your server :

    RHEL 7

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
    subscription-manager repos --enable=rhel-7-server-optional-rpms

    RHEL 6

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
    rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

    CentOS 7

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
    

    CentOS 6

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm

    STEP 2 :

    After you have installed repository you need to follow some extra configurations :

    Run this command one by one for RHEL or CentOS

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

     STEP 3 :

    Now just run this command :

    yum update -y

    You’ll see php packages are getting updated, After the update process you need to restart Apache server/php-fpm-(nginx) and check the php version from by below mentioned command:

    php -v
    [root@server ~]# php -v
    PHP 7.3.0 (cli) (built: Dec  4 2018 16:12:20) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies
    

    Troubleshoot

    If php upgrade process fails (no update/nothing happens) or you upgraded previously from 5.6 to 7.0/7.1/7.2 then you need to run this commands to disable php 5.6/7.0/7.1/7.2 :

    yum-config-manager --disable remi-php56
    yum-config-manager --disable remi-php70
    yum-config-manager --disable remi-php71
    yum-config-manager --disable remi-php72
    

    After that follow the tutorial from STEP 2 again.

     
  • starway 9:45 am on March 8, 2019 固定鏈結 | 回應  

    How to Upgrade PHP 5.6 to PHP 7.2 on CentOS VestaCP 

    來源:https://www.mysterydata.com/upgrade-php-5-6-php-7-2-centos-vesta-cp/

    In this tutorial I’ll show you how to upgrade PHP 5.6.xx which is by default installed by Vesta CP during installation to PHP 7.2.xx latest, I’ve tested on many server before writing this tutorial and its just working fine without any issue hence it is safe to upgrade to PHP 7.2, part of this tutorial is copied from remi repository.

    Why upgrade to php 7.2 –  Because it will give you security & performance boost + KICK, since WordPress will load much faster and uses less resources.

    Upgrade to php 7.3 : https://www.mysterydata.com/how-to-upgrade-php-5-6-to-php-7-3-on-centos-vestacp/

    STEP 1 :

    Install Remi Repository and EPEL Repository on your server :

    RHEL 7

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
    subscription-manager repos --enable=rhel-7-server-optional-rpms

    RHEL 6

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
    rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

    CentOS 7

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
    

    CentOS 6

    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm

    STEP 2 :

    After you have installed repository you need to follow some extra configurations :

    Run this command one by one for RHEL or CentOS

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

     STEP 3 :

    Now just run this command :

    yum update -y

    You’ll see php packages are getting updated, After the update process you need to restart Apache server/php-fpm-(nginx) and check the php version from by below mentioned command:

    php -v
    [root@server ~]# php -v
    PHP 7.2.7 (cli) (built: Jun 20 2018 08:21:26) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.2.7, Copyright (c) 1999-2018, by Zend Technologies
    

    Troubleshoot

    If php upgrade process fails (no update/nothing happens) or you upgraded previously from 5.6 to 7.0/7.1 then you need to run this commands to disable php 5.6/7.0/7.1 :

    yum-config-manager --disable remi-php56
    yum-config-manager --disable remi-php70
    yum-config-manager --disable remi-php71
    

    After that follow the tutorial from STEP 2 again.

     
  • starway 5:43 am on March 8, 2019 固定鏈結 | 回應  

    yum update 出現 Dependency 錯誤的解法 (2) 

    來源–https://ynotes.cn/blog/article_detail/127

    You could try using –skip-broken to work around the problem
    ** Found 41 pre-existing rpmdb problem(s), ‘yum check’ output follows:

    解决方法:
    $ yum install yum-utils
    $ package-cleanup –dupes
    $ package-cleanup –cleandupes
    $ yum update –skip-broken

     
  • starway 3:58 am on March 8, 2019 固定鏈結 | 回應  

    [CentOS] 解決 yum 出現 “Operation too slow” 問題 

    來源–https://becoder.org/centos-repair-yum-operation-slow/

     

    這幾天不管在 Proxmox VE 、還是 VMware ESXi ,裡面的 CentOS 7 一直遇到

    Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds

    讓一些沒有 mirror site 的程式一直安裝失敗,似乎是設備對國外連線有一點問題,延遲有點久,導致 VM 內的 yum 會 timeout。

     

    解決方法

    設定 yum 的 timeout:
    # echo "minrate=1" >> /etc/yum.conf

    1. echo "timeout=30000" >> /etc/yum.conf

     

    之後就不會有問題了,算是臨時解法,如果網路恢復正常記得把這兩行刪掉~

     
  • starway 3:03 am on March 8, 2019 固定鏈結 | 回應  

    【Linux】yum update 出現 Dependency 錯誤的解法 

    資料來源 — CentOS 6.6 (Final) – yum kernel upgrade troubles
    資料來源 — http://oldgrayduck.blogspot.com/2015/08/linuxyum-update-dependency.html

    在做 yum update 時出現錯誤,大意是

    Finished Dependency Resolution
    Error: Package: kernel-2.6.32-573.1.1.el6.x86_64 (centos6_x86_update)
           Requires: dracut-kernel >= 004-388.el6
           Installed: dracut-kernel-004-356.el6_6.3.noarch (@centos6_x86_update)
               dracut-kernel = 004-356.el6_6.3


    You could try using --skip-broken to work around the problem
    You could try running: rpm -Va --nofiles --nodigest

    可以試試

    先清空 yum 的 cache

    [root]# yum clean all

    再重做更新

    [root]# yum update

     
  • starway 1:40 pm on August 4, 2018 固定鏈結 | 回應
    Tags:   

    WooCommerce 購物網站的免運費機制 

    自動偵測免費運送的設定方法
    打開主題中的 functions.php
    將下方的程式片段碼貼入後存檔

    更新 for WC 2.6+

    /**

    • Hide shipping rates when free shipping is available.
    • Updated to support WooCommerce 2.6 Shipping Zones.
    • @param array $rates Array of rates found for the package.
    • @return array

    */
    add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_when_free_is_available’, 100 );
    function hide_shipping_when_free_is_available( $rates ) {
    $free = array();

    foreach ( $rates as $rate_id => $rate ) {
    if ( ‘free_shipping’ === $rate->method_id ) {
    $free[ $rate_id ] = $rate;
    break;
    }
    }

    return ! empty( $free ) ? $free : $rates;
    }

    更新 for WC 2.5

    /**

    • woocommerce_package_rates is a 2.1+ hook

    */
    add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_when_free_is_available’, 10, 2 );

    /**

    • Hide shipping rates when free shipping is available
    • @param array $rates Array of rates found for the package
    • @param array $package The package array/object being shipped
    • @return array of modified rates

    */
    function hide_shipping_when_free_is_available( $rates, $package ) {

    // Only modify rates if free_shipping is present
    if ( isset( $rates[‘free_shipping’] ) ) {

    // To unset a single rate/method, do the following. This example unsets flat_rate shipping
    unset( $rates[‘flat_rate’] );

    // To unset all methods except for free_shipping, do the following
    $free_shipping = $rates[‘free_shipping’];
    $rates = array();
    $rates[‘free_shipping’] = $free_shipping;
    }

    return $rates;
    }

    最後還要在 WooCommerce 的後台,設定免運費的金額限制

    參考:
    https://cloudwp.pro/blog/woocommerce-%E8%B3%BC%E7%89%A9%E7%B6%B2%E7%AB%99%E7%9A%84%E5%85%8D%E9%81%8B%E8%B2%BB%E6%A9%9F%E5%88%B6%E5%BB%BA%E8%AD%B0/

     
  • starway 3:12 pm on July 4, 2018 固定鏈結 | 回應
    Tags: css   

    Prevent Address-Bar hiding in mobile Browsers 

    html
    {
    overflow: hidden;
    width:100%;
    body
    {
    width:100%;
    height:100%;
    position:fixed; /* prevent overscroll bounce*/
    overflow-y:scroll;
    -webkit-overflow-scrolling: touch; /* iOS velocity scrolling */
    }
    }

     
  • starway 7:39 am on April 17, 2018 固定鏈結 | 回應
    Tags:   

    使用一個腳本監控mysql進程

    進入 cd /backup
    如果沒mysql資料夾
    建立 mysql資料夾
    mkdir mysql
    然後
    nano /backup/mysql/mysql.sh

    #!/bin/sh
    ps -fe|grep mysqld |grep -v grep
    if [ $? -ne 0 ]
    then
    echo “start process….."
    service mysql start
    else
    echo “runing….."
    fi

    DATE=`date +%Y%m%d%H%M%S`
    echo $DATE >> /backup/mysql/test.txt

    存檔

    nano /etc/crontab

    */1 * * * * root /backup/mysql/mysql.sh

    存檔

    crontab /etc/crontab

    然後更改檔案權限(這是 permission denied 解決方案)
    chmod 777 /backup/mysql
    chmod 777 /backup/mysql/mysql.sh

    備註:
    假如是 mariadb
    service mysql start 請修改成 systemctl restart mariadb

    參考文件 https://java-er.com/blog/mysql-restart/

     
  • starway 11:51 am on November 13, 2017 固定鏈結 | 回應  

    經緯度距離相關網站

    http://www.bijishequ.com/detail/256788?p=
    http://www.cnblogs.com/mgbert/p/4146538.html
    http://blog.csdn.net/liuxiaoshuang002/article/details/71122153
    https://www.wizzer.cn/archives/2254
    http://smallpoint-program.blogspot.tw/2014/12/php.html

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
回應
e
編輯
o
Show/Hide comments
t
至頂
l
Go to login
h
Show/Hide help
shift + esc
取消