Nginx Web Server - LEMP
Ubuntu 16.04 (DigitalOcean VPS)
::NGINX install::
sudo apt-get update
sudo apt-get install nginx
sudo apt-get install nginx
ufw app list
ufw allow 22
ufw allow "nginx http"
ufw enable
ufw status
::How to find Public IP address::
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
curl -4 icanhazip.com
Now go to visit http://<server-ip/dns>
If you see Welcome to NGINX! -- nginx working ok
::MySQL Server setup::
sudo apt-get install mysql-server
sudo mysql_secure_installation
..on all Q answer yes.. only root pass N!
::PHP install::
sudo apt-get install php-fpm php-mysql
sudo nano /etc/php/7.0/fpm/php.ini
ctrl+w --> search for cgi.fix_pathinfo
uncomment and change to 0 (zero) -- Security Reasons
sudo service php7.0-fpm restart
sudo nano /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
-- Check syntax errors
sudo nginx -t
sudo systemctl reload nginx
sudo service nginx reload
touch /var/www/html/info.php
echo "<?php" >> /var/www/html/test.php
echo "phpinfo();" > /var/www/html/test.php
(sudo nano /var/www/html/info.php)
If you see PHP info page -- > DONE!
Almost ... just remove test.php file if you don't want to be hacked soon...
sudo rm /var/www/html/info.php
No comments:
Post a Comment
Thank you for your comment. Will try to react as soon as possible.
Regards,
Networ King