Installing Blesta
Download Blesta
- Download Blesta from their Official Website
- Install unzip with
apt install unzip - Extract the zip with
cd /var/www && unzip blesta*
Install Apache
apt install apache2Generating SSL/TLS Certificates
Downloading Certbot
To begin, we will install certbot, a simple script that automatically renews our certificates and allows much easier creation of them. The command below is for Ubuntu distributions, but you can always check Certbot’s Official Website for installation instructions. We have also included a command below to install certbot’s Apache plugin so you won’t have to stop your webserver.
apt update
apt install -y certbot python3-certbot-apacheCompleting the HTTP Challenge
- Make sure you have port 80 open on your firewall
- Request a certificate from Let’s Encrypt, you should replace
billing.example.comwith the domain you would like to generate a certificate for.
certbot certonly --apache -d billing.example.comAutomatically Renewing SSL/TLS certificates
- Install crontab:
apt install cron- Create a crontab rule for the automatic renewal:
(crontab -l ; echo "0 23 * * * certbot renew --quiet --deploy-hook \"systemctl restart apache2\"")| crontab -Webserver Configuration
Remove the default configuration:
a2dissite 000-default.conf- Create a new Apache site configuration like
blesta.confin/etc/apache2/sites-availableusing a text editor like nano or vim. - Paste the text below into the file, replacing
billing.example.comwith your domain:
blesta.conf
<VirtualHost *:80>
ServerName billing.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/blesta
Options -Indexes
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:443>
<Directory /var/www/>
Options -Indexes
AllowOverride All
Require all granted
Order allow,deny
allow from all
</Directory>
ServerName billing.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/blesta
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# PHP Limits
php_value upload_max_filesize 100M
php_value post_max_size 100M
# SSL Configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/billing.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/billing.example.com/privkey.pem
# Headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Robots-Tag "none"
Header always set Content-Security-Policy "frame-ancestors 'self'"
Header always set X-Frame-Options "DENY"
Header always set Referrer-Policy "same-origin"
Header always set Permissions-Policy "accelerometer=(), camera=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), usb=()"
</VirtualHost>Link Config
Enable your new Apache website configuration and required modules:
ln -s /etc/apache2/sites-available/blesta.conf /etc/apache2/sites-enabled/blesta.confInstall PHP
apt-add-repository universe
apt -y install libapache2-mod-php8.1 php8.1 php8.1-{common,cli,gd,mysql,mbstring,bcmath,xml,fpm,curl,zip,bcmath,gmp,intl,mbstring,soap}Install IonCube
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -xzvf ioncube_loaders_lin_x86-64.tar.gz
cp ioncube/ioncube_loader_lin_8.1.so /usr/lib/php/20210902/Add IonCube Extension to CLI PHP.ini:
/etc/php/8.1/cli/php.ini
zend_extension = "/usr/lib/php/20210902/ioncube_loader_lin_8.1.so"Add IonCube Extension to Apache PHP.ini:
/etc/php/8.1/apache2/php.ini
zend_extension = "/usr/lib/php/20210902/ioncube_loader_lin_8.1.so"Check if IonCube was successfully installed:
php -vEnable Required Modules
a2enmod rewrite
a2enmod headers
a2enmod ssl
# List Modules
apachectl -MRestart Apache and PHP
systemctl restart apache2
systemctl restart php8.1-fpmInstall MariaDB
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
apt install mariadb-serverEnter MySQL Shell
mysqlCreate Database
CREATE DATABASE blesta;
CREATE USER 'blestauser'@'127.0.0.1' IDENTIFIED BY 'somePasswordHere';
GRANT ALL PRIVILEGES ON blesta.* TO 'blestauser'@'127.0.0.1';Setting File Permissions
chown -R www-data:www-data /var/www/blesta
chown -R www-data:www-data /var/www/uploads
chown -R www-data:www-data /var/www/logs_blestaCreate Blesta Cronjob
(crontab -l ; echo "*/5 * * * * php /var/www/html/index.php cron > /dev/null 2>&1")| crontab -Begin Setup
- Visit your domain and click “Click here to begin…”
- Read and either agree or disagree with the Blesta EULA
- Fix any errors, most commonly are simple file permission errors
- Input your database login credentials
- Input your license and create an administrator user