[Part 1] Ubuntu server for web hosting

Bài đầu tiên trong series là Setup 1 con Ubuntu server.

Mình có 1 con HP EliteDesk 800 G2 với

  • i5-6400
  • 32GB RAM – 2666Mhz
  • SSD NVme Gen3 x4 : 256GB
  • SSD Sata : 120GB

OS

Read more: [Part 1] Ubuntu server for web hosting

Oki sau khi installed OS xong. Ta có 1 vài thứ cơ bản

Update /etc/sudoers và thêm vào cuối file

$USER ALL=(ALL) NOPASSWD:ALL
  • Update LVM 100% Storage
  • Update NTP & Timezone
curl -L https://raw.githubusercontent.com/jooservices/bash/main/services/vm | bash

Oki để hosting ta sẽ dùng Virtualmin.

Virtualmin is the leading and most sophisticated web hosting control panel designed for Linux systems.

Virtualmin

By default Virtualmin không có đủ hết các PHP versions do đó ta sẽ install thêm

curl -L https://raw.githubusercontent.com/jooservices/bash/main/services/multi-php.sh | bash

Cơ bản 1 con web hosting như vậy là đủ. Một số packages bổ sung tùy chọn

By default Webmin / Virtualmin sẽ enable firewall. Do đó nếu cần access từ ngoài vào với các 3rd party services / ports thì cần update rules

Live site : https://selfhosted.jooservices.com

Để setup domain / Cloudflare trỏ về Virtualmin ta sẽ dùng HAProxy ở bài sau

Bash script setup basically VM

No password required with sudo

joos ALL=(ALL) NOPASSWD:ALL

Extend LVM

sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Setup timezone

sudo timedatectl set-timezone Asia/Ho_Chi_Minh
sudo timedatectl set-ntp on

Docker

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Setup PHP

#!/bin/bash

echo 'Install requirements'

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update && sudo apt upgrade -y

phpVersions=('8.3')
phpExtensions=('dev' 'cli' 'mbstring' 'curl' 'intl' 'mbstring' 'xml' 'xmlrpc' 'xsl' 'yaml' 'zip' 'imagick' 'gd' 'opcache' 'memcache' 'memcached' 'mysql' 'sqlite3' 'ldap' 'bcmath' 'fpm')
phpPecls=('mongodb' 'redis' 'pcov' 'apcu')

for phpVersion in "${phpVersions[@]}"
do
  echo "Install PHP ${phpVersion} extensions"
  extensions=$(printf "php${phpVersion}-%s " "${phpExtensions[@]}")
  sudo apt install -y $extensions

  echo "Install PHP ${phpVersion} pecl extensions"
  for phpPecl in "${phpPecls[@]}"
  do
    sudo pecl -d php_suffix="${phpVersion}" install "${phpPecl}"
    sudo pecl uninstall -r "${phpPecl}"    
    sudo bash -c 'echo "extension='${phpPecl}'.so" >> /etc/php/'${phpVersion}'/cli/php.ini'
    sudo bash -c 'echo "extension='${phpPecl}'.so" >> /etc/php/'${phpVersion}'/fpm/php.ini'
  done
done

Directive

Working as a Full Stack Developer at Directive Company was a significant milestone in my career. My role at Directive included providing customer support as well as developing new features for the company’s website. This experience provided me with a unique opportunity to learn and grow in many areas of web development.

As a supporter at Directive company, I was tasked with inspecting and resolving errors on customers’ websites. This involved identifying errors that may have been caused by code extensions, conflicts with third-party extensions, or user configuration errors. I utilized my skills in Joomla!, PHP & MySQL, HTML / CSS, Javascript / jQuery to diagnose the issues and provide solutions. In addition to providing customer support, I was also responsible for developing new features for the company’s website. This experience allowed me to expand my skill set and learn new technologies. I worked closely with my colleagues to implement requirements for the company, and I was able to apply my knowledge to develop new features that enhanced the user experience.

Overall, my experience at Directive Company provided me with an opportunity to learn new skills, gain experience in customer support, and hone my skills as a full stack developer. I am grateful for the experiences and skills that I gained while working at Directive.

VietProtocol

Working experience can be invaluable for personal and professional growth, and working with the right company can provide a wealth of opportunities for learning and development. For me, VietProtocol was that company. As the first and only Vietnamese company that I worked with, it provided me with a unique set of experiences that helped me hone my web development skills.

One of the most valuable experiences I gained while working at Vietprotocol was developing a website based on Joomla!. This involved using CSS for HTML, developing Joomla! templates from PSD, building complete websites on Joomla!, customizing templates and extensions, and working closely with designers to turn PSD design files into functional websites.

Additionally, there was no specific process for customer contact and feedback, which required me to be adaptable and flexible in my approach to working with clients. Through my experience at VietProtocol, I gained a deep understanding of web development principles and honed my skills in creating stunning and user-friendly websites. This experience provided me with a solid foundation for future endeavors and helped me grow both personally and professionally.

Kind of websites

  • Company portfolio
  • E-Commercial