Last active
April 19, 2020 04:37
-
-
Save linuxdevhub/2914f0efde5fff4c12de058fdd45362a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# YouTube: https://youtu.be/8lMpo73L7Vs | |
# Step 0: update repository and software packages: | |
sudo apt update | |
sudo apt upgrade | |
############## Nginx ############## | |
# Install Nginx from the Ubuntu repository | |
sudo apt install nginx | |
# Allow port in firewall | |
sudo ufw allow 'Nginx HTTP' | |
# you can see allowed status using | |
sudo ufw status | |
# Nginx to auto start when Ubuntu is booted | |
sudo systemctl enable nginx | |
# start Nginx with this command: | |
sudo systemctl start nginx | |
# Now check out its status. | |
systemctl status nginx | |
############## MariaDB ############## | |
# Step 2: Install the mysql-server package: | |
sudo apt install mariadb-server mariadb-client | |
systemctl status mariadb | |
# If it’s not running, start it with this command: | |
sudo systemctl start mariadb | |
# To enable MariaDB to automatically start at boot time, run | |
sudo systemctl enable mariadb | |
# Now run the post installation security script. | |
sudo mysql_secure_installation | |
# Log in to mariadb to test | |
sudo mysql -u root | |
quit; | |
############## PHP ############## | |
# Step 3: Install PHP and additional support libraries | |
sudo apt install php-fpm php-mysql | |
# PHP Version Check | |
php --version | |
sudo nano /etc/nginx/sites-available/site1.com.conf | |
# add these lines in site1.com.conf file and save | |
server { | |
listen 80; | |
root /var/www/html/site1; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name site1.com; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
# create link file on site enabled directory | |
sudo ln -s /etc/nginx/sites-available/site1.com.conf /etc/nginx/sites-enabled/ | |
# Then, unlink the default configuration file from the /sites-enabled/ directory: | |
sudo unlink /etc/nginx/sites-enabled/default | |
# Test your new configuration file for syntax errors by typing: | |
sudo nginx -t | |
# reload Nginx to make the necessary changes: | |
sudo systemctl reload nginx | |
############# Create Demo Web Page #################### | |
sudo nano /var/www/html/index.php | |
# Enter the following lines into the new file. This is valid PHP code that will return information about your server: | |
<?php | |
phpinfo(); | |
# Visit page | |
firefox http://site1.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment