Up until now we were just getting things set up. Yes, I know four posts on setup seems excessive. Honestly, if you’ve done this a few times the setup can be done in around 10 minutes time. :-) Don’t be discouraged by the size of the posts!
Also, I’ll stay away from as many screenshots as it’s not going to be as interesting as before. In any case, yesterday we learned how to ssh into our system. We’ll use the SSH that we got working yesterday to do most of the setup today.
First off, let’s make sure the server is fully patched and secure:
$ sudo yum -y update
I’ll break that down into parts for you:
- $ – command prompt, don’t copy that part. I’m putting it there to indicate that this is a command you’re typing in.
- sudo – Runs a command as super-user. Get it “su do” something.
- yum – The update manager.
- -y – Assume “yes” to the questions. You don’t need this, you’ll just need to hit “y” to update.
- update – What you want the command to do.
Next, let’s install the software that runs things:
$ sudo yum -y install mysql mysql-server gcc php-fpm php-cli php-devel php-gd php-imap php-mbstring php-mysql php-odbc php-pdo php-pear php-soap php-xml php-pecl-apc pcre-devel emacs $ sudo yum groupinstall -y "Web Server"
In this case we’re installing a whole slew of packages. Some aren’t strictly needed, but most are. You don’t need emacs, but that’s the editor I like. Feel free to hate on me. I’ll stick to nano for the instructions.
The basics of WordPress is that it’s a PHP application that uses MySQL as the database to store the posts and comments in. So what we just did was install MySQL and PHP. We also need a web server. We also installed apache to do that job for us.
At some point I want to explore using nginx (pronounced “engine x”) to use less memory, but it seems that the way WordPress stands right now, it would be swimming upstream way more than I want to dive into right now.
While we’re at it, let’s add some swap. I’m going to tune this server so it likely won’t be needed. That being said, running out of memory on a server can be problematic. Slow (disk) memory is better than no memory in this case.
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 52.9792 s, 20.3 MB/s $ sudo mkswap /swapfile mkswap: /swapfile: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 1048572 KiB no label, UUID=a44da2c8-70ab-4dd0-b109-e09b1fa4e549 $ sudo swapon /swapfile $ free total used free shared buffers cached Mem: 614596 607264 7332 0 13696 558396 -/+ buffers/cache: 35172 579424 Swap: 1048572 0 1048572
So, to break it down…
- dd – The origin of this command’s name is lost to the sands of time. What we’re doing is copying a gigabyte’s worth of zeros into a file. It’ll take a minute or so to run since you are in fact writing a giant freaking file.
- mkswap – It sets up the newly created file to look like a swap file for the system.
- swapon – Lets the operating system know about the file you just made for it.
The “free” at the end was just to verify it worked. It did. :-) In case you didn’t get it by now, the bold stuff is what you type (copy and paste probably) and the non-bold stuff is what you get back from the system.
There’s one last thing you need to do to make the swap space permanent.
$sudo nano /etc/fstab
This will open up an editor called nano. It’s simple and easy to use. Easier than vi or emacs. (I’m not going to get into the religious war about them. We all know emacs is better. ;-) )
You need to add one line to the bottom of it:
/swapfile swap swap defaults 0 0
Hit control-x to exit and choose to save the file. Once you’ve done this, the next time the server is restarted swap will be added back onto the system.
Let’s get one last thing done to at least make up feel like we got some real progress done today. Let’s start up the web server.
$sudo chkconfig httpd on $sudo service httpd start
If you’ve not yet set up DNS to your new server you can check the EC2 console to see what your IP address is. That’s the IP to put in your browser:
In the above example you would enter “http://22.214.171.124/” in the address bar of your browser.
The chkconfig tells the system we want to start up apache whenever it starts up. The service start, like you would guess, starts Apache.
Tomorrow we’ll set up MySQL, configure PHP and Apache.
(2014-03-30 – updated to provide additional info)