How to Setup a Development Machine
Last updated on Oct 1, 2022
Software Versions
| Name | Description | Version |
|---|---|---|
| Ubuntu Desktop | Jammy Jellyfish on April 22, 2022 | 22.04 |
| MariaDB | Database Server | 10.6 |
| Apache Httpd | Web Server | 2.4 |
| Nginx | Web Server & Reverse Proxy | 1.18 |
| Redis | Cach Server | 6 |
| PHP | Server-side Scripting Language | 8.1 |
| Python | Programming Language | 3.9 & 3.10 |
Install Ubuntu Desktop
Install Standalone/Multiboot Mode
Download Ubuntu Desktop
Download an Ubuntu image from Ubuntu official site. Make sure to save it to a memorable location on your PC.
Create an Ubuntu Live USB
Create a bootable USB stick with balenaEtcher on Linux, Windows and Mac OS.
Install Ubuntu Deskop from Ubuntu Live USB
Install on Windows using WSL
How to Install Linux on Windows with WSL
Update Software Packages
Press Ctrl+Alt+T to open up terminal window and issue the following commands to update ubuntu software packages.
$ sudo apt update $ apt list --upgradable $ sudo apt upgrade
Install MariaDB Database Server
Enter the following command to install MariaDB.
$ sudo apt install mariadb-server mariadb-client
Use systemctl to check MariaDB status.
$ systemctl status mariadb
Run the post-installation security script.
$ sudo mysql_secure_installation
Check MariaDB server version information.
$ mariadb --version
Login without providing MariaDB root password.
$ sudo mariadb
Create a dedicated MariaDB user
GRANT ALL ON . TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT;
Login test with dedicated user
$ mariadb -u admin -p
Install Apache HTTP Server
Install Apache Web server and useful utilities.
$ sudo apt install -y apache2 apache2-utils
Check Apache status with systemctl.
$ sudo systemctl status apache2
Check Apache version:
$ apache2 -v
FIX: Could not reliably determine the server's fully qualified domain name:
$ echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf $ sudo a2enconf fqdn $ sudo systemctl restart apache2
Access Apache 2 default page from browser:
http://localhost
Install PHP
Install PHP 8.1 and some common PHP modules.
$ sudo apt install php php-fpm php-cli php-mysql
Enable the Apache php8.1 module.
$ sudo a2enmod proxy_fcgi setenvif $ sudo a2enconf php8.1-fpm
Restart Apache Web server.
$ sudo systemctl restart apache2
Check PHP version information.
$ php --version
Create a phpinfo() file in the document root directory To test PHP scripts with Apache server.
$ echo "" | sudo tee /var/www/html/info.php
Access phpinfo() file from browser:
http://localhost/info.php
Install phpMyAdmin
Install phpMyAdmin with the command below.
$ sudo apt install phpmyadmin
Choose options on installation.
Choose Webserver. -> Apache 2
Configure database for phpmyadmin with dbconfig-common? -> Yes
MySQL application password for phpmyadmin: -> leave blank
Check the privileges of phpmyadmin user.
$ sudo mariadb
SHOW GRANTS FOR phpmyadmin@localhost;
Access phpMyAdmin web interface from browser:
http://localhost/phpmyadmin/
Reconfigure if failure:
$ sudo dpkg-reconfigure phpmyadmin
Install Adminer
Install Adminer.
$ sudo apt install adminer
Enable the Adminer module.
$ sudo a2enconf adminer
Reload Apache Web server
$ sudo systemctl reload apache2
Access the Adminer web interface from browser.
http://localhost/adminer/
Install Nginx Web Server & Reverse Proxy
First, stop Apache 2 to avoid conlicts:
$ sudo systemctl stop apache2
Install Nginx (Full):
$ sudo apt install nginx-extras
Check Nginx status with systemctl.
$ sudo systemctl status nginx
Check Nginx version:
$ nginx -v
Setup Nginx as Webserver and Reverse Proxy
Configure Apache 2 behind Nginx Reverse Proxy
Rename Apache’s ports.conf configuration file:
$ sudo mv /etc/apache2/ports.conf /etc/apache2/ports.conf.default
Create a new ports.conf file with the port set to 8080:
$ echo "Listen 8080" | sudo tee /etc/apache2/ports.conf
Disable the default virtual host:
$ sudo a2dissite 000-default.conf
Now open the new virtual host file:
$ sudo nano /etc/apache2/sites-available/001-default.conf
Put the content below into opened file:
<virtualhost *:8080="">
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</virtualhost>
Save the file and activate the new virtual host configuration file:
$ sudo a2ensite 001-default
Test Apache's configuration:
$ sudo apachectl -t
Syntax OK
Then start Apache:
$ sudo systemctl start apache2
Configuring Nginx as a Reverse Proxy
Create conf directory to store new configurations:
$ sudo mkdir -p /etc/nginx/conf
Create upstreams configuration file and add Apache 2 as upstream server:
$ sudo nano /etc/nginx/conf/upstreams.conf
upstream apache2 {
server 127.0.0.1:8080 fail_timeout=0;
}
Enable upstreams configuration:
$ sudo ln -s /etc/nginx/conf/upstreams.conf /etc/nginx/conf.d/80-upstreams.conf
Create proxy parameters snippet file:
$ sudo nano /etc/nginx/snippets/proxy-params.conf
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Use-X-Accel-Redirect True;
proxy_set_header Host $host;
proxy_read_timeout 120;
proxy_redirect off;
proxy_intercept_errors off;
Setup default server configuration:
$ sudo rm /etc/nginx/sites-enabled/default $ sudo nano /etc/nginx/conf/default.conf
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.nginx-debian.html index.html index.htm index.php;
server_name _;
# Serve certain paths from Apache 2
location ~ ^/(phpmyadmin|adminer) {
include snippets/proxy-params.conf;
proxy_pass http://apache2;
}
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
location / {
try_files $uri $uri/ =404;
}
# Serve PHP files from php-fpm
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
# Deny access to .htaccess files.
location ~ /\.ht {
deny all;
}
}
Enable default server configuration:
$ sudo ln -s /etc/nginx/conf/default.conf /etc/nginx/conf.d/90-default.conf
Check Nginx configuration is valid:
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart Nginx server to make changes:
$ sudo systemctl restart nginx
Access Nginx default page, phpinfo(), phpMyAdmin and Adminer pages from browser:
http://localhost
http://localhost/info.php
http://localhost/phpmyadmin
http://localhost/adminer
Install Redis Server
Install Redis using the following command:
$ sudo apt install redis-server
Once the installation is completed, you can check the version of Redis using the following command:
$ redis-server -v
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6
Configure Locale
Check which locales are supported:
$ locale -a
Add the locales you want (for example en_US):
$ sudo locale-gen en_US $ sudo locale-gen en_US.UTF-8
Run this update command:
$ sudo update-locale
Update system locale:
$ sudo localectl set-locale LANG=en_US.utf8
Update /etc/environment file:
$ sudo nano /etc/environment
Add the following lines, save and close the file:
...
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8