ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    First Thoughts on AWS and ThanksAJ.com is Back!

    IT Discussion
    amazon aws cloud computing cloud
    7
    15
    3.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thanksajdotcomT
      thanksajdotcom
      last edited by thanksajdotcom

      Before I start, ThanksAJ.com is back up!! 😄

      So due to some change in life circumstances, my ability to host my own website myself has been compromised. Therefore, I set out in search of a hosting platform. I asked @Danielle-Ralston about Rackspace, but that was too pricey. I looked at Azure, but even that was more than I could spend right now. However, AWS has quite a few things you can do completely free. For example, 1 CPU, 1 core, and 1GB for a Linux VM is totally free!! (as far as I can tell)

      Anyways, so here's what I did to move my webserver over...

      I setup my network back up with my router and server just to get files off. I keep my sites in their own folders in /var/www/. I copied the directories to the SAMBA share directories and then from there off to my laptop. Next, you need to run the following command...

      mysqldump -u [username] -p [database_name] > [dumpfilename.sql]
      

      Do that for every database you have, assuming you're using Wordpress. I copied the exported databases for each of my three sites to my laptop as well.

      Next, I created a new VM, or instance as Amazon calls it, of Ubuntu Server.
      upload-211fcb26-5aa0-4364-95ae-2657170e86c5

      Next I choose my instance provisioning, and I'm in the free tier category...
      upload-729d16be-d830-421a-976c-c08a65575f9e

      Configure instance details...I left this all default...
      upload-9dc42119-a4d3-4e87-a3c8-73bd5cb5994e

      Next is storage...I made my server 10GB...
      upload-6472ae7c-9f09-49e1-9192-3604cd2c2a2a

      Next you name/tag the machine...
      upload-1e2612ec-227b-477d-ac54-37fc6e09918a

      Now is the security settings/firewall rules...I added HTTP port 80 to the list to allow the webserver to work...
      upload-36c2717d-4481-43d6-9e4c-e55aeb2550c4

      That's pretty much it! A full list of what you have access to is here:
      upload-9a833c8f-e4e2-48c1-a2be-1db98460d8c0

      Once the VM was up, Amazon uses keys to secure the SSH connections, and they give you a very comprehensive tutorial on how to use their key file, which is a .pem, with PuTTY, which involves converting it to a PuTTY readable-format using PuTTYgen.

      Once I connected, I installed Pertino and connected it to my account. Then I shared the folder housing the files on my laptop and ran...

      mount -t cifs -o username=*username*,password=*password* //50.203.224.5/Websites /media/websites
      

      I made the folder websites in the /media folder so I'd have somewhere to mount it. After that, I did the following...(note: I was running in root mode, so I didn't have to type sudo before the commands)

      cd /media/websites
      cp -rv * /var/www
      

      The -r makes the copy recursive, and my .sql files were in this folder as well. I moved those after they copied. Also, the -v makes it verbose so you can see the progress, which you will want. While that ran, I opened a second SSH session and ran the following...

      apt-get update
      apt-get install apache2 mysql-server libapache2-mod-auth-mysql php5-mysql php5 libapache2-mod-php5 php5-mcrypt
      

      This installs Apache, MySQL and PHP so that you have a functional LAMP stack on your server!

      Now, assuming you have the .sql files copied, which it might be better to copy these separately and first (which I did), we need to import them back into MySQL. However, first we have to configure MySQL. You would have been prompted to set a root MySQL password when you installed it, so you will need that now.

      mysql -u root -p
      > CREATE DATABASE thanksaj;
      > CREATE DATABASE literaryworksbyaj;
      > CREATE USER wordpressuser@localhost;
      > SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
      > GRANT ALL PRIVILEGES ON thanksaj.* TO wordpressuser@localhost IDENTIFIED BY 'password';
      > GRANT ALL PRIVILEGES ON literaryworksbyaj.* TO wordpressuser@localhost IDENTIFIED BY 'password';
      > FLUSH PRIVILEGES; 
      > exit
      

      You will want to recreate the databases using the same names you used before, or you can name it something different, as long as you update your wp-config.php file afterwards. Now, navigate to the directory of your .sql files. To import the database into MySQL, use the following command:

      mysql -u [username] -p [database_name] < [dumpfilename.sql]
      

      So in my case, I did this...

      cd /path/to/sql_files
      mysql -u root -p thanksaj < thanksaj.sql
      

      So all that was left for me to do was setup the Apache Virtual Hosts and make sure Mod_Rewrite would work. Go to your apache.conf file in /etc/apache2/apache2.conf. It should be line 164 that will have the part you need, which is this:

      <Directory /var/www/>
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
      </Directory>

      Change the line in bold from ending in None to All. Now navigate to /etc/apache2/sites-available/ and make a .conf file for each website you're hosting. To do this, run...

      cp 000-default.conf thanksaj.com.conf
      vi thanksaj.com.conf
      

      The default looks as follows (additions/changes from default in bold):

      <VirtualHost *:80>
          # The ServerName directive sets the request scheme, hostname and port that
          # the server uses to identify itself. This is used when creating
          # redirection URLs. In the context of virtual hosts, the ServerName
          # specifies what hostname must appear in the request's Host: header to
          # match this virtual host. For the default virtual host (this file) this
          # value is not decisive as it is used as a last resort host regardless.
          # However, you must set it for any further virtual host explicitly.
          #ServerName www.example.com
      

      ServerAdmin webmaster@localhost
      ServerName thanksaj.com
      ServerAlias www.thanksaj.com
      DocumentRoot /var/www/thanksaj.com

          # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
          # error, crit, alert, emerg.
          # It is also possible to configure the loglevel for particular
          # modules, e.g.
          #LogLevel info ssl:warn
      
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      
          # For most configuration files from conf-available/, which are
          # enabled or disabled at a global level, it is possible to
          # include a line for only one particular virtual host. For example the
          # following line enables the CGI configuration for this host only
          # after it has been globally disabled with "a2disconf".
          #Include conf-available/serve-cgi-bin.conf
      </VirtualHost>
      

      Make on of these for each site. Afterwards, run...

      a2ensite thanksaj.com
      service apache2 restart
      

      You can bring all the sites on at once and then just restart apache once. Now the virtual hosts are online!

      Once I did this and had all my files copied over, my site was live once again! I know this is pretty long but I hope this helps someone else in the future!

      Stay fruity Fruit Tarts!

      Thanks,
      A.J.

      Reference Links:

      • https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu - Installing LAMP stack on Ubuntu
      • https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-12-04 - Installing Wordpress on Ubuntu
      • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html - How to connect to AWS Instance with PuTTY
      • http://www.itworld.com/article/2833078/it-management/3-ways-to-import-and-export-a-mysql-database.html - Import/export to/from MySQL
      1 Reply Last reply Reply Quote 2
      • ?
        A Former User
        last edited by

        Free for the first year.

        thanksajdotcomT scottalanmillerS 2 Replies Last reply Reply Quote 1
        • tonyshowoffT
          tonyshowoff
          last edited by tonyshowoff

          Today's To Do List:

          • Get my leprosy treated
          • Commence DDoS attack against ThanksAJ.com

          BTW, nice post, pretty informative, I bet especially to those new to AWS.

          thanksajdotcomT 1 Reply Last reply Reply Quote 0
          • thanksajdotcomT
            thanksajdotcom @A Former User
            last edited by

            @Aaron-Studer said:

            Free for the first year.

            You sure?

            thegillionT scottalanmillerS 2 Replies Last reply Reply Quote 0
            • thanksajdotcomT
              thanksajdotcom @tonyshowoff
              last edited by

              @tonyshowoff said:

              Today's To Do List:

              • Get my leprosy treated
              • Commence DDoS attack against ThanksAJ.com

              BTW, nice post, pretty informative, I bet especially to those new to AWS.

              I had never touched AWS before 6ish hours ago. I couldn't figure out at first why the server was accessible to me via SSH but the website I was trying to get to wasn't working. Then I realized...I had to allow port 80 inbound. After that, it started working.

              1 Reply Last reply Reply Quote 0
              • thanksajdotcomT
                thanksajdotcom
                last edited by

                So one thing I will say I don't like about AWS is the names for everything. A VM is an instance. Firewall rules are under security group, which to me is users and those users' permissions. They seemed to go out of their way to make all the names of standard stuff as unique to them as possible, and that is a little irritating, IMHO.

                thegillionT 1 Reply Last reply Reply Quote 0
                • AmbarishrhA
                  Ambarishrh
                  last edited by

                  Excellent post @thanksaj

                  1 Reply Last reply Reply Quote 1
                  • thegillionT
                    thegillion @thanksajdotcom
                    last edited by

                    @thanksaj said:

                    @Aaron-Studer said:

                    Free for the first year.

                    You sure?

                    Yes it is only for the first year.

                    1 Reply Last reply Reply Quote 0
                    • thegillionT
                      thegillion @thanksajdotcom
                      last edited by

                      @thanksaj said:

                      So one thing I will say I don't like about AWS is the names for everything. A VM is an instance. Firewall rules are under security group, which to me is users and those users' permissions. They seemed to go out of their way to make all the names of standard stuff as unique to them as possible, and that is a little irritating, IMHO.

                      They think they are cisco lol

                      1 Reply Last reply Reply Quote 1
                      • scottalanmillerS
                        scottalanmiller @A Former User
                        last edited by

                        @Aaron-Studer said:

                        Free for the first year.

                        Yup, I used it too. Now I have to pay for it. It's just an extended trial.

                        1 Reply Last reply Reply Quote 0
                        • scottalanmillerS
                          scottalanmiller @thanksajdotcom
                          last edited by

                          @thanksaj said:

                          @Aaron-Studer said:

                          Free for the first year.

                          You sure?

                          Yup

                          1 Reply Last reply Reply Quote 0
                          • MattSpellerM
                            MattSpeller
                            last edited by

                            How much is it after the year? Can't be terribly much for a 1cpu 1gb instance.

                            1 Reply Last reply Reply Quote 0
                            • scottalanmillerS
                              scottalanmiller
                              last edited by

                              One of the features that I like about Amazon is getting to use Amazon Linux. It is a really lean, really tight distro that is tuned for use on AWS. If you can, I would recommend it. It is based off of RHEL but heavily modified. And no SystemD. It is the last, major non-SystemD Linux.

                              1 Reply Last reply Reply Quote 0
                              • ?
                                A Former User
                                last edited by

                                AWS is $20/month after the first year.

                                You might take a look at digital ocean, or vultr after you year is up for a more affordable alternative.

                                1 Reply Last reply Reply Quote 2
                                • AmbarishrhA
                                  Ambarishrh
                                  last edited by

                                  I second Digital Ocean. They have 1 click installers for wordpress.
                                  https://www.digitalocean.com/community/tutorials/one-click-install-wordpress-on-ubuntu-14-04-with-digitalocean

                                  1 Reply Last reply Reply Quote 1
                                  • 1 / 1
                                  • First post
                                    Last post