Get the most out of your Centmin Mod LEMP stack
Become a Member

Magento Configuration Centmin Mod with magento

Discussion in 'Ecommerce / Shopping cart usage' started by reallove0810, Jan 16, 2015.

  1. reallove0810

    reallove0810 New Member

    22
    10
    3
    Jan 3, 2015
    Ratings:
    +11
    Local Time:
    6:09 AM
    1.7.9
    5.5.41
    Hello, after a short time I using Centmind Mod. I have some experience to share. I spent 3 days to 1 week for a stable configuration for magento.
    1. The first you need to enable Innodb in /etc/my.cnf
    From this
    Code:
    skip-innodb
    To this
    Code:
    #skip-innodb
    Because by default Centmin Mod disable this type of database. So if you dont want to see your magento site run with asynchronous data. You need turn it on. I highly recommend @eva2000 enable Innodb by default in new version of Centmin Mod.
    And you can change default character set to utf8 if your language is imcompatible with latin1. That is also important. Then restart sql server.
    Code:
    character-set-server=utf8
    2. Configuration for nginx.
    I keep the default nginx.conf of Centmin Mod.
    I created new staticfiles_magento.conf by copy content of this file /usr/local/nginx/conf/staticfiles.conf.
    And edit the new file with comment out on section html|htm|txt like bellow. If not comment out, 404 not found will appear :)
    Then upload to /usr/local/nginx/conf/
    Code:
        location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
    	gzip_static off;
    	#add_header Pragma public;
    	add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    	access_log off;
    	expires 1d;
    	break;
            }
    
        location ~* \.(js)$ {
    	#add_header Pragma public;
    	add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    	access_log off;
    	expires 1d;
    	break;
            }
    
        location ~* \.(css)$ {
    	#add_header Pragma public;
    	add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    	access_log off;
    	expires 1d;
    	break;
            }
    
        #location ~* \.(html|htm|txt)$ {
    	#add_header Pragma public;
    	#add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    	#access_log off;
    	#expires 1d;
    	#break;
        #    }
    
        location ~* \.(eot|svg|ttf|woff)$ {
    	#add_header Pragma public;
    	add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    	access_log off;
    	expires 1d;
    	break;
            }
    
    Now edit /usr/local/nginx/conf/conf.d/yoursite.com.conf
    It worked with www and non-www.

    Code:
    server {
        listen 80;
    ## SSL directives might go here
        server_name yoursite.com www.yoursite.com;
        root /home/nginx/domains/yoursite.com/public;
    	access_log /home/nginx/domains/yoursite.com/log/access.log combined buffer=32k;
    	error_log /home/nginx/domains/yoursite.com/log/error.log;
     
        location / {
            index index.php index.html; ## Allow a static html file to be shown first
            try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
            expires 30d; ## Assume all files are cachable
        }	
     
        ## These locations would be hidden by .htaccess normally
        location ^~ /app/                { deny all; }
        location ^~ /includes/           { deny all; }
        location ^~ /lib/                { deny all; }
        location ^~ /media/downloadable/ { deny all; }
        location ^~ /pkginfo/            { deny all; }
        location ^~ /report/config.xml   { deny all; }
        location ^~ /var/                { deny all; }
     
        location /var/export/ { ## Allow admins only to view export folder
            auth_basic           "Restricted"; ## Message shown in login window
            auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
            autoindex            on;
        }
     
        location  /. { ## Disable .htaccess and other hidden files
            return 404;
        }
     
        location @handler { ## Magento uses a common front handler
            rewrite / /index.php;
        }
     
        location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }
     
        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
     
            expires        off; ## Do not cache dynamic content
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  HTTPS $server_https;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
            fastcgi_param  MAGE_RUN_TYPE store;
            include        fastcgi_params; ## See /etc/nginx/fastcgi_params
        }
      include /usr/local/nginx/conf/staticfiles_magento.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
    I think it's ok with above configuration. Ex: http://www.yoursite.com/funiture.html will only redirect to http://yoursite.com (not http://yoursite.com/funiture.html). If you want more exactly redirect. Example: (http://www.yoursite.com/funiture.html to http://yoursite.com/funiture.html; or http://yoursite.com/funiture.html to http://www.yoursite.com/funiture.html.) You need to change the head part of yoursite.conf like this. Remember to change your url in Magento admin (System => Configuration => Web => Unsecure + Secure

    Non-www
    Code:
    server {
        listen 80;
        server_name www.yoursite.com;
        rewrite / $scheme://yoursite.com$request_uri permanent;
    }
    
    server {
        listen 80;
    ## SSL directives might go here
        server_name yoursite.com *.yoursite.com;
        root /home/nginx/domains/yoursite.com/public;
        access_log /home/nginx/domains/yoursite.com/log/access.log combined buffer=32k;
        error_log /home/nginx/domains/yoursite.com/log/error.log;
    
    With www

    Code:
    server {
        listen 80;
        server_name yoursite.com;
        rewrite / $scheme://www.$host$request_uri permanent;
    }
    
    server {
        listen 80;
    ## SSL directives might go here
        server_name www.yoursite.com *.yoursite.com;
        access_log /home/nginx/domains/yoursite.com/log/access.log combined buffer=32k;
        error_log /home/nginx/domains/yoursite.com/log/error.log;
    
    If you are using ssl, you could edit like this.

    Code:
    server {
    	listen 80;
            listen 443 ssl spdy;
    		ssl_certificate      /usr/local/nginx/conf/ssl/yoursitecom/ssl-unified.crt;
            ssl_certificate_key  /usr/local/nginx/conf/ssl/yoursitecom/yoursite_com.key;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_session_cache      shared:SSL:10m;
            ssl_session_timeout  10m;
            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
            ssl_prefer_server_ciphers   on;
            add_header Alternate-Protocol  443:npn-spdy/3;
            #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
            #add_header  X-Content-Type-Options "nosniff";
            #add_header X-Frame-Options DENY;
            # nginx 1.5.9+ or higher 
            # http://nginx.org/en/docs/http/ngx_http_spdy_module.html#spdy_headers_comp
            # http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size
            # spdy_headers_comp 0;
            # ssl_buffer_size 4k;
    
            # enable ocsp stapling
            resolver 8.8.8.8;
            ssl_stapling on;
            ssl_stapling_verify on;
            #ssl_trusted_certificate /usr/local/nginx/conf/ssl/yoursitecom/ssl-trusted.crt;
        server_name yoursite.com *.yoursite.com;
        root /home/nginx/domains/yoursite.com/public;
    	access_log /home/nginx/domains/yoursite.com/log/access.log combined buffer=32k;
    	error_log /home/nginx/domains/yoursite.com/log/error.log;
     
        location / {
            index index.php index.html; ## Allow a static html file to be shown first
            try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
            expires 30d; ## Assume all files are cachable
        }
    	
    	location /blog {
    	try_files $uri $uri/ /blog/index.php?q=$request_uri;
    	}
    	
    	location /wp {
    	try_files $uri $uri/ /wp/index.php?q=$request_uri;
    	}
     
        ## These locations would be hidden by .htaccess normally
        location ^~ /app/                { deny all; }
        location ^~ /includes/           { deny all; }
        location ^~ /lib/                { deny all; }
        location ^~ /media/downloadable/ { deny all; }
        location ^~ /pkginfo/            { deny all; }
        location ^~ /report/config.xml   { deny all; }
        location ^~ /var/                { deny all; }
     
        location /var/export/ { ## Allow admins only to view export folder
            auth_basic           "Restricted"; ## Message shown in login window
            auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
            autoindex            on;
        }
     
        location  /. { ## Disable .htaccess and other hidden files
            return 404;
        }
     
        location @handler { ## Magento uses a common front handler
            rewrite / /index.php;
        }
     
        location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }
     
        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
     
            expires        off; ## Do not cache dynamic content
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  HTTPS $server_https;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
            fastcgi_param  MAGE_RUN_TYPE store;
            include        fastcgi_params; ## See /etc/nginx/fastcgi_params
        }
      include /usr/local/nginx/conf/staticfiles_magento.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
    If you force customers to use https. You can remove listen 80 and uncomment at
    Code:
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
    In addition. If you use wordpress intergration extension WordPress Integration - Magento Connect
    You need to add something like this. It depends on the url you setup.
    Code:
    location /blog {
    	try_files $uri $uri/ /blog/index.php?q=$request_uri;
    	}
    	
    	location /wp {
    	try_files $uri $uri/ /wp/index.php?q=$request_uri;
    	}
    
     
    • Like Like x 5
  2. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    excellent guide @reallove0810 (y)

    Makes me very happy to see other Centmin Mod users share their experiences and know how for the rest of the Centmin Mod community :D

    As to why InnoDB is disabled by default, it's default to fact that not everyone starts with a fresh set of MySQL databases. Some folks are migrating data from other servers with existing MySQL databases etc. So leave InnoDB on/off status up to end users.
     
    • Like Like x 2
  3. reallove0810

    reallove0810 New Member

    22
    10
    3
    Jan 3, 2015
    Ratings:
    +11
    Local Time:
    6:09 AM
    1.7.9
    5.5.41
    I still don't understand that reason. May be my english is a little bit poor :D
    If somebody start with a fresh new database, then he can free to choose type of storage engine and InnoDB on/off is not problem. If off, he cant create new InnoDB table, then he simply turn it on :D
    But with some folks are migrating data from other servers like me. I restore my database without error. My website still running. While I fix the character set problem on vbulletin database. I accidentally see that vbulletin use MyISAM still continue use MyISAM, but magento InnoDB is converted to myisam. So I must turn on InnoDB and restore DB once again. If I had not suddenly discovered it, then now my data may be faulty.
     
    • Like Like x 1
  4. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    Yes that is why end user needs to understand that specifics for InnoDB i.e. enabling, tuning for InnoDB etc which is why leave to end user to do.

    Also >40% of Centmin Mod users still use 32bit OS and low memory servers/VPS Centmin Mod Survey 2013-2014 | Centmin Mod Community so it's important that memory usage be lower for MySQL.

    FYI, loading a previously InnoDB database tables into a MySQL server with InnoDB disabled won't do any damage usually unless the web app is coded to use InnoDB specific features. Although, performance might not be as good with MyISAM as with InnoDB. But then again InnoDB enabled without InnoDB specific MySQL optimised settings will also give poor performance and sometimes worse than that of MyISAM.
     
    • Like Like x 1
  5. reallove0810

    reallove0810 New Member

    22
    10
    3
    Jan 3, 2015
    Ratings:
    +11
    Local Time:
    6:09 AM
    1.7.9
    5.5.41
    Magento was developed in a transaction-safe environment. So, if we use non-transaction storage engine like MyISAM, then it will damage database.
    With ordinary users. They don't know the difference between MyISAM and InnoDB. They are newbies and moving from hosting to VPS. Most hosting providers support InnoDB by default. So, they don't know their data is going asynchronous.
    I have a question, InnoDB turn on (but dont use) will affect to performance of mysql server? If it affect, then disable by default is ok.
    And it is better if you add a note in FAQ or in MySQL introduction page.
     
    • Like Like x 1
  6. trexanhvn

    trexanhvn New Member

    6
    1
    3
    Oct 18, 2014
    Ratings:
    +1
    Local Time:
    12:09 PM
    I'm config like your instruction. But when I access to install, it appear blank page. I don't know how to config it.
    This is my config of file domain.conf in /usr/local/nginx/conf/conf.d/
    Code:
    server {
       listen 80;
        server_name domain.net;
        rewrite / $scheme://www.$host$request_uri permanent;
    }
    server {
        listen 80;
        server_name www.domain.net *.domain.net;
        root /home/nginx/domains/domain.net/public;
    
        access_log /home/nginx/domains/domain.net/log/access.log combined buffer=32k;
        error_log /home/nginx/domains/domain.net/log/error.log;
    
        location / {
            index index.php index.html; ## Allow a static html file to be shown first
            try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
            expires 30d; ## Assume all files are cachable
        }
    
        location /blog {
        try_files $uri $uri/ /blog/index.php?q=$request_uri;
        }
    
        location /wp {
        try_files $uri $uri/ /wp/index.php?q=$request_uri;
        }
    
        ## These locations would be hidden by .htaccess normally
        location ^~ /app/                { deny all; }
        location ^~ /includes/           { deny all; }
        location ^~ /lib/                { deny all; }
        location ^~ /media/downloadable/ { deny all; }
        location ^~ /pkginfo/            { deny all; }
        location ^~ /report/config.xml   { deny all; }
        location ^~ /var/                { deny all; }
    
        location /var/export/ { ## Allow admins only to view export folder
            auth_basic           "Restricted"; ## Message shown in login window
            auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
            autoindex            on;
        }
    
        location  /. { ## Disable .htaccess and other hidden files
            return 404;
        }
    
        location @handler { ## Magento uses a common front handler
            rewrite / /index.php;
        }
    
        location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }
    
        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
    
            expires        off; ## Do not cache dynamic content
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  HTTPS $server_https;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
            fastcgi_param  MAGE_RUN_TYPE store;
            include        fastcgi_params; ## See /etc/nginx/fastcgi_params
        }
      include /usr/local/nginx/conf/domain.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }

    Error Log don't have anything to view.
     
  7. reallove0810

    reallove0810 New Member

    22
    10
    3
    Jan 3, 2015
    Ratings:
    +11
    Local Time:
    6:09 AM
    1.7.9
    5.5.41
    Please try to upload a php file to root folder of your domain and run it.
    Ex:
    PHP:
    <?php
    echo "Hello World";
    ?>
    If it show "Hello World" then make sure your PHP version is compatible with the version of magento that you tried to install.
    Have you tried this command "chown -R nginx:nginx /home/nginx/domains/domain.net/public"
     
    • Like Like x 1
    • Informative Informative x 1
  8. trexanhvn

    trexanhvn New Member

    6
    1
    3
    Oct 18, 2014
    Ratings:
    +1
    Local Time:
    12:09 PM
    • Like Like x 1
  9. MarkKiss

    MarkKiss New Member

    21
    3
    3
    Sep 2, 2015
    Ratings:
    +3
    Local Time:
    5:09 AM
    Hi, I was trying use this domain.conf for Magento, but when I will try restart nginx nginx wont start.
     
  10. reallove0810

    reallove0810 New Member

    22
    10
    3
    Jan 3, 2015
    Ratings:
    +11
    Local Time:
    6:09 AM
    1.7.9
    5.5.41
    Please look at what the terminal say
     
  11. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    @MarkKiss like @reallove0810 said when you restart nginx and it has errors, usually it will have some kind of message accompanying it. For CentOS 7 it may prompt you to immediate type journalctl -xn command to see those errors

    did you get it solved ?
     
  12. RoldanLT

    RoldanLT Well-Known Member

    3,979
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    1:09 PM
    1.11
    10.2
    nginx -t to see specific errors.
     
    • Informative Informative x 1
  13. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    ah yes that too or

    Code:
    service nginx configtest
     
  14. MarkKiss

    MarkKiss New Member

    21
    3
    3
    Sep 2, 2015
    Ratings:
    +3
    Local Time:
    5:09 AM
    Error is here
    Code:
    [root@webserver ~]# nginx -t
    nginx: [emerg] access_log "/home/nginx/domains/txt.texet.com/log/access.log" already defined                                               with conflicting parameters in /usr/local/nginx/conf/conf.d/txt.texet.com.ssl.conf:49
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    
    I commented this line and is nginx start

    but, I saw only 404 error
     
  15. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    check for duplicates with command below

    Code:
    grep -Ro 'access.log' /usr/local/nginx/conf/conf.d/ | grep 'txt.texet.com' 
     
  16. MarkKiss

    MarkKiss New Member

    21
    3
    3
    Sep 2, 2015
    Ratings:
    +3
    Local Time:
    5:09 AM
    Code:
    [root@webserver ~]# grep -Ro 'access.log' /usr/local/nginx/conf/conf.d/ | grep 'txt.texet.com'
    /usr/local/nginx/conf/conf.d/txt.texet.com.conf:access_log
    /usr/local/nginx/conf/conf.d/txt.texet.com.conf:access.log
    /usr/local/nginx/conf/conf.d/txt.texet.com.conf.orig:access_log
    /usr/local/nginx/conf/conf.d/txt.texet.com.conf.orig:access.log
    /usr/local/nginx/conf/conf.d/txt.texet.com.ssl.conf:access_log
    /usr/local/nginx/conf/conf.d/txt.texet.com.ssl.conf:access.log
    
     
  17. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    Might need to expand out a bit more to see clearly
    Code:
    grep -Rn -C3 'access.log' /usr/local/nginx/conf/conf.d/ | grep 'txt.texet.com'
    
     
  18. MarkKiss

    MarkKiss New Member

    21
    3
    3
    Sep 2, 2015
    Ratings:
    +3
    Local Time:
    5:09 AM
    I just try adjust setting for log

    combined buffer=32k; to combined buffer=256k; like is in orig file and works
     
  19. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    3:09 PM
    Nginx 1.13.x
    MariaDB 5.5
    ah it might be matching on /usr/local/nginx/conf/conf.d/txt.texet.com.conf.orig so rename it to /usr/local/nginx/conf/conf.d/txt.texet.com.conf-orig and see
     
  20. MarkKiss

    MarkKiss New Member

    21
    3
    3
    Sep 2, 2015
    Ratings:
    +3
    Local Time:
    5:09 AM
    Is still same if buffer is 32k wont start with 256k is fine