Download pdf - AWS WordCamp Presentation

Transcript
  • 7/27/2019 AWS WordCamp Presentation

    1/34

  • 7/27/2019 AWS WordCamp Presentation

    2/34

    About Me

    Brazilian living in SD, 8 yrs in Marine Corps

    Started using WordPress in 2009

    Work with C++, Java, Perl, PHP (someRuby), Bachelor of Science in CS.

    Currently Engineer at Gap Intelligence

    Run Advanced WordPress Facebook Group

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    3/34

    Plug

    facebook.com/groups/advancedwp/

    http://bit.ly/KiFciT@bastosmichael

    https://www.facebook.com/groups/advancedwp/
  • 7/27/2019 AWS WordCamp Presentation

    4/34

    Quick Disclaimer...

    If you don't want to maintain your own serverenvironment, don't use AWS...

    If you don't want to be your own server

    admin or need constant support fromsomeone, don't use AWS...

    If you have no idea about anything that I justsaid, don't use AWS... I will be very technical...

    Other fast alternatives for WordPress: WP

    Engine, Page.ly, Media Temple, Heroku...

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    5/34

    Sign up for Amazon Web Services

    Visit http://aws.amazon.com/console/

    You'll need a credit card to register!

    Make sure you have the following services

    EC2 (Elastic Cloud Computing) Route53 (DNS Manager) RDS (Relational Database Service) S3 (Simple Storage)

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    6/34

    Start with the EC2 Console

    We willonlyfocus onthese 5areas...

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    7/34

    Step 1) Go and Create a Key Pair

    Make sureto give it a

    name...

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    8/34

    You will then Download your Key

    Make sure to put your Key Pair in the placewhere your terminal window begins

    You'll handle *.pemfiles differently on aMac and Linux

    Machine than youwill on Windows

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    9/34

    Where to place your Key Pair *.pem(Linux & Mac Desktops)

    Linux Desktop user's should place file inhome directory or it's .ssh folder. I.E."/home/your_user_name" or"/home/your_user_name/.ssh"

    To get to your .ssh folder in command linetype "cd ~/.ssh"

    Mac user's should place file in homedirectory's .ssh folder as well . I.E."/Users/your_user_name/.ssh"

  • 7/27/2019 AWS WordCamp Presentation

    10/34

    Where to place your Key (Windows)

    Download PuTTY & PuTTYGen to yourDesktop - http://bit.ly/KiprZ8

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    11/34

  • 7/27/2019 AWS WordCamp Presentation

    12/34

    You've now loaded the *.pem file

    Select Saveprivate key.

    You can saveit without apass code.

    It saves as a*.ppk on yourDesktop

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    13/34

    2) Modify your Security Group

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    14/34

  • 7/27/2019 AWS WordCamp Presentation

    15/34

  • 7/27/2019 AWS WordCamp Presentation

    16/34

    Make sure to change Security Group

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    17/34

    Launch your Instance when correct

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    18/34

    h //bi l /KiF iT@b i h l

  • 7/27/2019 AWS WordCamp Presentation

    19/34

    Right Click to view Connect option

    Be sure to login with

    username"ubuntu@" instead of"root@"

    Copy sshcommand..

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    20/34

    5) Now Open a new Terminal(Linux Desktop & MacOSX)

    Linux Desktop users can log into theirservers via ssh like so"ssh -i server.pem ubuntu@ElasticIP"

    Mac users can log into their servers via likeso "ssh -i ~/.ssh/server.pem

    ubuntu@ElasticIP"

    You may need to do a "chmod 400 *.pem" inorder to get this working

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    21/34

    Using the PuTTY terminal (Windows)

    Click putty.exe on yourDesktop andenter the

    Elastic IP

    http://bit.ly/KiFciT@bastosmichael

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    22/34

    Select Data Option on the left

    Make sure to

    make yourAuto-loginusername"ubuntu"

    instead of"root"

    http://bit.ly/KiFciT@bastosmichael

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    23/34

    Select SSH and Auth on the left

    Rememberthat *.ppk file

    we createdwithPuTTYGen?

    Click Browseand add it,then hit open.

    http://bit.ly/KiFciT@bastosmichael

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    24/34

    6) Instal Web Server (Nginx)

    sudo su apt-get install

    mysql-server

    mysql-client apt-get install

    nginx /etc/init.d/nginx

    startNow that your terminal isopen, go ahead and runthe following commands...

    $ sudo apt-get update

    http://bit.ly/KiFciT@bastosmichael

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    25/34

    7) Install PHP-5 FPM

    apt-get install php5-fpm php-apc php5-mysqlphp5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-

    memcache php5-ming php5-ps php5-pspellphp5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

    /etc/init.d/php5-fpm restart

    vi /etc/nginx/sites-available/default http://bit.ly/QZTPsB -> Use for Default Domain

    /etc/init.d/nginx restart

    http://bit.ly/KiFciT@bastosmichael

    htt //bit l /KiF iT@b t i h l

  • 7/27/2019 AWS WordCamp Presentation

    26/34

    8) Install Postfix for mail()

    pear install mail pear install Net_SMTP

    pear install Auth_SASL pear install mail_mime

    This will replace sendmail() with postfix apt-get install postfix

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    27/34

  • 7/27/2019 AWS WordCamp Presentation

    28/34

    http://bit ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    29/34

    10b) Create an RDS Instance

    https://console.aws.amazon.com/rds/home

    Once you've created the RDS Instance,

    connect to it in command line mysql -hRDShostaddress -uUsername -p create database wordpress;

    Now when you modify wp_config.php, keepall of these configuration changes in mind.

    Create as many databases as you'd like in

    RDS, pay attention to scale and size

    http://bit.ly/KiFciT@bastosmichael

    http://bit ly/KiFciT@bastosmichael

    https://console.aws.amazon.com/rds/homehttps://console.aws.amazon.com/rds/home
  • 7/27/2019 AWS WordCamp Presentation

    30/34

    11) Modify wp-config.php

    vi ~/your_domain/wp-config.php

    define('DB_NAME', 'database');

    define('DB_USER', 'admin'); define('DB_PASSWORD', 'your_password'); define('DB_HOST', 'localhost');

    Don't forget to add salting to your site. https://api.wordpress.org/secret-key/1.1/salt/

    http://bit.ly/KiFciT@bastosmichael

    http://bit ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    31/34

    12) Create a new Nginx Host

    vi /etc/nginx/sites-available/your_domain http://bit.ly/QZTPsB

    cd /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-available/your_domain

    your_domain Replace "_" if hosting multiple sites.

    server_name _;

    Change to "/home/ubuntu" root /var/www;

    /etc/init.d/nginx reload

    http://bit.ly/KiFciT@bastosmichael

    http://bit ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    32/34

    13) Now go to your IP and or Domain

    http://bit.ly/KiFciT@bastosmichael

    http://bit ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    33/34

    What you should know?

    You can take your ElasticIP and use withyour DNS service to point domain to server Route53 is the best DNS service for AWS (cheap)

    Use Amazon RDS instead of localhost tohost your database, S3 to store your files.

    Amazon CloudFormation has a WordPressblog stack both for single and RDS

    http://bit.ly/KiFciT@bastosmichael

  • 7/27/2019 AWS WordCamp Presentation

    34/34