[go: up one dir, main page]

0% found this document useful (0 votes)
3 views3 pages

Aws Deployment

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

React APP deployment on EC2

EC2 instance
follow the instructions for creating a new instance with following parameters
AMI: ubuntu 20.04
EC2 instance type: t2.micro
tags: Name: test-machine
pem file: RSA
download the pem file and change the permissions

> sudo chmod 400 <filename>

apache2
install apache

> sudo apt-get update


> sudo apt-get install apache2

enable htaccess
add following code in /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

add following in /var/www/html/.htaccess

RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state


links
RewriteRule ^ index.html [L]

restart apache

> sudo a2enmod rewrite


> sudo systemctl reload apache2
> sudo systemctl restart apache2

mysql
install mysql

> sudo apt update


> sudo apt install -y mysql-server

change the root password

> sudo mysql


> ALTER USER 'root'@'localhost' IDENTIFIED WITH
mysql_native_password BY 'root';
> FLUSH PRIVILEGES;
> exit;

React app
execute the following steps on your machine
build the application

> yarn build

archive the build directory contents


upload the archived file to server

> scp -i <pem file location> build/Archived.zip ubuntu@<public


ip>:~/
execute the following steps on the server (ec2) machine

> cd /var/www/html
> sudo rm -f *
> sudo mv ~/Archived.zip .
> sudo apt-get install unzip
> sudo unzip Archived.zip

nodejs
> curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
> sudo apt-get update
> sudo apt install -y nodejs
> node --version

You might also like