If anyone's interested, I built a more streamlined version of this approach using a single Python script, so there's no need to clone a repo, update the configuration etc. and then run a script - you just run one script directly, so it's a simpler process.
- A newly-created Opalstack static-only application - let's assume it's called static_app.
- A newly-created Opalstack proxy-port application - let's assume it's called proxy_app, and that the port number for it is proxy_port.
- Decide on the domain to be served by proxy_app - let's assume it's called proxy.domain.
Download the Python script, private_stack.py, from this gist:
Run the script using a command line like this (feel free to look at it first, I'll explain what it does below):
python3 private_stack.py proxy_app proxy_port static_app proxy.domain --php 8.1
Of course, substitute in the actual values for proxy_app, proxy_port, static_app and proxy.domain for your specific needs.
If you don't specify the
--php option, then just an nginx or Apache proxy is created. Otherwise, PHP-FPM with the specified PHP version is set up, too.
You can also specify a
-n) option - this prints to stdout a Bash script with commands to do the setting up. You might use this to inspect what would be done, as well as pipe it to a file if you want to customize the configurations in any way.
By default, an nginx-based proxy is created. For an Apache proxy, specify
--server apache as a command-line option.
The following directory tree is created:
│ ├── nginx -> /usr/sbin/nginx [if you didn't specify --server apache] OR
| ├── httpd -> /usr/sbin/httpd [if you specified --server apache]
│ ├── php-fpm -> /opt/remi/php81/root/usr/sbin/php-fpm [if you specified --php VERSION]
│ ├── restart [scripts to restart/start/stop the stack]
│ ├── start
│ └── stop
│ ├── nginx.conf [if you didn't specify --server apache] OR
│ └── httpd.conf [if you specified --server apache]
│ └── php-fpm.conf [if you specified --php VERSION]
├── lib [if you specified --php VERSION]
│ └── php.ini
├── log [log files will appear in here once you start the stack]
└── run [pid and socket files will appear in here once you start the stack]
How it works
Basically, the same way as the repository Sean posted above. Symlinks are created to the system binaries for nginx/Apache/php-fpm, configuration files for them to use are created, and scripts to start/stop/restart the stack are created. The static_app isn't touched at all - it's in the arguments because its path ends up inside some of the configuration files.
Feel free to try out the script and give me feedback if you have any questions, find any problems or want to suggest any improvements!