Skip to content

Instantly share code, notes, and snippets.

@webmechanicx
Last active May 6, 2020 15:42
Show Gist options
  • Select an option

  • Save webmechanicx/209115a85a1a084840456cfaba8447fa to your computer and use it in GitHub Desktop.

Select an option

Save webmechanicx/209115a85a1a084840456cfaba8447fa to your computer and use it in GitHub Desktop.

Revisions

  1. webmechanicx revised this gist May 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ First thing you have to connect to ssh using macos or putty for windows by added

    The above command ensure that all of your software packages are up to date.

    ## Step2: Now that your instance is current.
    ## Step2: Now install packages in your current instance.
    you can install the Apache web server, MySQL, and PHP software packages.

    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd```
  2. webmechanicx revised this gist May 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ you can install the Apache web server, MySQL, and PHP software packages.

    Test your web server. In a web browser, type the public DNS address. If there is no content in /var/www/html, you should see the Apache test page.

    Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.
    Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is **/var/www/html**, which by default is owned by root.

    ```ls -l /var/www```

  3. webmechanicx revised this gist May 6, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,8 @@ First thing you have to connect to ssh using macos or putty for windows by added

    The above command ensure that all of your software packages are up to date.

    ## Step2: Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.
    ## Step2: Now that your instance is current.
    you can install the Apache web server, MySQL, and PHP software packages.

    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd```

  4. webmechanicx revised this gist May 6, 2020. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,17 @@
    ### Install and start the LAMP web server

    ##Step1:
    ## Step1:
    First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:

    ```sudo yum update -y```

    The above command ensure that all of your software packages are up to date.

    ##Step2: Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.
    ## Step2: Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.

    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd```

    ##Step2: Start the Apache web server.
    ## Step3: Start the Apache web server.

    ```sudo service httpd start```

    @@ -21,7 +21,7 @@ Apache httpd serves files that are kept in a directory called the Apache documen

    ```ls -l /var/www```

    ## Step3: Setting file permissions
    ## Step4: Setting file permissions

    To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.

    @@ -67,7 +67,7 @@ Create a PHP file in the Apache document root.

    ```http://my.public.dns.amazonaws.com/phpinfo.php```

    ## Step4: Enabling .htaccess for url rewrite
    ## Step5: Enabling .htaccess for url rewrite

    ```
    sudo nano /etc/httpd/conf/httpd.conf
    @@ -78,7 +78,7 @@ Save the file ctrl + ^O and restart the apache:
    sudo service httpd restart
    ```

    ## Step5: Secure the Database Server
    ## Step6: Secure the Database Server

    ```
    sudo mysql_secure_installation
    @@ -92,7 +92,7 @@ When prompted, type a password for the root account and then set ```Y``` to all
    sudo chkconfig mysqld on
    ```

    ##Step 6: (Optional) Install phpMyAdmin
    ## Step 7: (Optional) Install phpMyAdmin

    1) Navigate to the Apache document root at
    **/var/www/html**
  5. webmechanicx revised this gist May 6, 2020. 1 changed file with 58 additions and 4 deletions.
    62 changes: 58 additions & 4 deletions aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,17 @@
    ### Install and start the LAMP web server

    **Step1:** First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:
    ##Step1:
    First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:

    ```sudo yum update -y```

    The above command ensure that all of your software packages are up to date.

    **Step2:** Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.
    ##Step2: Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.

    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd```

    **Step2:** Start the Apache web server.
    ##Step2: Start the Apache web server.

    ```sudo service httpd start```

    @@ -20,7 +21,7 @@ Apache httpd serves files that are kept in a directory called the Apache documen

    ```ls -l /var/www```

    ### Step3: Setting file permissions
    ## Step3: Setting file permissions

    To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.

    @@ -66,6 +67,59 @@ Create a PHP file in the Apache document root.

    ```http://my.public.dns.amazonaws.com/phpinfo.php```

    ## Step4: Enabling .htaccess for url rewrite

    ```
    sudo nano /etc/httpd/conf/httpd.conf
    ```

    Save the file ctrl + ^O and restart the apache:
    ```
    sudo service httpd restart
    ```

    ## Step5: Secure the Database Server

    ```
    sudo mysql_secure_installation
    ```

    When prompted, type a password for the root account and then set ```Y``` to all question being asked.

    (Optional) If you want the MySQL server to start at every boot, type the following command.

    ```
    sudo chkconfig mysqld on
    ```

    ##Step 6: (Optional) Install phpMyAdmin

    1) Navigate to the Apache document root at
    **/var/www/html**

    ```
    cd /var/www/html
    ```

    2) Create a phpMyAdmin folder and extract the package into it using the following command

    ```
    wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
    ```

    3) Delete the **phpMyAdmin-latest-all-languages.tar.gz** tarball.

    ```
    rm phpMyAdmin-latest-all-languages.tar.gz
    ```

    ```
    sudo service mysqld start
    ```

    phpmyadmin url should something like here:
    **http://my.public.dns.amazonaws.com/phpMyAdmin**

    ### Follow this link other configuration e.g. phpmyadmin

    [AWS LAMP PHPMYADMIN](https://medium.com/@oreillyalan88/lamp-linux-apache-mysql-php-web-server-on-an-amazon-ec2-linux-instance-e37eb023e996)
  6. webmechanicx revised this gist Jan 29, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -78,7 +78,7 @@ Create a PHP file in the Apache document root.
    ```
    # Install PHP 7.2
    # automatically includes php72-cli php72-common php72-json php72-process php72-xml
    sudo yum install php70
    sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
    # Install additional commonly used php packages
    sudo yum install php72-gd
    @@ -88,4 +88,6 @@ sudo yum install php72-mysqlnd
    sudo yum install php72-opcache
    sudo yum install php72-pdo
    sudo yum install php72-pecl-apcu
    sudo service httpd restart
    ```
  7. webmechanicx revised this gist Jan 29, 2020. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -72,4 +72,20 @@ Create a PHP file in the Apache document root.

    [AWS LAMP FROM Amazon Doc](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html)

    [AWS LAMP YOUTUBE](https://www.youtube.com/watch?v=XqDPcu-tmFA)
    [AWS LAMP YOUTUBE](https://www.youtube.com/watch?v=XqDPcu-tmFA)

    ### Command to install additional php72 extensions:
    ```
    # Install PHP 7.2
    # automatically includes php72-cli php72-common php72-json php72-process php72-xml
    sudo yum install php70
    # Install additional commonly used php packages
    sudo yum install php72-gd
    sudo yum install php72-imap
    sudo yum install php72-mbstring
    sudo yum install php72-mysqlnd
    sudo yum install php72-opcache
    sudo yum install php72-pdo
    sudo yum install php72-pecl-apcu
    ```
  8. webmechanicx revised this gist Jan 17, 2020. 1 changed file with 16 additions and 14 deletions.
    30 changes: 16 additions & 14 deletions aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -2,72 +2,74 @@

    **Step1:** First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:

    ```sudo yum update -y
    ```sudo yum update -y```

    The above command ensure that all of your software packages are up to date.

    **Step2:** Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.

    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd```

    **Step2:** Start the Apache web server.

    ```sudo service httpd start
    ```sudo service httpd start```

    Test your web server. In a web browser, type the public DNS address. If there is no content in /var/www/html, you should see the Apache test page.

    Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.

    ```ls -l /var/www
    ```ls -l /var/www```

    ### Step3: Setting file permissions

    To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.

    Add your user (in this case, ec2-user) to the apache group.

    ```sudo usermod -a -G apache ec2-user
    ```sudo usermod -a -G apache ec2-user```

    Log out and then log back in again to pick up the new group, and then verify your membership.

    Log out (use the exit command or close the terminal window):

    ```exit
    ```exit```

    To verify your membership in the apache group, reconnect to your instance, and then run the following command:

    ```groups
    ```groups```

    Change the group ownership of /var/www and its contents to the apache group.

    ```sudo chown -R ec2-user:apache /var/www
    ```sudo chown -R ec2-user:apache /var/www```

    To add group write permissions and to set the group ID on future subdirectories

    ```sudo chmod 2775 /var/www
    ```sudo chmod 2775 /var/www```

    Then:

    ```find /var/www -type d -exec sudo chmod 2775 {} \\;
    ```find /var/www -type d -exec sudo chmod 2775 {} \\;```

    To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:

    ```find /var/www -type f -exec sudo chmod 0664 {} \\;
    ```find /var/www -type f -exec sudo chmod 0664 {} \\;```

    **Now, the ec2-user user (and any future members of the apache group) can add, delete, and edit files in the Apache document root. Now you are ready to add content, such as a static website or a PHP application.**

    ### Test your LAMP server

    Create a PHP file in the Apache document root.

    ```echo "" > /var/www/html/phpinfo.php
    ```echo "" > /var/www/html/phpinfo.php```

    **If you get a “Permission denied” error when trying to run this command, try logging out and logging back in again to pick up the proper group permissions that you configured in Set File Permissions.**

    ```http://my.public.dns.amazonaws.com/phpinfo.php
    ```http://my.public.dns.amazonaws.com/phpinfo.php```

    ### Follow this link other configuration e.g. phpmyadmin

    [AWS LAMP PHPMYADMIN](https://medium.com/@oreillyalan88/lamp-linux-apache-mysql-php-web-server-on-an-amazon-ec2-linux-instance-e37eb023e996)

    [AWS LAMP FROM Amazon Doc]https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html)
    [AWS LAMP FROM Amazon Doc](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html)

    [AWS LAMP YOUTUBE](https://www.youtube.com/watch?v=XqDPcu-tmFA)
  9. webmechanicx revised this gist Jan 17, 2020. 1 changed file with 16 additions and 14 deletions.
    30 changes: 16 additions & 14 deletions aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -2,70 +2,72 @@

    **Step1:** First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:

    \`\`\`sudo yum update -y
    ```sudo yum update -y
    The above command ensure that all of your software packages are up to date.
    **Step2:** Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.
    \`\`\`sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
    ```sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
    **Step2:** Start the Apache web server.
    \`\`\`sudo service httpd start
    ```sudo service httpd start
    Test your web server. In a web browser, type the public DNS address. If there is no content in /var/www/html, you should see the Apache test page.
    Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.
    \`\`\`ls -l /var/www
    ```ls -l /var/www
    ### Step3: Setting file permissions
    To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.
    Add your user (in this case, ec2-user) to the apache group.
    \`\`\`sudo usermod -a -G apache ec2-user
    ```sudo usermod -a -G apache ec2-user
    Log out and then log back in again to pick up the new group, and then verify your membership.
    Log out (use the exit command or close the terminal window):
    \`\`\`exit
    ```exit
    To verify your membership in the apache group, reconnect to your instance, and then run the following command:
    \`\`\`groups
    ```groups
    Change the group ownership of /var/www and its contents to the apache group.
    \`\`\`sudo chown -R ec2-user:apache /var/www
    ```sudo chown -R ec2-user:apache /var/www
    To add group write permissions and to set the group ID on future subdirectories
    \`\`\`sudo chmod 2775 /var/www
    ```sudo chmod 2775 /var/www
    Then:
    \`\`\`find /var/www -type d -exec sudo chmod 2775 {} \\;
    ```find /var/www -type d -exec sudo chmod 2775 {} \\;
    To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:
    \`\`\`find /var/www -type f -exec sudo chmod 0664 {} \\;
    ```find /var/www -type f -exec sudo chmod 0664 {} \\;
    **Now, the ec2-user user (and any future members of the apache group) can add, delete, and edit files in the Apache document root. Now you are ready to add content, such as a static website or a PHP application.**
    ### Test your LAMP server
    Create a PHP file in the Apache document root.
    \`\`\`echo "" > /var/www/html/phpinfo.php
    ```echo "" > /var/www/html/phpinfo.php
    **If you get a “Permission denied” error when trying to run this command, try logging out and logging back in again to pick up the proper group permissions that you configured in Set File Permissions.**
    \`\`\`http://my.public.dns.amazonaws.com/phpinfo.php
    ```http://my.public.dns.amazonaws.com/phpinfo.php
    ### Follow this link other configuration e.g. phpmyadmin
    \[AWS LAMP PHPMYADMIN\](https://medium.com/@oreillyalan88/lamp-linux-apache-mysql-php-web-server-on-an-amazon-ec2-linux-instance-e37eb023e996)
    [AWS LAMP PHPMYADMIN](https://medium.com/@oreillyalan88/lamp-linux-apache-mysql-php-web-server-on-an-amazon-ec2-linux-instance-e37eb023e996)
    [AWS LAMP FROM Amazon Doc]https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html)
  10. webmechanicx created this gist Jan 17, 2020.
    71 changes: 71 additions & 0 deletions aws-linux-ami-2018030-hvm-ssd.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    ### Install and start the LAMP web server

    **Step1:** First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:

    \`\`\`sudo yum update -y

    The above command ensure that all of your software packages are up to date.

    **Step2:** Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages.

    \`\`\`sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd

    **Step2:** Start the Apache web server.

    \`\`\`sudo service httpd start

    Test your web server. In a web browser, type the public DNS address. If there is no content in /var/www/html, you should see the Apache test page.

    Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.

    \`\`\`ls -l /var/www

    ### Step3: Setting file permissions

    To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.

    Add your user (in this case, ec2-user) to the apache group.

    \`\`\`sudo usermod -a -G apache ec2-user

    Log out and then log back in again to pick up the new group, and then verify your membership.

    Log out (use the exit command or close the terminal window):

    \`\`\`exit

    To verify your membership in the apache group, reconnect to your instance, and then run the following command:

    \`\`\`groups

    Change the group ownership of /var/www and its contents to the apache group.

    \`\`\`sudo chown -R ec2-user:apache /var/www

    To add group write permissions and to set the group ID on future subdirectories

    \`\`\`sudo chmod 2775 /var/www

    Then:

    \`\`\`find /var/www -type d -exec sudo chmod 2775 {} \\;

    To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:

    \`\`\`find /var/www -type f -exec sudo chmod 0664 {} \\;

    **Now, the ec2-user user (and any future members of the apache group) can add, delete, and edit files in the Apache document root. Now you are ready to add content, such as a static website or a PHP application.**

    ### Test your LAMP server

    Create a PHP file in the Apache document root.

    \`\`\`echo "" > /var/www/html/phpinfo.php

    **If you get a “Permission denied” error when trying to run this command, try logging out and logging back in again to pick up the proper group permissions that you configured in Set File Permissions.**

    \`\`\`http://my.public.dns.amazonaws.com/phpinfo.php

    ### Follow this link other configuration e.g. phpmyadmin

    \[AWS LAMP PHPMYADMIN\](https://medium.com/@oreillyalan88/lamp-linux-apache-mysql-php-web-server-on-an-amazon-ec2-linux-instance-e37eb023e996)