Skip to content

Instantly share code, notes, and snippets.

@mrl22
Last active May 22, 2024 18:01
Show Gist options
  • Save mrl22/cbc72c0ab07c49f04b621c6fca52c1e8 to your computer and use it in GitHub Desktop.
Save mrl22/cbc72c0ab07c49f04b621c6fca52c1e8 to your computer and use it in GitHub Desktop.
PHP 8.1 Support for Apache and NGINX (OpenResty) on Moss.sh

Do not copy and paste this code, it requires changes

Other PHP versions available here: https://gist.github.com/search?q=user%3Amrl22+moss

As of writing this, Moss.sh does not support PHP 8.1 via the control panel even though Ubuntu does.

Set up your website using Moss.sh and select Apache with PHP 7.4.

Once complete, we need to install PHP 8.1 with all the packages moss installs for 7.4.

apt install php8.1-bcmath php8.1-bz2 php8.1-cli php8.1-common php8.1-curl php8.1-dev php8.1-fpm php8.1-imap php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-pgsql php8.1-readline php8.1-soap php8.1-sqlite3 php8.1-xml php8.1-xmlrpc php8.1-zip php8.1-gd php8.1-igbinary php8.1-imagick php8.1-memcached php8.1-msgpack

Lets configure PHP 8.1 FPM for the sites user so that Apache or NGINX can process PHP scripts. Make sure to change myuser to your sites user.

cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/myuser.conf
sed -i 's/\[www\]/\[myuser\]/g' /etc/php/8.1/fpm/pool.d/myuser.conf
sed -i 's/www-data/myuser/g' /etc/php/8.1/fpm/pool.d/myuser.conf
sed -i 's/php8.1-fpm/php8.1-fpm-myuser/g' /etc/php/8.1/fpm/pool.d/myuser.conf

Restart php-fpm

service php8.1-fpm reload

Now we switch Apache/NGINX/OpenResty from PHP 7.4 to 8.1 by replacing some words. Again, make sure to replace myuser and mysite.com configuration file.

Apache Method

sed -i 's/php7.4-fpm-myuser/php8.1-fpm-myuser/g' /etc/apache2/sites-enabled/mysite.com.conf

Restart Apache

service apache2 restart

NGINX/OpenResty Method

Moss.sh uses OpenResty which is a fork of NGINX, but they label it as NGINX in their control panel.

sed -i 's/php7.4-fpm-myuser/php8.1-fpm-myuser/g' /usr/local/openresty/nginx/sites/mysite.com.conf

Restart OpenResty

service openresty restart
@mrl22
Copy link
Author

mrl22 commented Apr 11, 2023

@eartisan-uk The closest I have found is cleavr.io. It has many more features and is built better, in my opinion. From a Laravel development point of view, Cleavr is not as good as Moss though. Cleavr has had a lot of development in the last few months and works very well with Laravel, even supporting queues and workers.

With newer Laravel projects, I have written my own GitHub actions, which replicate what Capistrano does to deploy a project. No requirement on any platform other than Github to deploy.

Moss uses Ansistrano/Capistrano to deploy from version control, where it has a releases/current folder with the symlink. I do try to release as much code as possible, so I may release it someday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment