Tuesday, December 4, 2012

install LAMP - postgres - change data dir - ssh without password... all donde minuted in AWS Amazon Web Services

I just wanted to comment on how good Amazon Web Services are.

I had my server hosted with another provider, whose name I'm not going to say...

I was with them a lot of time, maybe 10 years. Upgraded my server a couple of times and all. One day my server went nuts and they wanted to charge me $99 dollars AN HOUR just to take a look and help me, no warranties.

So I decided it was time to migrate to a better service: Amazon AWS.

I was getting used to it while setting up the a webapp on Elastic Beanstalk, which is also an excellent service you should try if you have a big webapp you want to deploy. It has and all integration with git, so its all really easy. Using it was that I started understading the relationship between the different services:
EC2: the app servers
RDS: database servers
Route52: domain record management
CloudFront: asset delivery
etc...

Well, as I was saying I was urged to migrate from my old server.

I could set up a running new server in minutes. Maybe the most complicated stuff would be opening a new account and passing through the telephone validation.

So I wrote all this because I wanted to documents the command I did to install the LAMP+Postgres environment I needed. Also to change the datadir of mysql:

I decided to use an instance running Ubuntu.

commands (with sudo or as root):
apt-get update
apt-get install apache2 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql postgresql-client php5-pgsql

that get all I needed installed.

I had a snapshot of a volume I wanted to mount in the new server. So in Amazon's interface I select attach volume to xxxx instance. After that I had to modify mount the drive that appeared in /dev/xvdf with the command

mount /dev/xvdf /mnt

To make the change permanent I edited the file

/etc/fstab

and added the line

/dev/xvdf /mnt ext4 defaults 0 0

where /mnt is the mount point... the other options are googlable.

I also needed to change MySql's data directory. This was kind of tricky the first time I had to do it.

One needs to change /etc/mysql/my.cnf file find datadir options and change it to what one needs.

The restart mysql with

service mysql restart

But that't not all, it is necessaty to update ubuntu's apparmor file with

vim /etc/apparmor.d/usr.sbin.mysqld

There you must find the old datadir path and change for the new one. Afterwards, reconfigure mysql with

dpkg-reconfigure mysql-server-5.5

And then restart again mysql (I did this, I don't know if its absolutely necessary).

I also needed to log in to the server using classic user/password combination, so its necessary to edit sshd_config with

vim /etc/ssh/sshd_config

There it is necessary to change the directive to

PasswordAuthentication yes

Finally I installed exim4 as an MTA

apt-get install exim4

and configured it with

dpkg-reconfigure exim4-config

I then chose a user to forward me root and postmaster mails. It is necessary to create a file in the user home

~/.forward

and the contents are the email address to which you wish to forward the emails.

that's it !

No comments:

Post a Comment

cancel script completely on ctrl-c

I found this question interesting: basically how to cancel completely a script and all child processes : You do this by creating a subro...