Join the community today
Become a Member

Nginx Perfex CRM Custom ngnix.conf

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by iekamburoglu, Oct 17, 2019.

  1. iekamburoglu

    iekamburoglu New Member

    10
    1
    3
    Apr 27, 2018
    Turkey
    Ratings:
    +1
    Local Time:
    5:19 PM
    1.17.10
    Hello,

    I have installed Perfex CRM to subdomain however after installation done website says 404 not found. While looking for a solution at perfex crm's forum they made a config file for ngnix servers. I have tried change crm.afyonbasimevi.com.conf but when i tried restart nginx server show error.


    There is my conf files.
    Code (Text):
    # 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 crm.afyonbasimevi.com;
    #            return 301 $scheme://www.crm.afyonbasimevi.com$request_uri;
    #       }
    
    server {
     
      server_name crm.afyonbasimevi.com www.crm.afyonbasimevi.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;
    
      #add_header X-Frame-Options SAMEORIGIN;
      add_header X-Xss-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/crm.afyonbasimevi.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/crm.afyonbasimevi.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/crm.afyonbasimevi.com/autoprotect-crm.afyonbasimevi.com.conf;
      root /home/nginx/domains/crm.afyonbasimevi.com/public;
      index index.html index.php;
     
      # set expiration of assets to MAX for caching
            location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                    expires max;
                    log_not_found off;
            }   
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
    
    # 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;
    
      # Wordpress Permalinks example
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      }
    
     
      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;
    }
    

    Their simple conf file and the link where I found it
    Code (Text):
    server {
            server_name yourdomain.com www.yourdomain.com;
    
            root /path/to/your/website.com/;
            index index.html index.php;
    
            # set expiration of assets to MAX for caching
            location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                    expires max;
                    log_not_found off;
            }
    
            location / {
                    # Check if a file or directory index file exists, else route it to index.php.
                    try_files $uri $uri/ /index.php;
            }
           
            location /backups {
                    deny all;
                    return 404;
            }
    
            location ~* \.php$ {
                    fastcgi_pass 127.0.0.1:9000;
                    include fastcgi.conf;
            }
    }
    

    and my original conf file

    Code (Text):
    # 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 crm.afyonbasimevi.com;
    #            return 301 $scheme://www.crm.afyonbasimevi.com$request_uri;
    #       }
    
    server {
     
      server_name crm.afyonbasimevi.com www.crm.afyonbasimevi.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;
    
      #add_header X-Frame-Options SAMEORIGIN;
      add_header X-Xss-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/crm.afyonbasimevi.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/crm.afyonbasimevi.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/crm.afyonbasimevi.com/autoprotect-crm.afyonbasimevi.com.conf;
      root /home/nginx/domains/crm.afyonbasimevi.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
    
    # 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;
    
      # Wordpress Permalinks example
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      }
    
     
      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;
    }
    

    What should I do to? Also how I can work LetsEncrypt and acmetool.sh work?

    Thank you for support.
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.17.4
    • PHP Version Installed: 7.3.9
    • MariaDB MySQL Version Installed: 10.4.8
    • When was last time updated Centmin Mod code base ? : Today
    • Persistent Config:
      Code (Text):
      MARCH_TARGETNATIVE='n'
      LETSENCRYPT_DETECT='y'
      
     
  2. eva2000

    eva2000 Administrator Staff Member

    47,474
    10,760
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,718
    Local Time:
    12:19 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    out of their example only thing you need is
    Code (Text):
           location / {
                   # Check if a file or directory index file exists, else route it to index.php.
                   try_files $uri $uri/ /index.php;
           }
    

    where only need to take
    Code (Text):
    try_files $uri $uri/ /index.php;

    and place it in your existing location / {} context

    php location context isn't needed as it is taken care of by your nginx vhost /usr/local/nginx/conf/php.conf include file and static files not needed as it's taken care of nginx vhost /usr/local/nginx/conf/staticfiles.conf include file so