AWS Setup
- Launch an instance
- Select AMI (server)
- create Key Pair
- Allow SSH, HTTPS, HTTP
- Click on Launch instance
- Open an SSH client.
- give chmod 400 permission to pem file.
- copy Example in SSH
SSH
sudo su
sudo apt update
sudo apt install nginx
nginx -v
sudo systemctl status nginx
----FIREWALL---
sudo ufw status
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw reload
sudo ufw status
---PHP installation---
sudo apt update
sudo apt install php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl -y
php -v
cd /var/www/html
nano index.php
<?php
phpinfo();
?>
rm index.nginx-debian.html
sudo chmod 755 /var/www/html
sudo chown -R www-data:www-data /var/www/html
sudo chown www-data:www-data /var/www/html/index.php
sudo chmod 644 /var/www/html/index.php
sudo systemctl restart nginx
sudo systemctl restart php8.1-fpm
Nginx.conf
# nano /etc/nginx/nginx.conf
#code start add before html close bracket
# server 1 start
server {
listen 80;
server_name 1.101.101.202; # or use your EC2 IP
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:/run/php/php8.3-fpm.sock; # adjust PHP version if needed
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
# server 1 end
sudo nginx -t
sudo systemctl reload nginx
Check IP
http://__your____IP
WordPress Installation