AWS instance setup

AWS instance setup on terminal


1. setup one time with downloaded .pem file

sudo chmod -R 400 Downloads/Skwad.pem


2. login server with terminal

Ubuntu

ssh -i Downloads/Skwad.pem ubuntu@intance_server_ip

ssh -i Downloads/Skwad.pem ubuntu@18.223.55.35

Windows

ssh -i "C:\path\to\your\pemfile.pem" ec2-user@intance_server_ip


If facing a problem: WARNING: UNPROTECTED PRIVATE KEY FILE! Permissions 0775 for '/home/techwinlabs/Downloads/service_app.pem' are too open. It is required that your private key files are NOT accessible by others. Change the file access: chmod -R 400 service_app.pem (Read Only)



3. After setup the server:


1. install apache on the server

sudo apt update

sudo apt install apache2


2. install php   https://www.digitalocean.com/community/tutorials/how-to-install-php-8-1-and-set-up-a-local-development-environment-on-ubuntu-22-04


3. install mysql server

sudo apt-get install mysql-server


4. install phpmyadmin

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-20-04


5. Install composer if require on server

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04




Start apache2 and phpmyadmin:

1. sudo systemctl enable apache2

2. sudo systemctl start apache2

for restart the apache:

1. sudo systemctl restart apache2


systemctl = system control


Create new file & remove file from the server:

  • Path of the server file: /var/www/html/

  • Add new: sudo nano file_name

  • Remove file: sudo rm -R filename

  • save file: Ctrl+X <then> Y <then> Enter




Login mysql in terminal (if any password):

mysql --user=root --password
password:


if Not opening phpmyadmin page after installation of phpmyadmin:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2


For adding additional verification on phpmyadmin login page:



#1 create .htacess file
sudo nano /usr/share/phpmyadmin/.htaccess

#2 Within this file, enter the following information

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

then save and close the file

Here is what each of these lines mean:
AuthType Basic: This line specifies the authentication type that you are implementing. This type will implement password authentication using a password file.
AuthName: This sets the message for the authentication dialog box. You should keep this generic so that unauthorized users won’t gain any information about what is being protected.
AuthUserFile: This sets the location of the password file that will be used for authentication. This should be outside of the directories that are being served. We will create this file shortly.
Require valid-user: This specifies that only authenticated users should be given access to this resource. This is what actually stops unauthorized users from entering.

#3 Set username and password for authentication
The location that you selected for your password file was /etc/phpmyadmin/.htpasswd. You can now create this file and pass it an initial user with the htpasswd utility:

sudo htpasswd -c /etc/phpmyadmin/.htpasswd enter_username
<then>set password
<then>conform password

#4 Restart the apache
sudo systemctl restart apache2



Install Filezilla if not available in pc:

1. sudo apt update

2. sudo add-apt-repository ppa:xtradeb/apps

3. sudo apt-get update

4. sudo apt-get update

5. sudo apt install -y filezilla

6. filezilla --version




Set config file to open  the project folder:

Path of config files:  /etc/apache2/sites-enabled/

Check all config file by : ls

  1. Open the 000-default.conf and set the correct path:

  sudo nano 000-default.conf


  1. Open the techvblogs.conf and set the correct path: (if only homepage opening)

sudo nano yoursitename.conf and write only:


<Directory "/var/www/html/your-project-folder/">
    AllowOverride All
</Directory>



Post a Comment

0 Comments

Visual Studio