How to install LeaderOS on Ubuntu
A full guide for installing, configuring and running LeaderOS on your Ubuntu server, for use in production.
Before starting the installation process, make sure your domain nameservers/DNS are configured. Otherwise, you would not be able to access to the website.
Learn how to configure your domain nameservers/DNS here.
Auto Installation
Download the installation script
Make the script executable.
Run the script.
Manual Installation
Install Nginx package
Ensure that nginx is running with the systemctl start
command:
Setting Up Nginx Server Blocks
When using the Nginx web server, server blocks (similar to virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain from a single server. We will set up a domain called your_domain.com, but you should replace this with your own domain name.
Create directory for your your_domain.com
Next, assign ownership of the directory with the www-data.
Configuring Nginx
In order for Nginx to serve this content, it’s necessary to create a server block with the correct directives. Instead of modifying the default configuration file directly, let’s make a new one at /etc/nginx/sites-available/your_domain.com
:
Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:
Next, let’s enable the file by creating a link from it to the sites-enabled directory, which Nginx reads from during startup:
Finally, restart nginx for the configuration to take effect.
Installing PHP 7.4
Ubuntu
Thereafter, install some important packages to fulfill the post.
The next step is to add the ondrej PPA repository.
Refresh APT to load the new repository:
And now you can install PHP 7.4
E: Package ‘php7.4’ has no installation candidate
If you get this error while installing PHP 7.4. Run this command:
Ubuntu 23.10:
sudo sed -i 's/mantic/jammy/' /etc/apt/sources.list.d/ondrej-ubuntu-*.sources
Ubuntu 23.04:
sudo sed -i 's/lunar/jammy/' /etc/apt/sources.list.d/ondrej-ubuntu-*.list
Then refresh APT:
sudo apt update -y
Now, you can install php 7.4:
sudo apt install php7.4 -y
Install required php extensions.
Start and enable the php7.4-fpm service.
Debian
Thereafter, install some important packages to fulfill the post.
Import and install the GPG key and repository using an automated script.
Refresh APT to load the new repository:
And now you can install PHP 7.4
Install required php extensions.
Start and enable the php7.4-fpm service.
Configure PHP Settings
In order for the LeaderOS software to work, some php settings need to be configured. Open the php.ini file with nano or your preferred text editor.
Add these lines at the end.
Then save and exit the file. Now we need to restart the nginx and php-fpm for the settings to come into effect.
Installing Ioncube Loader
Download IonCube Loader files.
Then uncompress the downloaded file using the tar command.
Switch into the unzipped folder.
Next, find the location of the extension directory for PHP version 7.4, it is where the ioncube loader file will be installed.
Output: extension_dir => /usr/lib/php/20190902 => /usr/lib/php/20190902
Next we need to copy ioncube loader for our PHP 7.4 version to the extension directory (/usr/lib/php/20190902).
Now we need to configure ioncube loader to work with PHP, in the php.ini file.
Then add below line as the first line in the respective php.ini file.
Then save and exit the file. Now we need to restart the nginx and php-fpm for the ioncube loaders to come into effect.
Installing MariaDB (MySQL)
Install the mariadb package.
Ensure that MariaDB is running with the systemctl start command:
Additionally, consider enabling MariaDB to start every time on system startup as shown.
Open up the MariaDB prompt from your terminal:
Next, create a regular user. Here, we are creating a user called leaderos. Be sure to replace secret_password with your preferred user’s password.
Next, create a database:
Next, grant all privileges to leaderos user. This effectively assigns all the database root user’s permissions to the user.
To apply the changes, flush the privileges.
Finally, exit the MariaDB prompt.
Configuring MariaDB (MySQL)
Open the MariaDB configration file.
Add these lines under [mysqld] section.
Then save and exit the file. Now we need to restart the MariaDB for the settings to come into effect.
Installing LeaderOS
Upload the leaderos.zip file to /var/www/your_domain.com/html via FTP and unzip the leaderos.zip file.
Visit your website. You will see the installation page.