2 minutes
Install nginx php7 mariaDb
Update Ubuntu
apt-get update
apt-get upgrade
sudo ufw allow ssh comment 'Open SSH port 22'
Install NginX
apt instal nginx
To start, stop and enable Nginx
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Open HTTP and HTTPS ports on firewall
sudo ufw allow http comment 'Open access Nginx port 80'
sudo ufw allow https comment 'Open all to access Nginx port 443'
Install MariaDB
sudo apt-get install mariadb-server mariadb-client
To start, stop and enable Nginx
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
To setup MariaDB
sudo mysql_secure_installation
Enter current password for root (enter for none): [Enter]
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
Log in to MySQL
sudo mysql -u root -p
Edit MySQL config
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Change the bind address to 0.0.0.0
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
sudo systemctl restart mariadb
Allow remote login (for dev only!)
Never give root access like this on a production server. To be honest it made me feel weird doing it on a local machine with not internet access. Create a user and grant that user specific access.
sudo mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.100.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
exit
Open MySQL port on firewall
sudo ufw allow mysql comment 'Open MySQL port 3306'
PHP
Install PHP and extentions
sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-sqlite3
Control the PHP Service
To start, stop and enable Nginx
sudo systemctl stop php7.4-fpm.service
sudo systemctl start php7.4-fpm.service
sudo systemctl enable php7.4-fpm.service
Nginx Default site config
Found in /etc/nginx/sites-availiable
Uncomment to enable PHP
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
Let’s Encrypt Client
sudo apt install python3-certbot-nginx
sudo certbot --nginx
sudo certbot --nginx -d example.com -d www.example.com
Auto renew
Untested
crontab -e
0 12 * * * /usr/bin/certbot renew --quiet
comments powered by Disqus