Links

DigitalOcean

DigitalOcean is a cloud hosting provider that offers cloud computing services and Infrastructure as a Service (IaaS)
Table of contents:

How to create a droplet in DigitalOcean?

In this article, firstly we will create a new droplet in DigitalOcean.
We recommend creating a LEMP server from the marketplace with at least 2+ CPU cores and 2GB+ memory.
Next, choose a plan:
Choose a data center region that one close to your location:
We chose the Frankfurt data center because close to us
Here you can choose a password or ssh key to log in to your server. We recommend choosing SSH keys to log in (the best secure way).
And after submitting the "Create droplet" button , you will see a progress bar for your droplet:
Next click the created droplet:
And here is your IP Address and username for server:
You can connect to your server with your credentials. We are using Termius like SSH client to connect, but you can use different SSH client ( PuTTy ). You can also connect by Digitalocean Console (above, you can use "Launch Droplet Console" button).
And here we connected the server:
​Uvodo 2.0.0 requires PHP 8.0.2+, Node v16.0.0+ and Composer v2.4+ (globally installed). Other than that, following PHP extensions are required: ​
  • zip
  • pdo
  • json
  • mbstring
  • openssl
  • pcre
  • tokenizer
  • ctype
  • fileinfo
  • filter ​ Also, you need to have npm installed globally and PHP passthru function must be enabled.
Let's check everything is OK in our server or not.

Install PHP (>= 8.1)

Firstly , check php version :
$ php -v
​Uvodo 2.0.0 requires PHP 8.0.2+ , and our current PHP version is 8.0.8.
If your PHP version is less than 8.0.2 , then you have to upgrade. Here is PHP version upgrade instructions.
These commands are eligible with Ubuntu or Debian-based distros
First, let’s update your System packages and install some dependencies as shown below.
$ sudo apt update
$ sudo apt upgrade
# Allow apt to use the repository via HTTPS
$ sudo apt install ca-certificates apt-transport-https
$ sudo apt install software-properties-common
Next, add the Ondrej PPA which is maintained by Ondřej Surý, a Debian developer who has been packaging PHP for Debian since PHP 5.
$ sudo add-apt-repository ppa:ondrej/php
When prompted, press ENTER to proceed with adding the repository.
If you'd like to use PHP 8.1 with Nginx installation, the most recommended step is to install PHP-FPM to process PHP files. You can install PHP and PHP-FPM using the following command:
$ sudo apt install php8.1 php8.1-fpm
The PHP-FPM service should start automatically. You can verify this as shown:
$ sudo systemctl status php8.1-fpm
Here you can install the PHP8.1 extensions:
$ sudo apt install php8.1-{bcmath,xml,fpm,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi,pdo}
Now we configure PHP for web applications by changing some values in the php.ini file. For PHP 8.1 FPM with Nginx, the php.ini location will be in the following directory.
sudo nano /etc/php/8.1/fpm/php.ini
Change following variables in the php.ini
upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000
After these changes need to restart PHP Fpm :
sudo service php8.1-fpm restart

Install NGINX

Check NIGNX status :
sudo systemctl status nginx
If there is not nginx , you can install with following command :
sudo apt install nginx
Before testing Nginx, the firewall software needs to be adjusted to allow access to the service. Nginx registers itself as a service with ufw upon installation, making it straightforward to allow Nginx access.
To check the ufw list, use this command :
sudo ufw app list
At first, add ssh to the firewall :
sudo ufw allow sshsudo ufw allow OpenSSH
After that, to enable Nginx on the firewall, use this command :
sudo ufw allow 'Nginx HTTP'
Now enable the firewall :
sudo ufw enable
sudo ufw default deny
You can verify the change by typing :
sudo ufw status
After the installation , restart nginx :
sudo systemctl restart nginx
And check nginx latest status :
sudo systemctl status nginx
Firstly need to create conf file for your domain
Here is conf example , under /etc/nginx/sites-available , create example.com file, and
paste :
server {
server_name example.com www.example.com;
root /var/www/html/example.com/public;
include snippets/common.conf;
include snippets/gzip.conf;
include snippets/cache.conf;
access_log /var/log/example.com/access.log;
error_log /var/log/example.com/error.log;
}
Here is common.conf , has to locate under /etc/nginx/snippets :
client_max_body_size 20M;
index index.php index.html index.html;
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# Fix for the deploy script symlinks
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
# With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# Deny all hidden files (starts with dot)
location ~ /\. {
deny all;
}
Here is gzip.conf , has to locate under /etc/nginx/snippets :
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_buffers 16 8k;
gzip_types
text/plain
text/javascript
text/xml
text/css
text/vtt
text/cache-manifest
text/vcard
text/vnd.rim.location.xloc
text/x-cross-domain-policy
text/x-component
application/xml
application/xhtml+xml
application/rss+xml
application/js
application/javascript
application/x-javascript
application/x-httpd-php
application/x-httpd-fastphp
application/atom+xml
application/json
application/ld+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/manifest+json
application/vnd.geo+json
font/opentype
image/svg+xml
image/x-icon
image/bmp;
# text/html is always compressed by gzip modul
Here is cache.conf , has to locate under /etc/nginx/snippets :
# Disable etag
etag off;
# Default cache control.
# no-cahe
expires -1;
# Cache JS, CSS files for a year.
# They will be updated with cache control unique strings on each
location ~* \.(css|js)$ {
expires 365d;
}
# Cache other static files for 7 days
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|svg|ogg|mp4|webm|woff|woff2|ttf|eot|otf|)$ {
expires 7d;
}
After that , to enable a website, you must create a symbolic link inside the /etc/nginx/sites-enabled directory pointing to the actual vhost file in /etc/nginx/sites-available
Here is command you need :
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Lastly , need to restart nginx :
sudo systemctl restart nginx

Install MySQL

sudo apt install mysql-server
Connect and create mysql database & user
sudo mysql
CREATE DATABASE uvodo_db;
CREATE USER 'uvodo_user'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';
GRANT ALL ON uvodo_db.* TO 'uvodo_user'@'%';
FLUSH PRIVILEGES;
We use MySQL user name uvodo_user and MYSQL password uvodo_db. Make sure you change at least MySQL password for security.

Change permission for www folder

sudo chown -R $USER:$USER /var/www
Upload uvodo your zip under /var/www/html folder , and unzip here :
If you don't have zip module in your server , install with this command :
sudo apt install unzip
And unzip command :
unzip uvodo-2.0.2.zip -d example.uvodo.com

Install Composer ( v2.4+ globally installed)

Now we need composer to run , if you don't have composer , then here is installation flow :
Go to home folder and run this command :
$ cd ~
$ curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. To facilitate the verification step, you can use the following command to programmatically obtain the latest hash from the Composer page and store it in a shell variable:
HASH=`curl -sS https://composer.github.io/installer.sig`
If you want to verify the obtained value, you can run:
echo $HASH
Output:
Outpute0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
$ php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
You’ll see the following output:
Installer verified
If the output says Installer corrupt, you’ll need to download the installation script again and double check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue.
To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
You’ll see output similar to this:
OutputAll settings correct for using Composer
Downloading...
Composer (version 2.2.9) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
To test your installation, run:
composer
Output:
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version Composer version 2.2.9 2022-03-15 22:13:37
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
...
This verifies that Composer was successfully installed on your system and is available system-wide.

Install Node ( > 15 )

Uvodo need node js to build admin ui . You have to install node js ( >= 16 ). If you don't have node js in your server , you can install by command :
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same.
source ~/.bashrc
The nvm installation is successfully completed on your Ubuntu system.
$ nvm use 18.11.0

Install Uvodo
🎉

Go to /var/www/html/example.uvodo.com and just run :
$ composer uvodo:install
After completing all steps , you will see this screen :
You need folder permissions under project ( /var/www/html/example.uvodo.com) :
$ chmod -R 777 .

That's it. Uvodo is ready
🎉
🎉
🔥

This is your admin panel - example.uvodo.com/admin
This is your storefront panel - example.uvodo.com
You have to add supervisor to handle the queue tasks. There is our article about it. You can read from here Supervisor