LENKRAD - The modern PHP core
Basics
Advanced
Deployment

Deployment

Manual deployment

We are working on various deployment helpers. For now, here is a checklist for manual deployment.

Checklist initial installation

  • Apache or Nginx installed and configured?
  • PHP and required modules installed?
  • Database (MySQL) installed & configured?
  • Codebase uploaded?
  • Domain & SSL set up?

Checklist continuous deployment

  • Packages updated?
  • Models migrated?

Example: Initial installation on AWS EC2

If you are using AWS EC2, this could be your first deployment procedure:

1. Create ec2 instance running Ubuntu (20.04 or higher)

Store the pem-key & set the security group to accept traffic from anywhere on port 443 and 80.

2. Log into the instance via ssh

There are multiple ways of doing so depending on your OS. We recommend using WSL on Windows to unify the instructions for the following procedure.

In your terminal, go to the folder ".ssh"


            cd ~/.ssh
            mkdir keys
            cp /path/to/downloaded/pem-key.pem keys/pem-key.pem
            chmod 400 keys/pem-key.pem
        

Then, open the file config in vim/nano or similar and set up the following:


            Host    my-lenkrad-server
            HostName    [public-aws-ip]
            User    ubuntu
            IdentityFile ~/.ssh/keys/pem-key.pem
        

You should now be able to ssh into the instance with the command "ssh my-lenkrad-server".

3. Install apache, php, certbot, and mysql

Once logged into your instance, run the following commands:

Apache & mysql


            sudo apt update
            sudo apt install apache2 mysql-server
            sudo mysql_secure_installation
        
Consider setting up a dedicated user with restricted permissions

PHP & modules


            sudo apt install software-properties-common
            sudo add-apt-repository ppa:ondrej/php
            sudo apt update
            sudo apt install php8.2 libapache2-mod-php8.2
            sudo apt install php8.2-{mysql,zip,xml,curl}
            sudo service apache2 restart
        

Upload codebase

Upload your codebase to a folder in /var/www.

Domain setup


            cd /etc/apache2/sites-available
            sudo cp 000-default.conf my-domain.com.conf
            sudo nano my-domain.com.conf
        

Assuming you have a domain pointing to the public IP of your server, you can make the following changes:


        

Save the file, then


            sudo a2ensite my-domain.com
            sudo service apache2 restart
        

SSL for free, baby


            sudo snap install --classic certbot
            sudo ln -s /snap/bin/certbot /usr/bin/certbot
            sudo certbot --apache
        

Setup .env & migrate


            cd /var/www/YOUR_UPLOAD_FOLDER
            nano .env
        

Add needed environment variables and save. You will likely need at least:

  • DB_NAME
  • DB_USER
  • DB_PASSWORD
  • JWT_SECRET
  • APPLICATION_ID

, but the actual requirements depend on your application.

Lastly, migrate your database


            php cli migrate:models mysql
        
Running in a subdirectory of a domain on apache? then don't forget to change the .htaccess file in /public

Before you move on

Many references on this page assume default settings. Your project might differ in behavior, paths etc.