commit
c633ab9081
20
README.md
20
README.md
@ -13,6 +13,26 @@ Looking for a modern hosting environment provisioned using Ansible? Check out [W
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### PHP configuration
|
||||||
|
|
||||||
|
The php-fpm pool configuration is located in `global/php-pool.conf` and defaults to PHP 7.1. It will need modified if you want the default php-fpm pool service to be a different PHP version. Additional PHP version upstream definitions can be added to the `/upstreams` folder (a PHP 7.0 sample is provided there). You can either use the default pool using `$upstream` in your nginx configurations or the specific upstream definition (i.e. php71, php70) setup by your custom upstream definitions.
|
||||||
|
|
||||||
|
For example, currently the nginx configuration for `singlesite.com` has the following set for php requests:
|
||||||
|
|
||||||
|
```
|
||||||
|
fastcgi_pass $upstream
|
||||||
|
```
|
||||||
|
|
||||||
|
You could change that to the following to use the php 7.0 php service instead (assuming that php7.0-fpm service is running).
|
||||||
|
|
||||||
|
```
|
||||||
|
fastcgi_pass php70
|
||||||
|
```
|
||||||
|
|
||||||
|
This effectively allows you to have different server blocks execute different versions of PHP if needed.
|
||||||
|
|
||||||
|
### Site configuration
|
||||||
|
|
||||||
You can use these sample configurations as reference or directly by replacing your existing nginx directory. Follow the steps below to replace your existing nginx configuration.
|
You can use these sample configurations as reference or directly by replacing your existing nginx directory. Follow the steps below to replace your existing nginx configuration.
|
||||||
|
|
||||||
Backup any existing config:
|
Backup any existing config:
|
||||||
|
|||||||
12
global/php-pool.conf
Normal file
12
global/php-pool.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Upstream to abstract backend connection(s) for PHP.
|
||||||
|
# Additional upstreams can be added to /etc/nginx/upstreams/*.conf and then you just
|
||||||
|
# change `default php71` to whatever the new upstream is (could be php70 for example).
|
||||||
|
upstream php71 {
|
||||||
|
server unix:/run/php/php7.1-fpm.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
include /etc/nginx/upstreams/*.conf;
|
||||||
|
|
||||||
|
map '' $upstream {
|
||||||
|
default php71;
|
||||||
|
}
|
||||||
@ -33,7 +33,7 @@ http {
|
|||||||
include global/limits.conf;
|
include global/limits.conf;
|
||||||
|
|
||||||
# Some WP plugins that push large amounts of data via cookies
|
# Some WP plugins that push large amounts of data via cookies
|
||||||
# can cause 500 HTTP erros if these values aren't increased.
|
# can cause 500 HTTP errors if these values aren't increased.
|
||||||
fastcgi_buffers 16 16k;
|
fastcgi_buffers 16 16k;
|
||||||
fastcgi_buffer_size 32k;
|
fastcgi_buffer_size 32k;
|
||||||
|
|
||||||
@ -44,6 +44,9 @@ http {
|
|||||||
# Gzip
|
# Gzip
|
||||||
include global/gzip.conf;
|
include global/gzip.conf;
|
||||||
|
|
||||||
|
# exposes configured php pool on $upstream variable
|
||||||
|
include global/php-pool.conf;
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
include /etc/nginx/conf.d/*.conf;
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
|
||||||
|
|||||||
@ -35,10 +35,9 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
|
|
||||||
# Skip cache based on rules in global/server/fastcgi-cache.conf.
|
# Skip cache based on rules in global/server/fastcgi-cache.conf.
|
||||||
fastcgi_cache_bypass $skip_cache;
|
fastcgi_cache_bypass $skip_cache;
|
||||||
@ -51,8 +50,8 @@ server {
|
|||||||
fastcgi_cache_valid 60m;
|
fastcgi_cache_valid 60m;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
|
|
||||||
# Uncomment if using the fastcgi_cache_purge module and Nginx Helper plugin (https://wordpress.org/plugins/nginx-helper/)
|
# Uncomment if using the fastcgi_cache_purge module and Nginx Helper plugin (https://wordpress.org/plugins/nginx-helper/)
|
||||||
# location ~ /purge(/.*) {
|
# location ~ /purge(/.*) {
|
||||||
|
|||||||
@ -30,14 +30,13 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirect www to non-www
|
# Redirect www to non-www
|
||||||
|
|||||||
@ -27,14 +27,13 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirect www to non-www
|
# Redirect www to non-www
|
||||||
|
|||||||
@ -27,14 +27,13 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirect www to non-www
|
# Redirect www to non-www
|
||||||
|
|||||||
@ -16,7 +16,7 @@ server {
|
|||||||
|
|
||||||
# Paths to certificate files.
|
# Paths to certificate files.
|
||||||
ssl_certificate /etc/letsencrypt/live/ssl-fastcgi-cache.com/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/ssl-fastcgi-cache.com/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/ssl-fastcgi-cache.com/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/ssl-fastcgi-cache.com/privkey.pem;
|
||||||
|
|
||||||
# File to be used as index
|
# File to be used as index
|
||||||
index index.php;
|
index index.php;
|
||||||
@ -42,10 +42,9 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
|
|
||||||
# Skip cache based on rules in global/server/fastcgi-cache.conf.
|
# Skip cache based on rules in global/server/fastcgi-cache.conf.
|
||||||
fastcgi_cache_bypass $skip_cache;
|
fastcgi_cache_bypass $skip_cache;
|
||||||
@ -58,8 +57,8 @@ server {
|
|||||||
fastcgi_cache_valid 60m;
|
fastcgi_cache_valid 60m;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
|
|
||||||
# Uncomment if using the fastcgi_cache_purge module and Nginx Helper plugin (https://wordpress.org/plugins/nginx-helper/)
|
# Uncomment if using the fastcgi_cache_purge module and Nginx Helper plugin (https://wordpress.org/plugins/nginx-helper/)
|
||||||
# location ~ /purge(/.*) {
|
# location ~ /purge(/.*) {
|
||||||
|
|||||||
@ -10,8 +10,8 @@ server {
|
|||||||
root /sites/ssl.com/public;
|
root /sites/ssl.com/public;
|
||||||
|
|
||||||
# Paths to certificate files.
|
# Paths to certificate files.
|
||||||
ssl_certificate /etc/letsencrypt/live/ssl.com/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/ssl.com/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/ssl.com/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/ssl.com/privkey.pem;
|
||||||
|
|
||||||
# File to be used as index
|
# File to be used as index
|
||||||
index index.php;
|
index index.php;
|
||||||
@ -34,14 +34,13 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
include global/fastcgi-params.conf;
|
include global/fastcgi-params.conf;
|
||||||
|
|
||||||
# Change socket if using PHP pools or different PHP version
|
# Use the php pool defined in the upstream variable.
|
||||||
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
|
# See global/php-pool.conf for definition.
|
||||||
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
fastcgi_pass $upstream;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rewrite robots.txt
|
# Rewrite robots.txt
|
||||||
rewrite ^/robots.txt$ /index.php last;
|
rewrite ^/robots.txt$ /index.php last;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirect http to https
|
# Redirect http to https
|
||||||
@ -60,4 +59,4 @@ server {
|
|||||||
server_name www.ssl.com;
|
server_name www.ssl.com;
|
||||||
|
|
||||||
return 301 https://ssl.com$request_uri;
|
return 301 https://ssl.com$request_uri;
|
||||||
}
|
}
|
||||||
|
|||||||
4
upstreams/php70.conf
Normal file
4
upstreams/php70.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Defines the upstream for PHP 7.0
|
||||||
|
upstream php70 {
|
||||||
|
server unix:/run/php/php7.0-fpm.sock;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user