NGINX

$ cat /proc/cpuinfo 
$ cat /etc/os-release
$ sudo nano /etc/hosts
$ sudo hostnamectl set-hostname new-one
$ newgrp
$ apt-get install nano wget curl perl sudo -y
$ sudo apt --purge autoremove -y
$ sudo apt update && sudo apt upgrade -y
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

$ sudo apt -y install nginx
http://ip_address

$ sudo apt install mariadb-server mariadb-client -y
$ mariadb-secure-installation

$ apt install -y php php-fpm php-mysql php-cli libmcrypt-dev libreadline-dev mcrypt php-common php-mysql php-xml
$ apt install -y php-xmlrpc php-curl php-gd php-imagick php-json php-mbstring php-opcache php-soap php-dev php-cgi
$ apt install -y php-zip php-intl php-bcmath php-pear
$ systemctl status php8.4-fpm
$ nano /etc/php/8.4/fpm/php.ini
  cgi.fix_pathinfo=0
$ nginx -t
$ systemctl restart nginx
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

$ sudo mkdir /var/www/your_domain
$ sudo chown -R $USER:$USER /var/www/your_domain
$ sudo nano /etc/nginx/sites-available/your_domain

server {
listen 80;
server_name your_domain;
root /var/www/your_domain;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
}
location ~ /.ht {
deny all;
}
}
$ sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
$ sudo unlink /etc/nginx/sites-enabled/default
$ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl reload nginx
$ nano /var/www/your_domain/index.php
$ http://domain
$ cd /var/www/your_domin
$ sudo wget http://storage.skydance.cc/uptime.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 )
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php* postfix

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.4-memcached
$ sudo service php8.4-fpm restart
$ sudo service nginx restart

==Install Let’s Encrypt on Your Domain=====
$ sudo apt install certbot python3-certbot-nginx
$ sudo certbot --nginx -d example.com
Proof: -> $ sudo nginx -T | grep ssl_   #This will display the SSL directives currently in use by Nginx.
$ sudo nano /etc/nginx/sites-available/your_domain   (it's already changed with SSL.)
server {
    listen 80;
    server_name example.com www.example.com;
    location
       ----
}
server {
    listen 443 ssl;
    server_name example.com www.example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    add this-> add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    root /var/www/example.com;
    index index.html;
    location -----
}
$ sudo nginx -t
$ sudo systemctl reload nginx
$ sudo systemctl status certbot.timer
$ sudo certbot renew --dry-run

==Delete Nginx=====

sudo systemctl stop nginx
sudo systemctl disable nginx
sudo apt purge nginx nginx-common nginx-core nginx-full
sudo apt autoremove -y
sudo rm -rf /etc/nginx /var/log/nginx /var/www/html
apt list --installed | grep nginx
ls -l /etc/nginx/


Posted : Saturday 29th of August 2015 @ 11:42 AM— Tags : LEMP