NGINX
Before anything begins; first thing first;
$ apt-get update --allow-releaseinfo-change -y
$ apt-get install --reinstall ca-certificates -y
$ apt-get upgrade -y
$ apt-get install nano wget curl perl sudo -y
$ sudo apt -y dist-upgrade
$ sudo apt --purge autoremove -y
$ sudo apt update && sudo apt upgrade -y
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*
================MySql==========================================
$ apt install -y mariadb-server mariadb-client
$ systemctl status mariadb
$ mariadb_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;
==========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
apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*
========Install Webmin===============
$ 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 )
$ adduser nginx
$ adduser nginx sudo
$ su - nginx
$ exit
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php* postfix
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
Step 4. Configure Nginx to use PHP Processor
$ 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/
=============Create Website=======================================
Use full domain name or whatever word!
$ sudo mkdir -p /var/www/html/website
$ sudo nano /var/www/html/website1/index.php
$ sudo nano /etc/nginx/sites-available/website
server {
listen 80;
server_name Website.com;
root /var/www/html/Website;
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/Website-access.log;
error_log /var/log/nginx/Website-error.log;
}
Make other website by copying first one.
$ sudo cp /etc/nginx/sites-available/website1 /etc/nginx/sites-available/website2
$ sudo nano /etc/nginx/sites-available/website2
paste same as above website1.com.
!!!!==Important=========
$ sudo ln -s /etc/nginx/sites-available/website1.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl restart nginx
Automatic restart of Nginx
$ systemctl restart nginx
$ mkdir -p /etc/systemd/system/nginx.service.d/
$ nano /etc/systemd/system/nginx.service.d/restart.conf
Add the following lines to the file
[Service]
Restart=always
RestartSec=5s
$ systemctl daemon-reload
$ pkill nginx
$ systemctl status nginx
Install Memcached
Memcached allows server side caching for faster data retrieval.
$ sudo apt -y install memcached
$ sudo apt -y install php8.2-memcached
$ sudo service php8.2-fpm restart
$ sudo service nginx restart
Install Let’s Encrypt on Your Domain
$ add-apt-repository ppa:certbot/certbot
$ apt-get update -y $ apt-get install python-certbot-nginx -y
$ certbot --nginx -d example.com Set Up Let’s Encrypt SSL Certificate Auto-Renewal
$ crontab -e Add the following line:
12 8 * * * root /usr/bin/certbot renew >/dev/null 2>&1 Renew the SSL certificate manually:
$ certbot renew --dry-runPosted :
Saturday 29th of August 2015 @ 11:42 AM— Tags :
LEMP