Skip to content

Commit 90e21ef

Browse files
committed
📚 Document OPcache with symlinks
1 parent 6b454e0 commit 90e21ef

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

docs/first-deploy.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ Start by deploying using `php artisan deploy`. Unless you have some folders call
2020
## 2️⃣ Point root path to current directory
2121
Make sure your server's root path points to the `current` symlink. For example if your `deploy_path` is `var/www/domain.com`, your server configurations should point to `var/www/domain.com/current`.
2222

23-
Because the `current` directory is a symlink, you need to allow symlinks on nginx by adding `disable_symlinks off;` to your server block.
23+
If you're using OPcache, you need to pass the realpath of the application instead of its symbolic link. Otherwise, PHP's OPcache may not properly detect changes to your PHP files. Add the following lines after the rest of your `fastcgi` configurations in the `location` block of your nginx configurations.
24+
25+
```nginx
26+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
27+
fastcgi_param DOCUMENT_ROOT $realpath_root;
28+
```
2429

2530
Are you using Laravel Forge? [You can do this directly from the web interface](how-to-forge.md#update-web-directory).
2631

docs/how-to-forge.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ localhost()
2727
* Combine with the `-a` (`--all`) option to skip any console interaction whilst using a maximum of features — npm, migrations, horizon, etc.
2828

2929
## Update web directory
30-
3130
Go to the *Meta* tab of your application page on Forge and change it to the `/current/public` directory.
3231

3332
![Enter `/current/public` on Meta > Update Web Directory](https://user-images.githubusercontent.com/3642397/37337948-320f3ea0-26b6-11e8-902f-f4b185c609c7.png)
3433

35-
## Allow symlinks on nginx
34+
## Make OPcache work with symlinks
35+
Next, you need to pass the real application path instead of the symlink path to PHP FPM. Otherwise, PHP's OPcache may not properly detect changes to your PHP files. Add the following lines after the rest of your `fastcgi` configurations in the `location` block of your nginx configurations.
3636
37-
Because the `current` directory is a symlink, you need to allow symlinks on nginx by adding `disable_symlinks off;` to your server block.
37+
```nginx
38+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
39+
fastcgi_param DOCUMENT_ROOT $realpath_root;
40+
```
3841
3942
![Edit your nginx configuration file](https://user-images.githubusercontent.com/3642397/37338252-30323c08-26b7-11e8-85d5-db49d5c4abbe.png)
4043
41-
![Add `disable_symlinks off;` to your server block](https://user-images.githubusercontent.com/3642397/37338263-41bb0144-26b7-11e8-9234-fc980198060f.png)
44+
![Add more fastcgi configs to your location block](https://user-images.githubusercontent.com/3642397/37346220-11785cb2-26cf-11e8-906e-30da2bfbe847.png)
4245
4346
## Edit your deploy script
4447
Your deploy script in Forge is now unnecessary since your whole deployment logic is define by Laravel Deployer. Replace it with the following script to deploy using Laravel Deployer when you deloy in Forge.
@@ -52,4 +55,4 @@ Now if you have *Quick Deploy* turned on, every time you push to your repository
5255
5356
## Extra things to configure
5457
* If you wish to reload php-fpm after each deployment like Forge does by default, you will need to use the `fpm:reload` task and set up your version of php-fpm within the `php_fpm_service` option. Read more [here](how-to-reload-fpm.md).
55-
* If you have a Daemon running Horizon in Forge, [read this](how-to-horizon.md) to make sure it restarts after each deployment.
58+
* If you have a Daemon running Horizon in Forge, [read this](how-to-horizon.md) to make sure it restarts after each deployment.

docs/troubleshooting.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,24 @@ Since Deployer uses `acl` by default to set up permissions for writable director
1717
sudo apt-get install acl
1818
```
1919
20-
## My changes don't show after a deployment.
20+
## My changes don't show up after a deployment.
2121

2222
**Problem:**
2323

2424
You push some new commits and run `php artisan deploy` successfully but the changes don't seem to appear on your application.
2525
2626
**Solution:**
2727
28-
It is likely that your server configurations do not allow symlinks. Since the `current` folder is a symlink, it will not see it as linked to the newest release. To allow symlinks in your nginx configuration, add `disable_symlinks off;` to your server block.
29-
28+
Since we are using symlinks to link the `current` folder to the current release of your application, it is likely that OPcache does not properly detect changes to your PHP files. To fix this, you should pass the real application path instead of the path to the symlink to PHP FPM. Add the following lines after the rest of your `fastcgi` configuration in the `location` block of your nginx configurations.
3029
30+
```nginx
31+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
32+
fastcgi_param DOCUMENT_ROOT $realpath_root;
3133
```
34+
35+
If this doesn't fix the problem, make sure that your nginx configurations allow symbolic links by adding `disable_symlinks off;` to your server block.
36+
37+
```nginx
3238
server {
3339
# ...
3440
disable_symlinks off;

0 commit comments

Comments
 (0)