This guide will help you set up a basic development environment on Ubuntu with the following tools:
Start by updating and upgrading your Ubuntu packages to make sure you have the latest versions and security patches.
sudo apt update && sudo apt upgrade -y
This will: Update the local package index (apt update) Upgrade all the installed packages to the latest version (apt upgrade)
Next, we'll install nvm (Node Version Manager) to manage multiple versions of Node.js.
Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Once the installation is complete, you’ll need to restart your terminal or source your profile:
source ~/.bashrc # Or use ~/.zshrc or ~/.profile based on your shell
Verify the Installation You can verify that nvm is installed successfully by running:
command -v nvm
If the installation was successful, it should return nvm.
Now that nvm is installed, you can use it to install Node.js version 20:
nvm install 20
To set Node.js version 20 as the default version for your terminal sessions, run:
nvm use 20
nvm alias default 20
You can verify the installed version of Node.js by running:
node -v
Git is essential for version control. To install Git, run the following:
sudo apt install git -y
To check if Git is installed correctly, run:
git --version
Install NGINX
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo apt install mysql-server -y
Secure the MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure the database.
Add the repository and install PHP:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php8.3 php8.3-fpm php8.3-cli php8.3-mysql php8.3-curl php8.3-xml php8.3-mbstring php8.3-zip php8.3-bcmath php8.3-gd php8.3-intl php8.3-readline -y
Restart PHP-FPM:
sudo systemctl restart php8.3-fpm
sudo apt install phpmyadmin -y
During the installation, select NGINX and configure the database for phpMyAdmin.
Create a symbolic link for phpMyAdmin in the NGINX web directory:
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
Restart NGINX:
sudo systemctl restart nginx
Log in to MySQL:
sudo mysql -u root -p
Create a new user:
CREATE USER 'phpmyadmin_user'@'localhost' IDENTIFIED BY 'secure_password';
Grant privileges:
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin_user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Allow necessary ports:
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
curl -fsSL https://code-server.dev/install.sh | sh
mkdir -p ~/.config/code-server
nano ~/.config/code-server/config.yaml
Add the following configuration:
bind-addr: 127.0.0.1:8080
auth: password
password: "your_secure_password"
cert: false
Save and exit (CTRL+X
, Y
, ENTER
).
Start Code Server:
code-server
To run it as a service:
sudo systemctl enable --now code-server@$USER
sudo apt install certbot python3-certbot-nginx -y
Obtain an SSL certificate:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Verify auto-renewal:
sudo certbot renew --dry-run
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Reload shell configuration:
source ~/.bashrc # For Bash users
source ~/.zshrc # For Zsh users
Verify NVM installation:
nvm --version
nvm install 20
Set Node.js 20 as the default version:
nvm use 20
nvm alias default 20
Verify Node.js installation:
node -v
npm -v
Your Ubuntu system is now updated, secured, and configured with a sudo user, MySQL, NGINX, PHP 8.3, phpMyAdmin, UFW firewall, Code Server, SSL with Let's Encrypt, NVM, and Node.js 20.