Skip to content

Instantly share code, notes, and snippets.

@LauLaman
Last active April 23, 2018 22:16
Show Gist options
  • Save LauLaman/c95387f8791e1a0076b7b68e79052df6 to your computer and use it in GitHub Desktop.
Save LauLaman/c95387f8791e1a0076b7b68e79052df6 to your computer and use it in GitHub Desktop.
EasyEngine seperate by user
  1. Create site: ee site create DOMAIN.TLD --wp --php7
  2. Create usergroup sudo groupadd DOMAIN
  3. Create user sudo useradd -d /var/www/DOMAIN.TLD/htdocs -g DOMAIN DOMAIN
  4. Create php-fpm config vi /etc/php/7.0/fpm/pool.d/DOMAIN.conf
[DOMAIN]
user = DOMAIN
group = DOMAIN
listen = /var/run/php7-fpm-DOMAIN.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
ping.path = /php-fpm/ping
pm.status_path = /php-fpm/status
  1. restart php-fpm service php7.0-fpm restart
  2. Check if user is part of the pool: ps aux|grep php-fpm
  3. Edit Nginx config vi /etc/nginx/sites-enabled/DOMAIN.TLD :
##wordpress.conf
server {


    server_name DOMAIN.TLD   www.DOMAIN.TLD;

    location ~ ^/php-fpm/(status|ping)$ {
        access_log off;
        allow 127.0.0.1;
        #deny all;
        fastcgi_pass unix:/var/run/php7-fpm-DOMAIN.sock;
        include fastcgi_params;
    }

    access_log /var/log/nginx/DOMAIN.TLD.access.log rt_cache;
    error_log /var/log/nginx/DOMAIN.TLD.error.log;


    root /var/www/DOMAIN.TLD/htdocs;


    index index.php index.html index.htm;

#    include common/php7.conf;
### Copy from here ###
    include common/wp-secure.conf;
    location / {
      try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php7-fpm-DOMAIN.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
   
### Copy to here ###
    include common/wpcommon-php7.conf;
    include common/locations-php7.conf;
    include /var/www/DOMAIN.TLD/conf/nginx/*.conf;
}
  1. Reload Nginx config service nginx restart
location ~* /wp-includes/.*.php$ {
return 404;
log_not_found off;
}
location ~* /wp-content/.*.php$ {
return 404;
log_not_found off;
}
location ~* /(?:uploads|files)/.*.php$ {
return 404;
log_not_found off;
}
location = /xmlrpc.php {
return 404;
log_not_found off;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment