Giter VIP home page Giter VIP logo

lamp-stack-implementation's Introduction

Lamp-Stack-Implementation

This is a project which implement the use of Web Stack (LAMP STACK) In AWS

What is a Technology stack?

A technology stack is a set of frameworks and tools used to develop a software product. This set of frameworks and tools are very specifically chosen to work together in creating a well-functioning software. They are acronymns for individual technologies used together for a specific technology product. some examples are…

LAMP (Linux, Apache, MySQL, PHP or Python, or Perl) LEMP (Linux, Nginx, MySQL, PHP or Python, or Perl) MERN (MongoDB, ExpressJS, ReactJS, NodeJS) MEAN (MongoDB, ExpressJS, AngularJS, NodeJS

Create a EC2 Instance

  • Select region (the cl and launch a new EC2 instance of t2.micro family with Ubuntu Server 20.04 LTS (HVM)

  • Create a pair Key as the EC2 is created

  • Move into the folder where the pair key is downloaded and run the following command to connect to the instance

            sudo chmod 0400 <private-key-name>.pem
        
            ssh -i <private-key-name>.pem ubuntu@<Public-IP-address>
    

Install APACHE and Update the Firewall

  • Firat is to update a list of packages in package manager, the following command is used

                   sudo apt update
    
  • Then we run apache2 package installation using the following command

                   sudo apt install apache2
    
  • To verify that apache2 is running as a Service in our OS, use following command

                  sudo systemctl status apache2
    
  • we can try to check how we can access it locally in our Ubuntu shell, using the following command

                   curl http://localhost:80
      
                                 or
                  
                    curl http://127.0.0.1:80
    
  • The image below will be display with the ip address

Screenshot 2022-04-17 at 09 28 47

Installing MYSQL

  • USe the the comman line to install the server

                   sudo apt install mysql-server
    
  • We can the server using the following command line

                   sudo mysql_secure_installation
    
  • You can sudo in the the server using the command

                          sudo mysql
    
  • This will be display which shows that it is successful

Screenshot 2022-04-17 at 09 52 35

  • We can exit the server using the following command

                                 exit
    

Installing PHP

  • We use the following command to install 3 packages at once

                          sudo apt install php libapache2-mod-php php-mysql
    
  • After the installation, we can run the check the php version with the following command

                                               php -v
    

Creating Virtual Host Using APACHE

  • Create the directory for projectlamp using ‘mkdir’ using the command

                                 sudo mkdir /var/www/projectlamp
    
  • Assign ownership of the directory with current system user using the command

                                sudo chown -R $USER:$USER /var/www/projectlamp
    
  • Create and open a new configuration file in Apache’s usinng the command line

                                sudo vi /etc/apache2/sites-available/projectlamp.conf
    
  • paste the command below in the vim file and save

                                      <VirtualHost *:80>
                                      ServerName projectlamp
                                      ServerAlias www.projectlamp 
                                      ServerAdmin webmaster@localhost
                                      DocumentRoot /var/www/projectlamp
                                      ErrorLog ${APACHE_LOG_DIR}/error.log
                                      CustomLog ${APACHE_LOG_DIR}/access.log combined
                                      </VirtualHost>
    
  • You can list us the command line below tp list what is in the file

                                 sudo ls /etc/apache2/sites-available
    
  • Enable new virtual host using the command

                                        sudo a2ensite projectlamp
    
  • You can disable Apache default website using the command

                                        sudo a2dissite 000-default
    
  • Check for syntax error in the configuration file with the command

                                        sudo apache2ctl configtest
    
  • Reload Apache for the changes to take effect

                                        sudo systemctl reload apache2
    
  • Create an index.html file in that location to test that the virtual host works as expected using the command

     sudo echo 'Hello LAMP from hostname' $(curl -s http://169.254.169.254/latest/meta-data/public-hostname) 'with public IP' $(curl -s                           http://169.254.169.254/latest/meta-data/public-ipv4) > /var/www/projectlamp/index.html
    
  • The website URL can be access using thr IP address

                                        http://<Public-IP-Address>:80
    

Enable PHP on the website

  • Edit the conf file with the command

                                 sudo vim /etc/apache2/mods-enabled/dir.conf
    
  • Paste in the command

                           <IfModule mod_dir.c>
                           #Change this:
                           #DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
                           #To this:
                           DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
                           </IfModule>
    
  • Reload Apache

                                 sudo systemctl reload apache2
    
  • Create index.php file

                                 vim /var/www/projectlamp/index.php
    
  • Add the following text, which is valid PHP code, inside the file:

                                             <?php
                                            phpinfo();
    
  • Save and close the file, refresh the page and you will see a page similar to this:

Screenshot 2022-04-18 at 23 55 58

  • Its best to remove the file create, you can do that using the following command

                                 sudo rm /var/www/projectlamp/index.php
    

lamp-stack-implementation's People

Contributors

newthingade avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.