$ ssh your_user@your_server_ip
ssh your_user@your_server_ip
ssh your_user@your_server_ip
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade -y
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">update -y
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">update -y
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">update -y
-weight: 600;">sudo ufw allow OpenSSH # Or -weight: 600;">sudo ufw allow 22 (if not changed)
-weight: 600;">sudo ufw allow http # For HTTP traffic (port 80)
-weight: 600;">sudo ufw allow https # For HTTPS traffic (port 443)
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 600;">sudo ufw allow OpenSSH # Or -weight: 600;">sudo ufw allow 22 (if not changed)
-weight: 600;">sudo ufw allow http # For HTTP traffic (port 80)
-weight: 600;">sudo ufw allow https # For HTTPS traffic (port 443)
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 600;">sudo ufw allow OpenSSH # Or -weight: 600;">sudo ufw allow 22 (if not changed)
-weight: 600;">sudo ufw allow http # For HTTP traffic (port 80)
-weight: 600;">sudo ufw allow https # For HTTPS traffic (port 443)
-weight: 600;">sudo ufw -weight: 500;">enable
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install php-fpm php-mysql php-cli php-mbstring php-xml php--weight: 500;">curl -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install php-fpm php-mysql php-cli php-mbstring php-xml php--weight: 500;">curl -y
server { listen 80; server_name your_domain.com www.your_domain.com; # Replace with your domain root /var/www/html; # Or your application's root directory index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php-fpm.sock; # Check your PHP version for the correct socket path } # Deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; }
}
server { listen 80; server_name your_domain.com www.your_domain.com; # Replace with your domain root /var/www/html; # Or your application's root directory index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php-fpm.sock; # Check your PHP version for the correct socket path } # Deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; }
}
-weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mariadb-server -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mariadb
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mariadb
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mariadb-server -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mariadb
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mariadb
-weight: 600;">sudo mysql_secure_installation
-weight: 600;">sudo mysql_secure_installation - Disable Root Login: Never allow direct SSH login as the root user. Create a new user with administrative privileges.
- Use SSH Keys: As mentioned, SSH keys are significantly more secure than passwords. Generate a key pair on your local machine (ssh-keygen) and copy the public key to your server's ~/.ssh/authorized_keys file.
- Change Default SSH Port: While not a foolproof security measure, changing the default SSH port (22) can deter automated bots scanning for open ports. Edit the SSH configuration file (/etc/ssh/sshd_config) and -weight: 500;">restart the SSH -weight: 500;">service. - Install Nginx: -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx After installation, Nginx should be running. You can verify this by visiting your server's IP address in a web browser. You should see the Nginx welcome page.
- Install PHP: You'll likely need PHP to process dynamic content. Install PHP and common extensions. -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install php-fpm php-mysql php-cli php-mbstring php-xml php--weight: 500;">curl -y php-fpm (FastCGI Process Manager) is essential for Nginx to communicate with PHP.
- Configure Nginx for PHP: You need to tell Nginx how to handle PHP files. Edit your Nginx site configuration file (e.g., /etc/nginx/sites-available/default or create a new one). server { listen 80; server_name your_domain.com www.your_domain.com; # Replace with your domain root /var/www/html; # Or your application's root directory index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php-fpm.sock; # Check your PHP version for the correct socket path } # Deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; }
} After editing, test your Nginx configuration and reload: -weight: 600;">sudo nginx -t
-weight: 600;">sudo -weight: 500;">systemctl reload nginx
- Install a Database (MySQL/MariaDB) For many applications, a database is required. MariaDB is a popular drop-in replacement for MySQL. -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mariadb-server -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mariadb
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mariadb Secure your MariaDB installation: -weight: 600;">sudo mysql_secure_installation This script will guide you through setting a root password, removing anonymous users, disallowing remote root login, and removing the test database. - /var/log/nginx/access.log and /var/log/nginx/error.log for Nginx.
- /var/log/syslog or /var/log/messages for general system messages.
- Database logs (location varies by database). - Database Backups: Regularly dump your databases to a separate location.
- File System Backups: Back up your application files and configurations.