-
Notifications
You must be signed in to change notification settings - Fork 195
Nginx Configuration
mclang edited this page Dec 16, 2016
·
2 revisions
If you are planning to run Unmark on a machine with Nginx as the web server you can use one the following virtual host configuration files. The first one is a regular one for http. The second one is if you wish to run Unmark with HTTPS support e.g when using Let's Encrypt.
These instructions are for Ubuntu/Debian but same kind of configuration should work also with CentOS 7. Note that the PHP FPM socket used here is different when using Ubuntu 16.04 with PHP 7. Check the right path from the PHP FPM pool config file.
Just place the appropriate file, e.g unmark.conf
, under /etc/nginx/sites-available
and symlink it to /etc/nginx/sites-enabled
. Then all you need to do is sudo service nginx reload
and browse to
your.server.name/setup.
server {
listen :80;
listen [::]:80;
server_name your.server.name;
root /path/to/unmark/files/;
index index.php index.html index.html;
rewrite ^system.* /index.php?/$1 break;
rewrite ^application.* /index.php?/$1 break;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?/$1 break;
}
# Include the "?$args" part so non-default permalinks do not break when using query strings.
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi.conf;
fastcgi_index index.php;
}
}
server {
listen :80;
listen [::]:80;
server_name your.server.name;
return 301 https://$server_name$request_uri;
}
server {
listen :443 ssl http2;
listen [::]:443 ssl http2;
server_name your.server.name;
charset utf-8;
ssl on;
ssl_certificate /path/to/crt_file.crt;
ssl_certificate_key /path/to/key_file.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_prefer_server_ciphers on;
root /path/to/unmark/files/;
index index.php index.html index.html;
rewrite ^system.* /index.php?/$1 break;
rewrite ^application.* /index.php?/$1 break;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?/$1 break;
}
# Include the "?$args" part so non-default permalinks do not break when using query strings.
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi.conf;
fastcgi_index index.php;
}
}