This is a fully detailed guide to install everything necessary to run MultiPortal on a brand new 22.04 LTS machine.
At the end of the guide, you'll have a fully working MultiPortal instance with the following components:
First, let's make sure the machine is up to date.
# Fetch latest updates
sudo apt update
# Install all updates automatically
sudo apt upgrade -y
sudo apt install -y \
debian-keyring \
debian-archive-keyring \
apt-transport-https \
curl \
software-properties-common \
git \
unzip \
libicu-dev
cron
Install mariaDB
sudo apt install -y \
mariadb-server
To install PHP 8.* we need to add the main PPA to your ubuntu server. For more details see PHP PPA
# Install Add Ondrej
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
Once the above respository has been added you can now run the following
sudo apt install -y \
php8.2 \
php8.2-cli \
php8.2-fpm \
php8.2-common \
php8.2-curl \
php8.2-gd \
php8.2-mbstring \
php8.2-mysql \
php8.2-opcache \
php8.2-xml \
php8.2-xmlrpc \
php8.2-imagick \
php8.2-zip
Edit the PHP configuration file to update upload settings:
sudo nano /etc/php/8.2/fpm/php.ini
Modify the following lines:
upload_max_filesize = 10G
post_max_size = 10G
max_execution_time = 360
Restart the PHP-FPM service:
sudo systemctl restart php8.2-fpm
cd /tmp
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -zxvf ioncube_loaders_lin_x86-64.tar.gz
Determine your PHP extension directory:
php -r "echo ini_get('extension_dir').PHP_EOL;"
Then copy the ionCube loader to that directory. Replace /path/to/php/extension_dir with the path from the output.
sudo cp /tmp/ioncube/ioncube_loader_lin_8.2.so /path/to/php/extension_dir/
Add the following line to your PHP configuration files:
/etc/php/8.2/fpm/php.ini
/etc/php/8.2/cli/php.ini
zend_extension = /path/to/php/extension_dir/ioncube_loader_lin_8.2.so
Restart the PHP-FPM service:
sudo systemctl restart php8.2-fpm
sudo systemctl enable php8.2-fpm
Confirm the extension has been installed by running:
php -v
If installed correctly the output will look similar:
PHP 8.2.25 (cli) (built: Oct 30 2024 11:26:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.25, Copyright (c) Zend Technologies
with the ionCube PHP Loader v14.0.0, Copyright (c) 2002-2024, by ionCube Ltd.
with Zend OPcache v8.2.25, Copyright (c), by Zend Technologies
Install Node.js and npm:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Download and install CaddyServer:
wget -q "https://github.com/caddyserver/caddy/releases/download/v2.7.6/caddy_2.7.6_linux_amd64.deb"
sudo apt install ./caddy_2.7.6_linux_amd64.deb
rm caddy_2.7.6_linux_amd64.deb
Download and install Composer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --quiet
sudo mv composer.phar /usr/local/bin/composer
curl -o ./installMultiportal https://downloads.multiportal.io/installer/ManualInstallation
chmod +x ./installMultiportal
Run the installer:
php ./installMultiportal YOUR_HOSTNAME
Navigate to the websocket directory and install dependencies:
cd /var/www/YOUR_HOSTNAME/websockets
sudo npm install
sudo npm install pm2 -g
Create a configuration file for your application:
sudo nano /etc/caddy/Caddyfile
Paste the following configuration (Changing YOUR_HOSTNAME):
YOUR_HOSTNAME {
@css path *.css
header @css Content-Type text/css
root * /var/www/YOUR_HOSTNAME/backend/web
encode gzip
file_server
php_fastcgi unix//var/run/php/php8.2-fpm.sock {
index index.php
}
# Add headers
header {
Access-Control-Allow-Origin *
Access-Control-Allow-Methods "GET, POST, OPTIONS"
x-frame-options SAMEORIGIN
Access-Control-Allow-Headers "Content-Type, Authorization"
}
# Error and access logs
log {
output file /var/log/caddy/YOUR_HOSTNAME.log
level error
}
# PHP handling
route / {
try_files {path} {path}/ /index.php?{query}
php_fastcgi unix//var/run/php/php8.2-fpm.sock {
env PHP_FCGI_MAX_REQUESTS 1000
}
}
# Static files
route / {
file_server
}
# Reverse proxy to Node.js server
reverse_proxy /wss* localhost:8081 {
header_up Host {host}
header_up X-Real-IP {remote}
}
}
If you wish to add your own TLS certificate instead of using the CaddyServer default LetsEncrypt process. Upload your certificate and private key to your server, then add the following after YOUR_HOSTNAME {
If you are using a combined file, you only need to add path to that combined file
YOUR_HOSTNAME {
tls /path/to/your/certificate /path/to/your/privatekey
...
Start and enable Caddy:
sudo systemctl start caddy
sudo systemctl enable caddy
Create a service file:
sudo nano /etc/systemd/system/multiportal.service
Add the following content (Changing YOUR_HOSTNAME):
[Unit]
Description=Multiportal Service
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/var/www/YOUR_HOSTNAME
ExecStart=/usr/bin/php /var/www/YOUR_HOSTNAME/yii queue/listen --verbose
Restart=on-failure
[Install]
WantedBy=multi-user.target
Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl enable multiportal.service
sudo systemctl start multiportal.service
sudo ufw allow https
sudo ufw --force enable
Visit your instance:
https://YOUR_HOSTNAME