From 1371cf1849c5b63097854a3b8d12608fcb142feb Mon Sep 17 00:00:00 2001 From: Kishan Takoordyal Date: Sat, 20 May 2023 14:14:47 +0000 Subject: [PATCH] Update Section_06/main.sh, Section_06/php.sh, Section_06/index.php, Section_06/default --- Section_06/default | 91 ++++++++++++++++++++++++++++++++++++++++++++ Section_06/index.php | 3 ++ Section_06/main.sh | 31 +++++++++++++++ Section_06/php.sh | 47 +++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 Section_06/default create mode 100644 Section_06/index.php create mode 100644 Section_06/main.sh create mode 100644 Section_06/php.sh diff --git a/Section_06/default b/Section_06/default new file mode 100644 index 0000000..b7b79f8 --- /dev/null +++ b/Section_06/default @@ -0,0 +1,91 @@ +## +# You should look at the following URL's in order to grasp a solid understanding +# of Nginx configuration files in order to fully unleash the power of Nginx. +# https://www.nginx.com/resources/wiki/start/ +# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ +# https://wiki.debian.org/Nginx/DirectoryStructure +# +# In most cases, administrators will remove this file from sites-enabled/ and +# leave it as reference inside of sites-available where it will continue to be +# updated by the nginx packaging team. +# +# This file will automatically load configuration files provided by other +# applications, such as Drupal or Wordpress. These applications will be made +# available underneath a path with that package name, such as /drupal8. +# +# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. +## + +# Default server configuration +# +server { + listen 80 default_server; + listen [::]:80 default_server; + + # SSL configuration + # + # listen 443 ssl default_server; + # listen [::]:443 ssl default_server; + # + # Note: You should disable gzip for SSL traffic. + # See: https://bugs.debian.org/773332 + # + # Read up on ssl_ciphers to ensure a secure configuration. + # See: https://bugs.debian.org/765782 + # + # Self signed certs generated by the ssl-cert package + # Don't use them in a production server! + # + # include snippets/snakeoil.conf; + + root /var/www/html; + + # Add index.php to the list if you are using PHP + index index.php index.nginx-debian.html; + + server_name _; + + location / { + # First attempt to serve request as file, then + # as directory, then fall back to displaying a 404. + try_files $uri $uri/ =404; + } + + # pass PHP scripts to FastCGI server + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + + # With php-fpm (or other unix sockets): + fastcgi_pass unix:/run/php/php8.1-fpm.sock; + # With php-cgi (or other tcp sockets): + # fastcgi_pass 127.0.0.1:9000; + } + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + location ~ /\.ht { + deny all; + } +} + + +# Virtual Host configuration for example.com +# +# You can move that to a different file under sites-available/ and symlink that +# to sites-enabled/ to enable it. +# +#server { +# listen 80; +# listen [::]:80; +# +# server_name example.com; +# +# root /var/www/example.com; +# index index.html; +# +# location / { +# try_files $uri $uri/ =404; +# } +#} diff --git a/Section_06/index.php b/Section_06/index.php new file mode 100644 index 0000000..cf60860 --- /dev/null +++ b/Section_06/index.php @@ -0,0 +1,3 @@ + diff --git a/Section_06/main.sh b/Section_06/main.sh new file mode 100644 index 0000000..d28d8ac --- /dev/null +++ b/Section_06/main.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Install Apache2 +sudo apt install apache2 +sudo systemctl enable apache2 --now +cd /etc/apache2/sites-available/ +cat 000-default.conf +ls ../sites-enabled/ +cat /var/www/html/index.html +# sudo apache2ctl -t +# sudo a2dissite 000-default +# sudo a2ensite 000-default +# sudo systemctl reload apache2 +# sudo systemctl stop apache2 +# sudo systemctl disable apache2 + +# Install Nginx +sudo apt install nginx +sudo systemctl enable nginx --now +cd /etc/nginx/sites-available/ +cat default +ls ../sites-enabled/ +ls /var/www/html/ +cat /var/www/html/index.nginx-debian.html +sudo nano default +sudo rm ../sites-enabled/default +sudo ln default ../sites-enabled/ +sudo systemctl reload nginx +# sudo nginx -t +# sudo systemctl stop nginx +# sudo systemctl disable nginx diff --git a/Section_06/php.sh b/Section_06/php.sh new file mode 100644 index 0000000..1f6cb22 --- /dev/null +++ b/Section_06/php.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +PHP_VER=8.1 + +# Install PHP modules for Apache2 +sudo su +wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +echo "deb https://packages.sury.org/php/ bookworm main" > /etc/apt/sources.list.d/php.list +apt update +apt install libapache2-mod-php${PHP_VER} +apt install php${PHP_VER} php${PHP_VER}-cli php${PHP_VER}-common php${PHP_VER}-curl php${PHP_VER}-mbstring php${PHP_VER}-mysql php${PHP_VER}-xml php${PHP_VER}-fileinfo php${PHP_VER}-xml php${PHP_VER}-mbstring php${PHP_VER}-pdo php${PHP_VER}-zip php${PHP_VER}-http php${PHP_VER}-cli +phpenmod ctype curl dom iconv mbstring posix simplexml xml zip fileinfo pdo_mysql +sudo systemctl enable apache2 --now +sudo systemctl restart apache2 + +# Testing +sudo rm -rf /var/www/html/* +sudo nano /var/www/html/index.php +sudo nano /etc/php/8.1/apache2/php.ini +sudo systemctl restart apache2 +# sudo systemctl stop apache2 +# sudo systemctl disable apache2 + +# Install Nginx +sudo su +wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +echo "deb https://packages.sury.org/php/ bookworm main" > /etc/apt/sources.list.d/php.list +apt update +apt install php${PHP_VER}-fpm +apt install php${PHP_VER}-curl php${PHP_VER}-mbstring php${PHP_VER}-mysql php${PHP_VER}-xml php${PHP_VER}-fileinfo php${PHP_VER}-xml php${PHP_VER}-mbstring php${PHP_VER}-pdo php${PHP_VER}-zip php${PHP_VER}-http php${PHP_VER}-cli +phpenmod ctype curl dom iconv mbstring posix simplexml xml zip fileinfo pdo_mysql +sudo systemctl enable nginx --now +sudo systemctl enable php${PHP_VER}-fpm --now +sudo systemctl restart php${PHP_VER}-fpm +cd /etc/nginx/sites-available/ +sudo nano default +sudo rm ../sites-enabled/default +sudo ln default ../sites-enabled/ +sudo systemctl reload nginx + +# Testing +sudo rm -rf /var/www/html/* +sudo nano /var/www/html/index.php +sudo nano /etc/php/8.1/fpm/php.ini +sudo systemctl restart php${PHP_VER}-fpm +# sudo systemctl stop nginx +# sudo systemctl disable nginx