Create a new ssh key in your computer.
Add the pub key to the AWS key pair directory.
Create new Ubuntu server and add access to port 3306 to it.
Connect to server using the same key.
Run the following commands in the server.
sudo apt update
sudo apt upgrade -y
sudo reboot
Open ports for UFW.
sudo ufw allow OpenSSH
sudo ufw allow 3306
sudo ufw enable
Install NGINX
sudo apt install nginx
Check if NGNIX is working by accessing the public ipv4 address in the browser.
Allow NGINX for UFW.
sudo ufw app list
sudo ufw allow 'Nginx Full'
Setup MySQL.
sudo apt install mysql-server
sudo mysql
Exit if everything worked.
Install phpMyAdmin.
sudo apt install php-fpm php-mysql
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
Create new SQL user.
sudo mysql
mysql> CREATE USER '<user>'@'localhost' IDENTIFIED WITH caching_sha2_password BY '<password>';
mysql> GRANT ALL PRIVILEGES ON *.* TO '<user>'@'localhost' WITH GRANT OPTION;
mysql> exit
Copy phpMyAdmin configuration to NGINX.
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo service nginx restart
sudo nano /var/www/html/index.php
Add the following lines
<?php
phpinfo();
?>
sudo service nginx restart
php -v
Check the PHP version from here.
sudo nano /etc/nginx/sites-available/default
Change the PHP version.
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
sudo service nginx restart
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Change the bind address to 0.0.0.0
sudo systemctl restart mysql
Change host of the MySQL user.
sudo mysql
mysql> SELECT User, Host FROM mysql.user;
mysql> UPDATE mysql.user SET HOST='%' WHERE User='<user>';
mysql> SELECT User, Host FROM mysql.user;
# % is the wildcard to connect from everywhere.
mysql> exit
Top comments (2)
Great article, keep the good work! Liked and followed! 🚀
Thank you so much ✌️