Join the community today
Register Now

From oblivion to zen - moving from old server to new one

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Sunka, Nov 1, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:57 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    yes in theory it should work - just if you have permission issues, chown would be the first thing to try

     
  2. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    When I execute php --ri redis
    I see that by default phpredis is installed like memcache too. If I did not touche anything about memcache, it is not in use, so I can use redis, or I have to uninstall memcache first, or if I stop memcache, should it be running again after rebooting server?
    It is "cache" day, and I am confused.

    Is Redis server needed for phpredis which is installed by default?

    If I want to use redis to cache and store PHP sessions on Xenforo forum, first I have to install redis server like it is instructed in this post?

    Also, I am on KMV so I have to add to /etc/sysctl.conf this: vm.overcommit_memory = 1
    And then execute sysctl -p?

    When Using Redis as an LRU cache is it better to set maxmemory to 0MB against 100 MB. The manual said "Setting maxmemory to zero results into no memory limits. This is the default behavior for 64 bit systems, while 32 bit systems use an implicit memory limit of 3GB." Is this connected with my CentOS 64 bit system, or is better to set maxmemory to 100MB?

    Then I enable AOF by changing to - appendonly yes

    After that I do not need setup phpredis for php cache because that is doing allready zend opcache by default (i have installed them when I upgrade php to 5.6.15), and I do not have to configure nothing for zend OPcache in zend opcache.ini file nor in XenForo's config.php, couse it is woring out of the box?

    And after all that, when I finally transfer my xenforo files and database to new server, I will have to install Xon addon for Zend Redis Cache for xenforo, add or edit in Xenforo library/config.php this rows:
    PHP:
    $config['cache']['enabled'] = true;
    $config['cache']['cacheSessions'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions'] = array(
    'caching' => true,
    'cache_id_prefix' => 'xfxx_',
    'automatic_serialization' => false,
    'lifetime' => 0
    );

    $config['cache']['backend'] = 'Redis';

    $config['cache']['backendOptions'] = array(
    'server' => '127.0.0.1',
    'port' => 6379,
    'use_lua' => true,
    );
    require(
    XenForo_Application::getConfigDir().'/SV/RedisCache/Installer.php');
    (cache_id_prefix i could set xfredis_ it does not to have be xfxx_?)

    and then flush redis server cache - redis-cli FLUSHALL

    So, If I understood corectlly:
    1. install redis server
    2. add to /etc/sysctl.conf this: vm.overcommit_memory = 1
    3. execute sysctl -p
    4. for using Redis as an LRU cache set maxmemory to xxMB (how much)
    5. enable AOF by changing to - appendonly yes
    6. transfer my xenforo files and database to new server
    7. Install xon addon
    8. edit Xenforo library/config.php
    9. set cache_id_prefix to xfredis_
    10. flush redis server cache - redis-cli FLUSHALL

    Should I do something before or after this steps?

    So, if I have configured redis like I wrote, and installed Zend OPcache, I do not install any other cache application for my forum?

    And question about flushing. Should I regullary flush cache for redis and/or opcache or it is done automatically with some kind of magic?

    When I reboot server is all applications restarted (nginx, mysql, redis, cache...) or not?

    Is it OK to put my database backups in /home/nginx/domains/pijanitvor.com/database_backup or in /home/nginx/domains/pijanitvor.com/private/database_backup

    How to get rid of "You have new mail in /var/spool/mail/root"

    @eva2000 - it is not much, but I have 5 usd on my paypal account, and I be glad to give you that ammount for donation for your help and your effort of creating centmin mod. If I ever won lottery, I will make you happy (y)
     
  3. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:57 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    you can leave memcached and redis server running simultaneously no need to stop if you have apps using memcached server otherwise only run what you need
    yes redis server needed - phpredis just allows php to talk to redis server
    yes
    yes
    set a limit to manage memory usage
    yes
    yes no need to configure anything for zend opcache
    yes and any prefix name of your choosing
    yes
    yup all you need to run redis cache xenforo addon
    nothing else for redis cache xenforo addon
    no need that's what maxmemory setting does
    if you installed redis server as outlined it will auto restart on reboot
    can put it anywhere you want besides /public which is public accessible and the spool mail is normal just ignore
    might want to save up for premium membership - some benefits there :)
     
  4. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    How many MB is good for my xenforo forum in your opinion?

    New VPS server (Droplet on Digital Ocean)
    Disk Space - 60 Gb
    Ram - 4 GB

    My XenForo forum specification
    XenForo - 1.5.1
    Database - 831 MB (about 126 MB zipped)
    Number of attachments - 3,601
    Attachments disk usage - 9,737 MB
    Addons - 66
    Posts - 243,337
    Users - 3,613 (online registered users in peak time is about 50 + guests)

    I mean, zend OPcache and rediris cache is all I need for forum, I do not have to install any other cache program?

    And others? When rebooting, every service installed on server is restarting/rebooting too (nginx, mysql...)?

    Is it recommended to not use swap file on hard disk when using redis cache?

    And about friendly url on Xenforo. Manual said to add this to nginx:
    Code:
    location /xf/ {
        try_files $uri $uri/ /xf/index.php?$uri&$args;
        index index.php index.html;
    }
    
    location /xf/internal_data/ {
        internal;
    }
    location /xf/library/ {
           internal;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }
    Also, it said that I change /xf/ paths to match your XenForo installation path.
    So it would be this?? - /home/nginx/domains/pijanitvor.com/public


    This is my virtual.conf

    Code:
    server {
    #  listen  80;
      listen  80 default_server backlog=2048 reuseport;
      server_name hostname.pijanitvor.com;
      root  html;
    
      access_log  /var/log/nginx/localhost.access.log  main buf$
      error_log  /var/log/nginx/localhost.error.log  error;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
      location /nginx_status {
      stub_status on;
      access_log  off;
      allow 127.0.0.1;
      #allow youripaddress;
      deny all;
      }
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
    #  Enables directory listings when index file not found
    #  autoindex  on;
    
    #  Shows file listing times as local time
    #  autoindex_localtime on;
    
    #  Enable for vBulletin usage WITHOUT vbSEO installed
    #  try_files  $uri $uri/ /index.php;
    
      }
    
      # example nginx-http-concat
      # /csstest/??one.css,two.css
      #location /csstest {
    
      #concat on;
      #concat_max_files 20;
      #}
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/include_opcache.conf;
    include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/phpstatus.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_mainserver.conf;
    
      }

    How to merge this two into one?
     
    Last edited: Nov 6, 2015
  5. rdan

    rdan Well-Known Member

    5,452
    1,418
    113
    May 25, 2014
    Ratings:
    +2,212
    Local Time:
    12:57 PM
    Mainline
    10.2
    I have a medium size forum, and I only use 32MB for Redis.
    So set it to 50MB would be fine.
    Yes.
    Just follow this guide: Nginx Rewrites for Xenforo Friendly Urls - CentminMod.com LEMP Nginx web stack for CentOS
     
  6. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Ah, I have that in my pijanitvor.com.conf
    So I do not need to change anything in virtual.conf?

    Is all conf's bellow configurated good for Xenforo forum and enabled friendly url

    pijanitvor.com.conf
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name pijanitvor.com;
                return 301 $scheme://www.pijanitvor.com$request_uri;
           }
    
    server {
      server_name pijanitvor.com www.pijanitvor.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/pijanitvor.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/pijanitvor.com/log/error.log;
    
      root /home/nginx/domains/pijanitvor.com/public;
    
    location / {
         index index.php index.html index.htm;
         try_files $uri $uri/ /index.php?$uri&$args;
    }
    
    location /internal_data/ {
         internal;
         allow 127.0.0.1;
         allow MYIPADDRESS;
         deny all;
    }
    
    location /library/ {
         internal;
         allow 127.0.0.1;
         allow MYIPADDRESS;
         deny all;
    }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    virtual.conf
    Code:
    server {
    #  listen  80;
      listen  80 default_server backlog=2048 reuseport;
      server_name hostname.pijanitvor.com;
      root  html;
    
      access_log  /var/log/nginx/localhost.access.log  main buf$
      error_log  /var/log/nginx/localhost.error.log  error;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
      location /nginx_status {
      stub_status on;
      access_log  off;
      allow 127.0.0.1;
      #allow youripaddress;
      deny all;
      }
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
    #  Enables directory listings when index file not found
    #  autoindex  on;
    
    #  Shows file listing times as local time
    #  autoindex_localtime on;
    
    #  Enable for vBulletin usage WITHOUT vbSEO installed
    #  try_files  $uri $uri/ /index.php;
    
      }
    
      # example nginx-http-concat
      # /csstest/??one.css,two.css
      #location /csstest {
    
      #concat on;
      #concat_max_files 20;
      #}
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/include_opcache.conf;
    include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/phpstatus.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_mainserver.conf;
    
      }
     
  7. rdan

    rdan Well-Known Member

    5,452
    1,418
    113
    May 25, 2014
    Ratings:
    +2,212
    Local Time:
    12:57 PM
    Mainline
    10.2
    Yes.
     
  8. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Hmmm, and what about pijanitvor.com.conf

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name pijanitvor.com;
                return 301 $scheme://www.pijanitvor.com$request_uri;
           }
    
    server {
      server_name pijanitvor.com www.pijanitvor.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/pijanitvor.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/pijanitvor.com/log/error.log;
    
      root /home/nginx/domains/pijanitvor.com/public;
    
    location / {
         index index.php index.html index.htm;
         try_files $uri $uri/ /index.php?$uri&$args;
    }
    
    location /internal_data/ {
         internal;
         allow 127.0.0.1;
         allow MYIPADDRESS;
         deny all;
    }
    
    location /library/ {
         internal;
         allow 127.0.0.1;
         allow MYIPADDRESS;
         deny all;
    }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }

    Manual said to add this:

    Code:
    location /xf/ {
        try_files $uri $uri/ /xf/index.php?$uri&$args;
        index index.php index.html;
    }
    
    location /xf/internal_data/ {
        internal;
    }
    location /xf/library/ {
           internal;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }
    My pijanitvor.com.conf is missing some parts, also it said that I change /xf/ paths to match your XenForo installation path.
    So it would be this?? - /home/nginx/domains/pijanitvor.com/public
     
  9. rdan

    rdan Well-Known Member

    5,452
    1,418
    113
    May 25, 2014
    Ratings:
    +2,212
    Local Time:
    12:57 PM
    Mainline
    10.2
    Dis-regard the guide on XF :)
    Very simple :).
    Some of the code you said was missing is already included on include /usr/local/nginx/conf/php.conf;.
     
  10. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    So my pijanitvor.com.conf is OK for Xenforo and friendly urls?
     
  11. rdan

    rdan Well-Known Member

    5,452
    1,418
    113
    May 25, 2014
    Ratings:
    +2,212
    Local Time:
    12:57 PM
    Mainline
    10.2
    I clean up your config:
    Code:
    server {
                listen   80;
                server_name pijanitvor.com;
                return 301 $scheme://www.pijanitvor.com$request_uri;
           }
    
    server {
        server_name www.pijanitvor.com;
    
        access_log /home/nginx/domains/pijanitvor.com/log/access.log combined buffer=256k flush=60m;
        error_log /home/nginx/domains/pijanitvor.com/log/error.log;
    
        root /home/nginx/domains/pijanitvor.com/public;
    
        location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$uri&$args;
        }
    
        location /internal_data/ {
            internal;
            allow 127.0.0.1;
            allow MYIPADDRESS;
            deny all;
        }
    
        location /library/ {
            internal;
            allow 127.0.0.1;
            allow MYIPADDRESS;
            deny all;
        }
    
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/php.conf;
        include /usr/local/nginx/conf/drop.conf;
        include /usr/local/nginx/conf/vts_server.conf;
    }
    That should work perfectly.
     
  12. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Salamat @RoldanLT (y)

    just one question
    why this change:
    from
    Code:
    server {
      server_name pijanitvor.com www.pijanitvor.com;
    to
    Code:
    server {
        server_name www.pijanitvor.com;
     
  13. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    I set it to 100MB, hope that is not too much?

    Also, when edited /etc/redis.conf I found line for enabling AOF, so I changed from appendonly no to appendonly yes but for a memory limit, eviction policy and LRU algorithm sample size i can not find lines except commented (#) officialy recommendations.
    So, I just add to the end of file:
    Code:
    maxmemory 100mb
    maxmemory-policy allkeys-lru
    maxmemory-samples 10
    Is that correct?
     
  14. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Regarding Redis server. When I execute redis-server in terminal, it shows me:
    Code:
    # redis-server
    12833:C 05 Nov 20:24:41.858 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
                    _._                                                
               _.-``__ ''-._                                           
          _.-``    `.  `_.  ''-._           Redis 3.0.5 (00000000/0) 64 bit
      .-`` .-```.  ```\/    _.,_ ''-._                                 
    (    '      ,       .-`  | `,    )     Running in standalone mode
    |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
    |    `-._   `._    /     _.-'    |     PID: 12833
      `-._    `-._  `-./  _.-'    _.-'                                 
    |`-._`-._    `-.__.-'    _.-'_.-'|                                
    |    `-._`-._        _.-'_.-'    |           http://redis.io      
      `-._    `-._`-.__.-'_.-'    _.-'                                 
    |`-._`-._    `-.__.-'    _.-'_.-'|                                
    |    `-._`-._        _.-'_.-'    |                                
      `-._    `-._`-.__.-'_.-'    _.-'                                 
          `-._    `-.__.-'    _.-'                                     
              `-._        _.-'                                         
                  `-.__.-'                                             
    
    12833:M 05 Nov 20:24:41.860 # Server started, Redis version 3.0.5
    12833:M 05 Nov 20:24:41.860 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    12833:M 05 Nov 20:24:41.860 * The server is now ready to accept connections on port 6379
    According redis manual:
    So,what should I do?


    if I execute this commands, will be something ruined on my server, or just redis will be configured like it should be?
    Code:
    echo 1 > /proc/sys/vm/overcommit_memory
    echo never > sys/kernel/mm/transparent_hugepage/enabled
    Or in this way:
    Add vm.overcommit_memory = 1 to /etc/sysctl.conf
    and then:
    Code:
    sysctl vm.overcommit_memory=1
    echo never > sys/kernel/mm/transparent_hugepage/enabled
     
  15. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:57 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    shouldn't need to run the command at all, just run
    Code:
    redis-cli FLUSHALL
    if that is what you're trying to do
    this way
     
  16. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:57 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    and it should be
    Code:
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    missing beginning forward slash
     
  17. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Just to be sure.
    Regardin that two errors, I have to do something, I can not just leave them?

    So, I have to do in this order:
    Add vm.overcommit_memory = 1 to /etc/sysctl.conf
    and then:
    Code:
    sysctl vm.overcommit_memory=1
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    redis-cli FLUSHALL
     
  18. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:57 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    yup do those changes
     
  19. rdan

    rdan Well-Known Member

    5,452
    1,418
    113
    May 25, 2014
    Ratings:
    +2,212
    Local Time:
    12:57 PM
    Mainline
    10.2
    It's redundant since you declare it on first server block.
     
  20. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Finnaly I upload all files and restore database. I managed dns servers so I probably must wait for dns to refreshing.
    Is there some chance to see webpage on new server directly, before dns changed? All I can see now is default nginx page.

    Also, regarding database and config.php from xenforo.
    I have one database on server, and two users have all privileges on database, root user and new created user.
    Which one to put into config.php for xenforo?