Prerequisite to Website

$ sudo dpkg --configure -a
$ sudo nano /etc/hosts
$ sudo hostnamectl set-hostname new-one
$ newgrp
1 ========== Prerequisite===========================
$ apt-get update --allow-releaseinfo-change
$ apt-get install --reinstall ca-certificates
$ apt-get upgrade -y
$ apt-get install nano wget curl perl sudo -y

$ sudo apt dist-upgrade
$ sudo apt --purge autoremove
$ sudo apt update && sudo apt upgrade
$ apt -y purge Apache2* bind* exim* ufw* firewalld* libapache2-mod-php*

2 ==========Install PHP==================
$ sudo apt -y install php software-properties-common libmcrypt-dev libreadline-dev mcrypt
$ sudo apt -y install php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli 
$ sudo apt -y install php-fpm php-json php-imap php-mbstring php-opcache php-soap php-dev php-cgi 
$ sudo apt -y install php-zip php-intl php-bcmath php-pear

3 ================MySql==========================================
$ apt install -y mariadb-server mariadb-client
$ systemctl status mariadb
$ mysql_secure_installation
$ mysql -u root -p
--Enter password:
Maria DB [(none)]>
> CREATE DATABASE rome;
> CREATE USER 'user_name'@localhost IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON *.* TO 'db_name'@localhost IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
> SHOW GRANTS FOR 'db_name'@localhost;
> SHOW DATABASES;
> Exit;

4 ==WEBMIN==============

$ sudo apt -y install curl
$ curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
$ sh setup-repos.sh
$ apt -y install webmin --install-recommends
( change port: $ sudo nano -w /etc/webmin/miniserv.conf )

add adminer.php

$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

For L.A.M.P
================Install Apache==========================================
$ sudo apt -y install apache2 apache2-utils
$ apache2 -v
$ systemctl status apache2
$ systemctl reload apache2

For L.L.M.P
=============Install Lighttpd=======================
$ apt-get install lighttpd -y
$ systemctl start lighttpd
$ systemctl enable lighttpd
$ systemctl status lighttpd
go to http://your-server-ip

For CADDY

==============Install Caddy=========================
$ sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | 
sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | 
sudo tee /etc/apt/sources.list.d/caddy-stable.list
$ chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ chmod o+r /etc/apt/sources.list.d/caddy-stable.list
$ sudo apt update
$ sudo apt install caddy

$ sudo systemctl enable --now caddy
$ sudo systemctl status caddy
Open http://i.p in your browser 

==============Install NGINX=========================
$ sudo apt-get install nginx -y
$ systemctl start nginx
$ systemctl enable nginx
$ systemctl status nginx
  http://i.p address
$ chown www-data:www-data /var/www/html -R

$ systemctl start php8.2-fpm
$ systemctl enable php8.2-fpm
$ systemctl status php8.2-fpm

sudo nano /etc/nginx/sites-enabled/default
--------------------------------------------
server {
        listen 80 default_server;
        listen [::]:80 default_server;
    server_name _;
    root /var/www/html;
    index index.php index.html index.htm;
    location / {
    try_files $uri $uri/ /index.php?$args;
               }
     location ~ \.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
                       }
     }
$ sudo nginx -t
$ sudo systemctl reload nginx
http://server_IP/

$ sudo mkdir -p /var/www/html/website
$ sudo nano /var/www/html/website/index.php
$ sudo nano /etc/nginx/sites-available/website
server {
    listen 80;
    server_name website.com;
    root /var/www/html/website1;
    index index.php index.html index.htm;
     location / {
     try_files $uri $uri/ /index.php?$args;
               }
     location ~ \.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
                  }
    access_log /var/log/nginx/website1-access.log;
    error_log /var/log/nginx/website1-error.log;
}

$ sudo ln -s /etc/nginx/sites-available/website /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl restart nginx


Posted : Friday 19th of September 2025 @ 12:51 AM— Tags : Prerequisite-website