Skip to content

Instantly share code, notes, and snippets.

@dragonjet
Last active July 31, 2021 21:01
Show Gist options
  • Save dragonjet/270cf0139df45d1b7690 to your computer and use it in GitHub Desktop.
Save dragonjet/270cf0139df45d1b7690 to your computer and use it in GitHub Desktop.

Revisions

  1. dragonjet revised this gist Feb 18, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2b-nginx.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Step 2 (A): NGINX Web Server + PHP5.5
    ## Step 2 (B): NGINX Web Server + PHP5.5
    For this step, you may choose either (A) Apache or (B) Nginx.

    ### Installation
  2. dragonjet revised this gist Feb 18, 2015. 2 changed files with 60 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions 2a-apache.md
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@ For this step, you may choose either (A) Apache or (B) Nginx.

    ### Installation
    * `yum update -y` Update linux packages
    * `yum -y install httpd24` Install webserver
    * `yum -y install httpd24` Install APACHE webserver
    * `chkconfig httpd on` Setup service
    * `yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.
    * `yum -y install php55 php55-bcmath php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.

    ### Configuration
    * **Apache Configuration**
    60 changes: 58 additions & 2 deletions 2b-nginx.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,58 @@
    ## Step 2 (A): NGINX Web Server + PHP5.6
    For this step, you may choose either (A) Apache or (B) Nginx.
    ## Step 2 (A): NGINX Web Server + PHP5.5
    For this step, you may choose either (A) Apache or (B) Nginx.

    ### Installation
    * `yum update -y` Update linux packages
    * `yum install -y nginx` Install NGINX webserver
    * `chkconfig httpd on` Setup service
    * `yum -y install php55 php55-fpm php55-bcmath php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions, including FPM.

    ### Configuration
    * **Nginx Configuration**
    `vi /etc/nginx/nginx.conf`
    ```
    root /var/www/html;
    location / {
    root /var/www/html;
    index index.php index.html index.htm;
    }
    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
    include fastcgi_params;
    }
    ```

    * **PHP-FPM Configuration**
    `vi /etc/php-fpm.d/www.conf`
    ```
    listen = /var/run/php-fpm/php-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0664
    user = nginx
    group = nginx
    ```

    * **PHP Configuration**
    `vi /etc/php.ini`
    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    ```

    ### Finalization
    ```
    usermod -a -G devgroup nginx
    chown -R root:devgroup /var/www/html
    chmod -R 775 /var/www/html
    chkconfig nginx on
    service nginx start
    chkconfig php-fpm on
    service php-fpm start
    ```
  3. dragonjet revised this gist Feb 18, 2015. 6 changed files with 102 additions and 99 deletions.
    25 changes: 25 additions & 0 deletions 1-server.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    ## Step 1: Server Credentials

    This assumes you are now connected to the server via SSH.
    * `sudo -s` Enter root mode for admin access
    * `groupadd devgroup` Create new group to be later granted access to */var/www/html*

    #### Creating a new Root User
    * `useradd -G root,devgroup masterdev` Create new root user. Also add to the *devgroup*
    * `passwd masterdev` Change password for the new root user
    * At this point, you'll need to input your new root user's new password

    #### Further User Configuration
    Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwords **cannot** be used on SSH (**Off**), so you initially need to use the pem or ppk files. However, since we now have created our new root user, we can change this and set it to "**On**".
    * `vi /etc/ssh/sshd_config` Edit SSH config file
    * Make sure this is set: `PasswordAuthentication yes`
    * `service sshd restart`

    #### Add as sudoer
    * `vi /etc/sudoers` Edit the sudoers file
    * Add **masterdev** user after the **root**'s line
    ```
    root ALL=(ALL) ALL
    masterdev ALL=NOPASSWD: ALL
    ```
    * Since the sudoer file is read-only, you may need to save your changes using `:wq!`.
    35 changes: 35 additions & 0 deletions 2a-apache.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    ## Step 2 (A): APACHE Web Server + PHP5.5
    For this step, you may choose either (A) Apache or (B) Nginx.

    ### Installation
    * `yum update -y` Update linux packages
    * `yum -y install httpd24` Install webserver
    * `chkconfig httpd on` Setup service
    * `yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.

    ### Configuration
    * **Apache Configuration**
    `vi /etc/httpd/conf/httpd.conf`
    ```
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    ```

    * **PHP Configuration**
    `vi /etc/php.ini`
    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    ```

    ### Finalization
    * `usermod -a -G devgroup apache` Add apache to dev group
    * Give the *devgroup* access to */var/www/html*
    ```
    chown -R root:devgroup /var/www/html
    chmod -R 775 /var/www/html
    ```
    * `service httpd start`
    2 changes: 2 additions & 0 deletions 2b-nginx.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    ## Step 2 (A): NGINX Web Server + PHP5.6
    For this step, you may choose either (A) Apache or (B) Nginx.
    29 changes: 29 additions & 0 deletions 3-mysql.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    ## Step 3: MySQL 5.6
    * If you will be using **Amazon RDS** or any separate database server, skip the whole MySQL Section. This is only required when you want to use a "localhost" MySQL on your server.

    ### Installation
    * `wget -O mysql.rpm http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/`
    * `yum -y localinstall mysql.rpm`
    * `yum -y install mysql-community-server`
    * `service mysqld start`
    * `chkconfig mysqld on`
    * `mysql_secure_installation`
    * MySQL will ask for root password. By default, its blank. Press enter.
    * MySQL will ask to set root password, answer `Y`.
    * Input the new root password
    * MySQL will ask to remove anonymous users, answer `Y`.
    * MySQL will ask to disallow root login remotely, answer `Y`.
    * MySQL will ask to remove test database, answer `Y`.
    * MySQL will ask to reload privileges, answer `Y`.
    * `mysql -u root -p` Test Root Login to **MySQL Console**
    * At this point you will need to enter your password
    * If the console prefix changed to `mysql>`, it was successful
    * Type `exit` to go back to **Linux command line**

    ### Setup phpMyAdmin
    * `cd /var/www/html`
    * `wget -O pma.zip http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.3/phpMyAdmin-4.3.3-english.zip`
    * `unzip pma.zip`
    * `mv phpMyAdmin-4.3.3-english dba`
    * `sudo rm pma.zip`
    * **phpMyAdmin** now accessible on `http://your_server/dba`
    11 changes: 11 additions & 0 deletions 4-optionals.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ## Optional: Setup FTP

    #### Creating a Dev User
    * `useradd -d /var/www/html -G devgroup -M dev` Add dev user, with home pointing to web directory, and add to the *devgroup*.
    * `passwd dev` Change password for the dev user
    * At this point, you'll need to input the dev user's new password

    #### Connecting
    * Use the username and password of the Dev User you just created
    * **Use SFTP connection**. FTP only will not work.

    99 changes: 0 additions & 99 deletions nginx-php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -1,99 +0,0 @@
    ## Environment
    This assumes you are now connected to the server via SSH.
    * `sudo -s` Enter root mode for admin access
    * `groupadd devgroup` Create new group to be later granted access to */var/www/html*

    #### Creating a new Root User
    * `useradd -G root,devgroup masterdev` Create new root user. Also add to the *devgroup*
    * `passwd masterdev` Change password for the new root user
    * At this point, you'll need to input your new root user's new password

    #### Further User Configuration
    Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwords **cannot** be used on SSH (**Off**), so you initially need to use the pem or ppk files. However, since we now have created our new root user, we can change this and set it to "**On**".
    * `vi /etc/ssh/sshd_config` Edit SSH config file
    * Make sure this is set: `PasswordAuthentication yes`
    * `service sshd restart`

    #### Add as sudoer
    * `vi /etc/sudoers` Edit the sudoers file
    * Add **masterdev** user after the **root**'s line
    ```
    root ALL=(ALL) ALL
    masterdev ALL=NOPASSWD: ALL
    ```
    * Since the sudoer file is read-only, you may need to save your changes using `:wq!`.

    ## Setup WebServer (PHP)

    ### Installation
    * `yum update -y` Update linux packages
    * `yum -y install httpd24` Install webserver
    * `chkconfig httpd on` Setup service
    * `yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.

    ### Configuration
    * **Apache Configuration**
    `vi /etc/httpd/conf/httpd.conf`
    ```
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    ```

    * **PHP Configuration**
    `vi /etc/php.ini`
    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    ```

    #### Finalization
    * `usermod -a -G devgroup apache` Add apache to dev group
    * Give the *devgroup* access to */var/www/html*
    ```
    chown -R root:devgroup /var/www/html
    chmod -R 775 /var/www/html
    ```
    * `service httpd start`

    ## Setup MySQL 5.6
    * If you will be using **Amazon RDS** or any separate database server, skip the whole MySQL Section. This is only required when you want to use a "localhost" MySQL on your server.

    ### Installation
    * `wget -O mysql.rpm http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/`
    * `yum -y localinstall mysql.rpm`
    * `yum -y install mysql-community-server`
    * `service mysqld start`
    * `chkconfig mysqld on`
    * `mysql_secure_installation`
    * MySQL will ask for root password. By default, its blank. Press enter.
    * MySQL will ask to set root password, answer `Y`.
    * Input the new root password
    * MySQL will ask to remove anonymous users, answer `Y`.
    * MySQL will ask to disallow root login remotely, answer `Y`.
    * MySQL will ask to remove test database, answer `Y`.
    * MySQL will ask to reload privileges, answer `Y`.
    * `mysql -u root -p` Test Root Login to **MySQL Console**
    * At this point you will need to enter your password
    * If the console prefix changed to `mysql>`, it was successful
    * Type `exit` to go back to **Linux command line**

    ### Setup phpMyAdmin
    * `cd /var/www/html`
    * `wget -O pma.zip http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.3/phpMyAdmin-4.3.3-english.zip`
    * `unzip pma.zip`
    * `mv phpMyAdmin-4.3.3-english dba`
    * `sudo rm pma.zip`
    * **phpMyAdmin** now accessible on `http://your_server/dba`

    ## Setup FTP
    #### Creating a Dev User
    * `useradd -d /var/www/html -G devgroup -M dev` Add dev user, with home pointing to web directory, and add to the *devgroup*.
    * `passwd dev` Change password for the dev user
    * At this point, you'll need to input the dev user's new password

    #### Connecting
    * Use the username and password of the Dev User you just created
    * **Use SFTP connection**. FTP only will not work.
  4. dragonjet revised this gist Feb 18, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx-php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -80,7 +80,7 @@ chmod -R 775 /var/www/html
    * If the console prefix changed to `mysql>`, it was successful
    * Type `exit` to go back to **Linux command line**

    ## Setup phpMyAdmin
    ### Setup phpMyAdmin
    * `cd /var/www/html`
    * `wget -O pma.zip http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.3/phpMyAdmin-4.3.3-english.zip`
    * `unzip pma.zip`
  5. dragonjet renamed this gist Feb 18, 2015. 1 changed file with 0 additions and 0 deletions.
  6. dragonjet revised this gist Dec 22, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -93,6 +93,7 @@ chmod -R 775 /var/www/html
    * `useradd -d /var/www/html -G devgroup -M dev` Add dev user, with home pointing to web directory, and add to the *devgroup*.
    * `passwd dev` Change password for the dev user
    * At this point, you'll need to input the dev user's new password

    #### Connecting
    * Use the username and password of the Dev User you just created
    * **Use SFTP connection**. FTP only will not work.
  7. dragonjet revised this gist Dec 22, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -92,4 +92,7 @@ chmod -R 775 /var/www/html
    #### Creating a Dev User
    * `useradd -d /var/www/html -G devgroup -M dev` Add dev user, with home pointing to web directory, and add to the *devgroup*.
    * `passwd dev` Change password for the dev user
    * At this point, you'll need to input the dev user's new password
    * At this point, you'll need to input the dev user's new password
    #### Connecting
    * Use the username and password of the Dev User you just created
    * **Use SFTP connection**. FTP only will not work.
  8. dragonjet revised this gist Dec 22, 2014. 1 changed file with 20 additions and 1 deletion.
    21 changes: 20 additions & 1 deletion php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,11 @@ date.timezone = "UTC"

    #### Finalization
    * `usermod -a -G devgroup apache` Add apache to dev group
    * Give the *devgroup* access to */var/www/html*
    ```
    chown -R root:devgroup /var/www/html
    chmod -R 775 /var/www/html
    ```
    * `service httpd start`

    ## Setup MySQL 5.6
    @@ -73,4 +78,18 @@ date.timezone = "UTC"
    * `mysql -u root -p` Test Root Login to **MySQL Console**
    * At this point you will need to enter your password
    * If the console prefix changed to `mysql>`, it was successful
    * Type `exit` to go back to **Linux command line**
    * Type `exit` to go back to **Linux command line**

    ## Setup phpMyAdmin
    * `cd /var/www/html`
    * `wget -O pma.zip http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.3/phpMyAdmin-4.3.3-english.zip`
    * `unzip pma.zip`
    * `mv phpMyAdmin-4.3.3-english dba`
    * `sudo rm pma.zip`
    * **phpMyAdmin** now accessible on `http://your_server/dba`

    ## Setup FTP
    #### Creating a Dev User
    * `useradd -d /var/www/html -G devgroup -M dev` Add dev user, with home pointing to web directory, and add to the *devgroup*.
    * `passwd dev` Change password for the dev user
    * At this point, you'll need to input the dev user's new password
  9. dragonjet revised this gist Dec 22, 2014. 1 changed file with 26 additions and 34 deletions.
    60 changes: 26 additions & 34 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -10,12 +10,12 @@ This assumes you are now connected to the server via SSH.

    #### Further User Configuration
    Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwords **cannot** be used on SSH (**Off**), so you initially need to use the pem or ppk files. However, since we now have created our new root user, we can change this and set it to "**On**".
    * `sudo vi /etc/ssh/sshd_config` Edit SSH config file
    * `vi /etc/ssh/sshd_config` Edit SSH config file
    * Make sure this is set: `PasswordAuthentication yes`
    * `sudo service sshd restart`
    * `service sshd restart`

    #### Add as sudoer
    * `sudo vi /etc/sudoers` Edit the sudoers file
    * `vi /etc/sudoers` Edit the sudoers file
    * Add **masterdev** user after the **root**'s line
    ```
    root ALL=(ALL) ALL
    @@ -26,16 +26,14 @@ masterdev ALL=NOPASSWD: ALL
    ## Setup WebServer (PHP)

    ### Installation
    * `sudo yum update -y` Update linux packages
    * `sudo yum -y install httpd24` Install webserver
    * `sudo chkconfig httpd on` Setup service
    * `sudo service httpd start` Start the webserver
    * `sudo yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.
    * `sudo service httpd restart` Restart the webserver
    * `yum update -y` Update linux packages
    * `yum -y install httpd24` Install webserver
    * `chkconfig httpd on` Setup service
    * `yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.

    ### Configuration
    * **Apache Configuration**
    `sudo vi /etc/httpd/conf/httpd.conf`
    `vi /etc/httpd/conf/httpd.conf`
    ```
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks
    @@ -45,40 +43,34 @@ masterdev ALL=NOPASSWD: ALL
    ```

    * **PHP Configuration**
    `sudo vi /etc/php.ini`
    `vi /etc/php.ini`
    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    ```

    * **After configurations**
    `sudo service httpd restart`
    #### Finalization
    * `usermod -a -G devgroup apache` Add apache to dev group
    * `service httpd start`

    #### Other
    * `sudo usermod -a -G devgroup apache` Add apache to dev group
    * `sudo service httpd restart`

    ## Setup MySQL
    ## Setup MySQL 5.6
    * If you will be using **Amazon RDS** or any separate database server, skip the whole MySQL Section. This is only required when you want to use a "localhost" MySQL on your server.

    ### Installation
    * `wget -O mysql.rpm http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/`
    * `yum localinstall mysql.rpm`
    * `yum install mysql-community-server`
    * `yum -y localinstall mysql.rpm`
    * `yum -y install mysql-community-server`
    * `service mysqld start`
    * `chkconfig mysqld on`
    * `sudo mysqladmin -u root password 'NEW_ROOT_PASSWORD'` Setup root password
    * `sudo mysql -u root -p` Login to MySQL via console
    * `mysql_secure_installation`
    * MySQL will ask for root password. By default, its blank. Press enter.
    * MySQL will ask to set root password, answer `Y`.
    * Input the new root password
    * MySQL will ask to remove anonymous users, answer `Y`.
    * MySQL will ask to disallow root login remotely, answer `Y`.
    * MySQL will ask to remove test database, answer `Y`.
    * MySQL will ask to reload privileges, answer `Y`.
    * `mysql -u root -p` Test Root Login to **MySQL Console**
    * At this point you will need to enter your password

    ### MySQL Console
    * After entering your password, the console supposedly changed to `mysql>`.
    * At this point you can execute MySQL queries, not linux commands.
    * Execute the following code to test running queries:
    ```
    DROP DATABASE test;
    DELETE FROM mysql.user WHERE user = '';
    FLUSH PRIVILEGES;
    ```

    * To exit the MySQL Console, you can type `exit`, or press `Ctrl+C`.
    * If the console prefix changed to `mysql>`, it was successful
    * Type `exit` to go back to **Linux command line**
  10. dragonjet revised this gist Dec 22, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ masterdev ALL=NOPASSWD: ALL
    ### Installation
    * `sudo yum update -y` Update linux packages
    * `sudo yum -y install httpd24` Install webserver
    * `sudo chkconfig httpd on` Check for config errors
    * `sudo chkconfig httpd on` Setup service
    * `sudo service httpd start` Start the webserver
    * `sudo yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.
    * `sudo service httpd restart` Restart the webserver
    @@ -62,10 +62,12 @@ date.timezone = "UTC"
    * If you will be using **Amazon RDS** or any separate database server, skip the whole MySQL Section. This is only required when you want to use a "localhost" MySQL on your server.

    ### Installation
    * `sudo yum -y install mysql mysql-server` Install
    * `wget -O mysql.rpm http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/`
    * `yum localinstall mysql.rpm`
    * `yum install mysql-community-server`
    * `service mysqld start`
    * `chkconfig mysqld on`
    * `sudo mysqladmin -u root password 'NEW_ROOT_PASSWORD'` Setup root password
    * `sudo chkconfig mysqld on` Check if there are config errors
    * `sudo service mysqld start` Start the mysql service
    * `sudo mysql -u root -p` Login to MySQL via console
    * At this point you will need to enter your password

  11. dragonjet revised this gist Dec 22, 2014. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    ## Environment
    This assumes you are now connected to the server via SSH.

    * `sudo -s` Enter root mode for admin access
    * `groupadd devgroup` Create new group to be later granted access to */var/www/html*

    @@ -11,7 +10,6 @@ This assumes you are now connected to the server via SSH.

    #### Further User Configuration
    Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwords **cannot** be used on SSH (**Off**), so you initially need to use the pem or ppk files. However, since we now have created our new root user, we can change this and set it to "**On**".

    * `sudo vi /etc/ssh/sshd_config` Edit SSH config file
    * Make sure this is set: `PasswordAuthentication yes`
    * `sudo service sshd restart`
    @@ -23,6 +21,7 @@ Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwo
    root ALL=(ALL) ALL
    masterdev ALL=NOPASSWD: ALL
    ```
    * Since the sudoer file is read-only, you may need to save your changes using `:wq!`.

    ## Setup WebServer (PHP)

    @@ -37,7 +36,6 @@ masterdev ALL=NOPASSWD: ALL
    ### Configuration
    * **Apache Configuration**
    `sudo vi /etc/httpd/conf/httpd.conf`

    ```
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks
    @@ -48,7 +46,6 @@ masterdev ALL=NOPASSWD: ALL

    * **PHP Configuration**
    `sudo vi /etc/php.ini`

    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    @@ -76,7 +73,6 @@ date.timezone = "UTC"
    * After entering your password, the console supposedly changed to `mysql>`.
    * At this point you can execute MySQL queries, not linux commands.
    * Execute the following code to test running queries:

    ```
    DROP DATABASE test;
    DELETE FROM mysql.user WHERE user = '';
  12. dragonjet revised this gist Dec 22, 2014. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,14 @@ Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwo
    * Make sure this is set: `PasswordAuthentication yes`
    * `sudo service sshd restart`

    #### Add as sudoer
    * `sudo vi /etc/sudoers` Edit the sudoers file
    * Add **masterdev** user after the **root**'s line
    ```
    root ALL=(ALL) ALL
    masterdev ALL=NOPASSWD: ALL
    ```

    ## Setup WebServer (PHP)

    ### Installation
  13. dragonjet created this gist Dec 22, 2014.
    78 changes: 78 additions & 0 deletions php-mysql-ec2-amazon_linux_ami.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    ## Environment
    This assumes you are now connected to the server via SSH.

    * `sudo -s` Enter root mode for admin access
    * `groupadd devgroup` Create new group to be later granted access to */var/www/html*

    #### Creating a new Root User
    * `useradd -G root,devgroup masterdev` Create new root user. Also add to the *devgroup*
    * `passwd masterdev` Change password for the new root user
    * At this point, you'll need to input your new root user's new password

    #### Further User Configuration
    Next, we'll need to set **PasswordAuthentication** to **On**. By default, passwords **cannot** be used on SSH (**Off**), so you initially need to use the pem or ppk files. However, since we now have created our new root user, we can change this and set it to "**On**".

    * `sudo vi /etc/ssh/sshd_config` Edit SSH config file
    * Make sure this is set: `PasswordAuthentication yes`
    * `sudo service sshd restart`

    ## Setup WebServer (PHP)

    ### Installation
    * `sudo yum update -y` Update linux packages
    * `sudo yum -y install httpd24` Install webserver
    * `sudo chkconfig httpd on` Check for config errors
    * `sudo service httpd start` Start the webserver
    * `sudo yum -y install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt` Install php and the usual extensions.
    * `sudo service httpd restart` Restart the webserver

    ### Configuration
    * **Apache Configuration**
    `sudo vi /etc/httpd/conf/httpd.conf`

    ```
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    ```

    * **PHP Configuration**
    `sudo vi /etc/php.ini`

    ```
    error_log = /var/log/php-error.log
    date.timezone = "UTC"
    ```

    * **After configurations**
    `sudo service httpd restart`

    #### Other
    * `sudo usermod -a -G devgroup apache` Add apache to dev group
    * `sudo service httpd restart`

    ## Setup MySQL
    * If you will be using **Amazon RDS** or any separate database server, skip the whole MySQL Section. This is only required when you want to use a "localhost" MySQL on your server.

    ### Installation
    * `sudo yum -y install mysql mysql-server` Install
    * `sudo mysqladmin -u root password 'NEW_ROOT_PASSWORD'` Setup root password
    * `sudo chkconfig mysqld on` Check if there are config errors
    * `sudo service mysqld start` Start the mysql service
    * `sudo mysql -u root -p` Login to MySQL via console
    * At this point you will need to enter your password

    ### MySQL Console
    * After entering your password, the console supposedly changed to `mysql>`.
    * At this point you can execute MySQL queries, not linux commands.
    * Execute the following code to test running queries:

    ```
    DROP DATABASE test;
    DELETE FROM mysql.user WHERE user = '';
    FLUSH PRIVILEGES;
    ```

    * To exit the MySQL Console, you can type `exit`, or press `Ctrl+C`.