Hẳn khi bạn cài Mailwizz trên server Nginx sẽ gặp nhiều khó khăn và vướng mắc, mỗi người có cái vướng khác nhau, nhưng bạn nên tự giải quyết vướng mắc của mình,mình cũng tự giải quyết vướng mắc đó, mình lục tung cả forum của mailwizz lên để giải quyết lỗi Unable to resolve the request "customer/index.php".Mình đã rất vui khi cài đặt các bước trước đó thành công,nhưng bước cuối cùng lạikhông đăng nhập được.



Đầu tiên mình đọc bài hướng dẫn https://kb.mailwizz.com/articles/nginx-server-basic-configuration-for-mailwizz/ và làm theo,













Nginx server basic configuration for mailwizz


If you need a very advanced/optimised nginx configuration, you’ll find one here, otherwise below sample should do it for the simplest use cases.
Please note that the below configuration is going to use php-fpm for what is worth.
1
/etc/nginx/nginx.conf
1
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/
user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;
pid        /run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    index   index.html index.htm;
    #root /usr/share/nginx/html;
  # this is the section that matters for mailwizz.
    server {
     listen      80;
     server_name domain.com;
     root        /usr/share/nginx/html;
     location / {
         if (!-e $request_filename){
         rewrite ^(/)?api/.*$ /api/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(/)?customer/.*$ /customer/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(/)?backend/.*$ /backend/index.php;
         }
         if (!-e $request_filename){
         rewrite ^(.*)$ /index.php;
         }
         index  index.html index.htm index.php;
     }
     #error_page  404              /404.html;
     # redirect server error pages to the static page /50x.html
     #
     error_page   500 502 503 504  /50x.html;
     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     #
     location ~ \.php$ {
         fastcgi_split_path_info  ^(.+\.php)(.*)$;
         fastcgi_param  PATH_INFO        $fastcgi_path_info;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include fastcgi_params;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_read_timeout 600s;
         fastcgi_send_timeout 600s;
     }
     # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     location ~ /\.ht {
         deny  all;
     }
   }
}


Nếu cách trên bạn vẫn không fix được lỗi thì làm thêm cách bên dưới

Bạn nên thử theo cách dưới đây, mình sửa file /etc/nginx/conf.d/domain-cua-ban.conf
và thêm đoạn đầu tiên Had to add the below như bên dưới và đã đăng nhập được




Just a update the server runs nginx and the config file needs to be edited

Found the required lines here:



Had to add the below
Code:
    if (!-e $request_filename){
    rewrite customer/.* /customer/index.php;
    }
    if (!-e $request_filename){
    rewrite backend/.* /backend/index.php;
    }
    if (!-e $request_filename){
    rewrite api/.* /api/index.php;
    }
    if (!-e $request_filename){
    rewrite ^(.*)$ /index.php;
    }

FULL nginx file below
Code:
server {
    listen 80;
    listen 443 ssl;
    server_name mailwizz.dev;
    root "/home/vagrant/Code/mailwizz";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/mailwizz.dev-error.log error;

    sendfile off;

    client_max_body_size 100m;

    if (!-e $request_filename){
        rewrite customer/.* /customer/index.php;
    }

    if (!-e $request_filename){
        rewrite backend/.* /backend/index.php;
    }

    if (!-e $request_filename){
        rewrite api/.* /api/index.php;
    }

    if (!-e $request_filename){
        rewrite ^(.*)$ /index.php;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }

    ssl_certificate     /etc/nginx/ssl/mailwizz.dev.crt;
    ssl_certificate_key /etc/nginx/ssl/mailwizz.dev.key;
}

Last edited: Jul 13, 2016
Sau đó bạn nhớ khởi động lại Nginx bằng lệnh:
 service nginx restart 


file conf.d chuẩn đã cài đặt thành công như ở dưới:


1
server { listen 80; listen 443 ssl; server_name www.mailmarketing.lemaihuong.com; rewrite ^(.*) http://mailmarketing.lemaihuong.com$1 permanent; } server { listen 80; listen 443 ssl; access_log off; # access_log /home/mailmarketing.lemaihuong.com/logs/access.log; error_log off; # error_log /home/mailmarketing.lemaihuong.com/logs/error.log; root /home/mailmarketing.lemaihuong.com/public_html; index index.php index.html index.htm; server_name mailmarketing.lemaihuong.com; location / { try_files $uri $uri/ /index.php?$args; } # Custom configuration include /home/mailmarketing.lemaihuong.com/public_html/*.conf; if (!-e $request_filename){ rewrite customer/.* /customer/index.php; } if (!-e $request_filename){ rewrite backend/.* /backend/index.php; } if (!-e $request_filename){ rewrite api/.* /api/index.php; } if (!-e $request_filename){ rewrite ^(.*)$ /index.php; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 32k; fastcgi_buffers 8 16k; fastcgi_busy_buffers_size 32k; fastcgi_temp_file_write_size 32k; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME /home/mailmarketing.lemaihuong.com/public_html$fastcgi_script_name; } location ~ /\. { deny all; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } 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|eot|svg|ttf|woff)$ { gzip_static off; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; access_log off; expires 30d; break; } location ~* \.(txt|js|css)$ { add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; access_log off; expires 30d; break; } }


Share To:

Post A Comment:

0 comments so far,add yours