Setting up a EC2 Server on Amazon: Part 3
Up to this point you have created the server, and have granted yourself access to it. Now it’s time to make it work how it should, so, let’s jump right into this. We will be using the ever so dreaded command prompt to set this up. There isn’t any way around it so just muster up the courage, and open it up. I use a mac so I am going to go into Applications -> Utilities -> Terminal.
The first thing to do is to get connected. To do this you need to use your Key Pair, which you downloaded when creating your server. For me, I downloaded this file right to my Downloads folder on my Macbook Pro, so I will first get into the directory:
Now if you haven’t done it already, you need to set the permissions on this file. It’s for added security.
sudo chmod 600 Initial_Test.pem
Next I will SSH into the server by utilizing the Key Pair. Mine was called Initial_Test.pem.
ssh -i Initial_Test.pem email@example.com
Next, it will ask you if you want to add this to your known hosts file. Type “yes” and press “Return,” and you are now connected! Next we need to install any updates. So type the following command.
sudo aptitude update
One that is complete type,
sudo aptitude dist-upgrade
Next you need to install the LAMP stack so type,
It will run a quick command and then launch a blue screen with a bunch of options. Use the arrow keys to move the cusror down to where it says “LAMP” and press the “Space Bar,” and then press “Return.” You have now begun to install the LAMP stack. Eventually it will ask you some questions about setting up MySQL, namely the Username and Password you wish to use. Just enter these so that you will remember them and press return. For this example, I am going to use “root” as my username and “test123″ as my password. Once that process is complete, it will kick you out to the command prompt. We are going to go ahead and setup phpMyAdmin. To do so, I will need to log into MySQL. To do so, type the following and press “Return.”
mysql -u root -p
When prompted enter your password (in my case test123) and press”Return.” Now all I have to do is create the phpmyadmin database. So I will type the following and press “Return.”
CREATE DATABASE phpmyadmin;
Then type “exit” and you will exit out of MySQL. Next I will install phpMyAdmin by enter the following and pressing “Return.”
sudo apt-get install phpmyadmin
At this point you are going to want to go test your phpMyAdmin area. I have found in recent installs that I can’t connect so sometimes I need to run the following command to link everything up.
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
So guess what…your done. For the most part. As promised PHP is installed, along with MySQL, and we even got phpMyAdmin installed, so you don’t have to do anything on the command line.
A few things to note.
- Location of the php.ini file:
- Restart apache by typing:
Now if you have other things you need installed, just Google it! From here on out you will follow the same process above to connect to the server. You will have to enter a few commands, and boom…your done.
There are a few extensions that I like to install, and usually find I need when creating a Web Apps. For the most part just enter these and press enter. Some of them may ask you if you want to allow the module to use up space, so just press “Y”. Others I have listed, require a little more editing, and I will try to write up a few articles on these in more detail.
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
sudo apt-get install php5-memcache memcached
SFTP (Read More)
sudo apt-get install vsftpd
PHP CLI / Cron (Read More)
sudo apt-get install php5-cli
Mod_Rewrite (Additional PostComing Soon!)
sudo a2enmod rewrite
HTOP – Monitor Processes on Server
sudo apt-get install htop
Other PHP Libraries
sudo apt-get install php5-dev
sudo apt-get install php-pear
Might Need to Install MongoDB
pecl install mongo
Then add this to the php.ini file
Allows the system to send mail from server.
sudo apt-get install sendmail