Last active
June 30, 2023 12:20
-
-
Save williamgomes/5749c8f54936823af15c9f1a45713861 to your computer and use it in GitHub Desktop.
how to configure nginx with craft (also multilingual)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* General Configuration | |
* | |
* All of your system's general configuration settings go in here. | |
* You can see a list of the default settings in craft/app/etc/config/defaults/general.php | |
*/ | |
return array( | |
/** | |
* You only need this part if you are configuring multilingual craft cms website, otherwise just ignore 'siteUrl' array | |
* You dont need this 'siteUrl' array for single language craft cms website | |
**/ | |
'siteUrl' => array( | |
'en' => '<YOUR-WEBSITE-URL>/', //Please replace this <YOUR-WEBSITE-URL> with your website domain or hosting address | |
'de' => '<YOUR-WEBSITE-URL>/de/', //Please replace this <YOUR-WEBSITE-URL> with your website domain or hosting address | |
), | |
'usePathInfo' => true, | |
'omitScriptNameInUrls' => true | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
root /var/www/html; | |
index index.php index.html index.htm; | |
server_name localhost; | |
############################### | |
# MOD REWRITE BLOCK START # | |
############################### | |
## Use Block 1 if you are working with multilingual craft cms. | |
## For example, for me it was en: http://localhost/ and for de: http://localhost/de | |
## For single language craft cms website, use Block 2 | |
### BLOCK 1 START ### | |
location / { | |
try_files $uri $uri/ @rewrites; | |
} | |
location @rewrites { | |
rewrite ^(/en_gb|de|fr|es)?/(.*)$ $1/index.php?p=$2&$args? last; | |
} | |
### BLOCK 1 END ### | |
### BLOCK 2 START ### | |
location / { | |
try_files $uri $uri/ @rewrites; | |
} | |
location @rewrites { | |
rewrite ^(.*) /index.php?p=$1 last; | |
} | |
### BLOCK 2 END ### | |
############################### | |
# MOD REWRITE BLOCK ENDS # | |
############################### | |
error_page 404 /404.html;error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please check my update. I put my own host in the URL, my bad, i believe that was the problem of wrong activation email. Please replace '' part with your domain name or hosting address. Believe that will solve the issue.
Please check my update. I put my own host in the URL, my bad, i believe that was the problem of wrong activation email. Please replace '' part with your domain name or hosting address. Believe that will solve the issue.