Skip to content

Commit 708e77d

Browse files
authored
add script-free manual instructions (#16)
Signed-off-by: Hasan ÇALIŞIR <hasan.calisir@psauxit.com>
1 parent dcdb78a commit 708e77d

File tree

1 file changed

+67
-17
lines changed

1 file changed

+67
-17
lines changed

README.md

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Nginx FastCGI Cache Purge & Preload Plugin for Wordpress (NPP)
1+
# Nginx Cache Purge & Preload for Wordpress (NPP)
22

33
🚀 **Support this project!** If NPP has improved your workflow, consider giving it a ⭐ to help us grow:
44
🚀 **Need help with server-side integration?** Check out our tailored services:
@@ -7,11 +7,11 @@
77
[![GitHub Release](https://img.shields.io/github/v/release/psaux-it/nginx-fastcgi-cache-purge-and-preload?logo=github)](https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload/releases) [![Donate](https://img.shields.io/badge/Wordpress_SVN-v2.0.9-blue?style=flat&logo=wordpress)](https://wordpress.org/plugins/fastcgi-cache-purge-and-preload-nginx/) [![Donate](https://img.shields.io/badge/Donate-PayTR-blue?style=flat&logo=visa)](https://www.psauxit.com/nginx-fastcgi-cache-purge-preload-for-wordpress/) [![Donate](https://img.shields.io/badge/Check-Services-blue?style=flat&logo=Linux)](https://www.psauxit.com/nginx-fastcgi-cache-purge-preload-for-wordpress/)
88

99
> [!NOTE]
10-
> This plugin allows WordPress users to manage Nginx Cache Purge and Preload operations directly from the WordPress admin dashboard, enhancing website performance and caching efficiency.
10+
> NPP allows WordPress users to manage Nginx Cache operations directly from the WordPress admin dashboard, enhancing website performance and caching efficiency. NPP supports Nginx **FastCGI**, **Proxy**, **SCGI**, and **UWSGI** cache purge and preload operations, making it the most comprehensive solution for managing Nginx Cache from your WordPress dashboard.
1111
1212
### Requirements
1313

14-
This wordpress plugin is compatible exclusively with **Nginx web servers** running on **Linux-powered** systems. Additionally, the **shell_exec** function must be enabled and unrestricted. Consequently, the plugin may not operate fully on shared hosting environments where native Linux commands are blocked from running via PHP.
14+
NPP is compatible exclusively with **Nginx web servers** running on **Linux-powered** systems. Additionally, the **shell_exec** function must be enabled and unrestricted. Consequently, the plugin may not operate fully on shared hosting environments where native Linux commands are blocked from running via PHP.
1515

1616
Moreover, granting the correct permissions to the PHP process owner (PHP-FPM-USER) is essential for the proper functioning of the purge and preload operations. This is necessary in isolated user environments that have two distinct user roles: the WEBSERVER-USER (nginx or www-data) and the PHP-FPM-USER.
1717

@@ -33,7 +33,7 @@ Moreover, granting the correct permissions to the PHP process owner (PHP-FPM-USE
3333
🚀**Remote Nginx Cache Purge & Preload via REST API**: Remotely trigger cache purging and preloading through `REST API` endpoints.<br/>
3434
🚀**Manual Nginx Cache Purge & Preload**: Allow manual purging and preloading of cache through the table view in Advanced Tab.<br/>
3535
🚀**On-Page Nginx Cache Purge & Preload**: Manually purge and preload Nginx cache for the currently visited page directly from the frontend.<br/>
36-
🚀**Custom Cache Key Support**: Define a regex pattern to parse URLs based on your custom `fastcgi_cache_key` format.<br/>
36+
🚀**Custom Cache Key Support**: Define a regex pattern to parse URLs based on your custom `(fastcgi|proxy|uwsgi|scgi)_cache_key` format.<br/>
3737
🚀**Optimized Nginx Cache Preload**: Enhance Nginx cache preload performance with options to limit server resource usage, via exclude endpoints, exclude file extensions, wait retrievals and rate limiting.<br/>
3838
🚀**Monitor Plugin and Nginx Cache Status**: Monitor plugin status, cache status, cache preload status, and Nginx status from the Status tab.<br/>
3939
🚀**User-Friendly Interface**: Easy-to-use AJAX-powered settings, integrated into the WordPress admin bar for quick access.<br/>
@@ -44,7 +44,9 @@ Moreover, granting the correct permissions to the PHP process owner (PHP-FPM-USE
4444

4545
### Overview
4646

47-
This project addresses the challenge of automating Nginx FastCGI cache purging and preloading (WordPress) in Nginx environments where two distinct users, WEBSERVER-USER and PHP-FPM-USER, are involved. NPP offers a more direct solution without requiring any external NGINX modules, such as the Cache Purge module. This plugin directly traverses the cache directory and clears the cache when the permissions are properly granted for the PHP-FPM-USER to access the Nginx cache directory. To automate the granting of necessary permissions to PHP-FPM-USER, a pre-made bash script is provided that must be run manually on the host server under the **root**.
47+
This project addresses the challenge of automating Nginx cache purging and preloading in WordPress environments where two distinct users, WEBSERVER-USER and PHP-FPM-USER, are involved. NPP provides a direct solution without relying on external Nginx modules, such as the Cache Purge module. Instead, NPP traverses the cache directory and clears the cache, provided the PHP-FPM-USER has the necessary permissions to access the Nginx cache directory.
48+
49+
To facilitate this, a pre-configured bash script is included, which must be run manually on the host server under the **root** user to grant the required permissions to the PHP-FPM-USER.
4850

4951
### Problem Statement
5052

@@ -58,7 +60,6 @@ This project addresses the challenge of automating Nginx FastCGI cache purging a
5860

5961
### Solution
6062

61-
~~Solution involves combining **inotifywait** with **setfacl**:~~ ❗️This approach is deprecated.<br/>
6263
Use **bindfs** to create a FUSE mount of the original Nginx Cache Path, granting read and write permissions to the PHP-FPM-USER.
6364

6465
## Installation Instructions
@@ -71,17 +72,6 @@ To implement this solution:
7172

7273
The `install.sh` script serves as a wrapper for executing the main `fastcgi_ops_root.sh` script from [psaux-it.github.io](https://github.com/psaux-it/psaux-it.github.io). This script is designed for the **FastCGI Cache Purge and Preload for Nginx** WordPress plugin (NPP), which can be found at [Official WordPress Plugin Repository](https://wordpress.org/plugins/fastcgi-cache-purge-and-preload-nginx/).<br/>
7374

74-
----
75-
76-
❗️This approach is deprecated.
77-
78-
~~Mainly, in case your current web server setup involves two distinct users, **WEBSERVER-USER** (nginx or www-data) and **PHP-FPM-USER**, the solution proposed by this script involves combining Linux server side tools
79-
**inotifywait** with **setfacl** to automatically grant write permissions to the **PHP-FPM-USER** for the corresponding **Nginx Cache Paths**, which are matched either automatically or via a manual configuration file.~~
80-
81-
----
82-
83-
📣 **New Approach**
84-
8575
The script first attempts to automatically identify the PHP-FPM-USER (also known as the PHP process owner or website user) along with their associated Nginx Cache Paths. If it cannot automatically match the PHP-FPM-USER with their respective Nginx Cache Path, it provides an easy manual setup option using the `manual-configs.nginx` file.
8676

8777
In environments with two distinct user roles—the WEBSERVER-USER (nginx or www-data) and the PHP-FPM-USER —this script automates the management of Nginx Cache Paths. **It utilizes `bindfs` to create a `FUSE` mount of the original Nginx Cache Paths, enabling the PHP-FPM-USER to write to these directories with the necessary permissions.** This approach resolves permission conflicts by granting the PHP-FPM-USER access to a new mount point, while keeping the original Nginx Cache Paths intact and synchronized.
@@ -110,6 +100,66 @@ fastcgi_cache_path /var/cache/psauxit-fastcgi
110100
fastcgi_cache_path /var/cache/website-psauxit.com
111101
```
112102

103+
### Scriptless Setup Instructions
104+
105+
These instructions guide you through setting up the NPP plugin in environments where `PHP-FPM-USER` and `WEBSERVER-USER` are distinct, manually, without the automation script **install.sh**
106+
107+
#### Prerequisites
108+
- **Web Server:** `NGINX` configured with caching.
109+
- **Example Users:**
110+
- `PHP-FPM-USER` (PHP process owner, e.g., `psauxit`).
111+
- `WEBSERVER-USER` (commonly `nginx` or `www-data`).
112+
- **Tools:** A Linux-based server with **bindfs** installed.
113+
114+
#### Example Environment
115+
- **Original Nginx Cache Path:** `/dev/shm/fastcgi-cache-psauxit`
116+
- **FUSE Mount Point:** `/dev/shm/fastcgi-cache-psauxit-mnt`
117+
- This mount path will be used as the Nginx Cache Path in the NPP plugin settings.
118+
119+
---
120+
121+
#### Steps
122+
123+
##### 1. Install bindfs
124+
Install **bindfs** using your Linux distribution's package manager:
125+
```bash
126+
# For Gentoo
127+
emerge --ask sys-fs/bindfs
128+
129+
# For Debian/Ubuntu
130+
sudo apt install bindfs
131+
132+
# For Red Hat/CentOS
133+
sudo yum install bindfs
134+
```
135+
136+
##### 2. Create the FUSE Mount Directory
137+
Create a new directory for the FUSE mount:
138+
```bash
139+
mkdir /dev/shm/fastcgi-cache-psauxit-mnt
140+
```
141+
142+
##### 3. Set Up the bindfs Mount
143+
Mount the original Nginx cache path to the FUSE mount directory with the appropriate permissions for `psauxit`:
144+
```bash
145+
bindfs -u psauxit -g psauxit --perms=u=rwx:g=rx:o= /dev/shm/fastcgi-cache-psauxit /dev/shm/fastcgi-cache-psauxit-mnt
146+
```
147+
148+
To make the mount persistent, add the following line to `/etc/fstab`:
149+
```bash
150+
bindfs#/dev/shm/fastcgi-cache-psauxit /dev/shm/fastcgi-cache-psauxit-mnt fuse force-user=psauxit,force-group=psauxit,perms=u=rwx:g=rx:o= 0 0
151+
```
152+
153+
After editing `/etc/fstab`, apply the changes:
154+
```bash
155+
mount -a
156+
```
157+
158+
##### 4. Configure NPP Plugin
159+
1. Go to the **NPP plugin settings** page in your WordPress dashboard.
160+
2. Set `/dev/shm/fastcgi-cache-psauxit-mnt` as the **Nginx Cache Path**.
161+
3. Check the plugin **Status** tab for any warnings.
162+
113163
## Visuals
114164

115165
[https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload/assets/25556606/235404ff-b35c-4cce-ac17-ebead39130b6](https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload/assets/25556606/93a94d73-1d37-4b69-9ca9-ac1bed766f86)

0 commit comments

Comments
 (0)