Skip to content

Instantly share code, notes, and snippets.

@mrl22
Last active May 22, 2024 17:56
Show Gist options
  • Save mrl22/074b40f1ed12d7e47f1be515fdb6a2b3 to your computer and use it in GitHub Desktop.
Save mrl22/074b40f1ed12d7e47f1be515fdb6a2b3 to your computer and use it in GitHub Desktop.
PHP 8.3 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 STILL does not support anything above PHP 7.4 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.3 with all the packages moss installs for 7.4.

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

Lets configure PHP 8.3 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.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/myuser.conf
sed -i 's/\[www\]/\[myuser\]/g' /etc/php/8.3/fpm/pool.d/myuser.conf
sed -i 's/www-data/myuser/g' /etc/php/8.3/fpm/pool.d/myuser.conf
sed -i 's/php8.3-fpm/php8.3-fpm-myuser/g' /etc/php/8.3/fpm/pool.d/myuser.conf

Restart php-fpm

service php8.3-fpm reload

Now we switch Apache/NGINX/OpenResty from PHP 7.4 to 8.3 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.3-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.3-fpm-myuser/g' /usr/local/openresty/nginx/sites/mysite.com.conf

Restart OpenResty

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