AWS CentOS 6.5 Instance + AWS EBS volume for web hosting files and database?

admin

Administrator
Staff member
I have an AWS instance running CentOS 6.5. It has been updated, secured, and setup for web hosting (LAMP). I attached an EBS volume to the instance and mounted it under
Code:
/data
.

Two questions:

<ol>
<li>How can I get MySQL to use the
Code:
/data
directory as its database storage location? (I don't want to run the program from the
Code:
/data
directory, just put the .sql file there.</li>
<li>How can I do the same for my web site? I plan on running a wordpress site and its current location is in the
Code:
/var/www/html
directory. I want to change this to
Code:
/data/site
.</li>
</ol>

I want to keep the web site files and database on a separate volume:
Code:
/data
. If my instance was to get corrupt or inaccessible, I can attach the EBS volume to a new instance.

I have read dozens of tutorials and articles on how to get MySQL moved to a different directory, but nothing is working. MySQL refuses to start up after. Can I keep MySQL installed as is, but have it read/write the database on a different directory like
Code:
/data
which is a mounted EBS volume or is this not possible at all with linux?

Here are some of the tutorials and articles I been following/testing with:

Code:
aws.amazon.com/articles/1663?_encoding=UTF8&amp;jiveRedirect=1

Code:
spruce.it/noise/setting-up-a-proper-lamp-stack-on-aws-ec2-ebs/

EDIT:
This is what I am doing.

<ol>
<li>Create a new instance using this ami:
Code:
https://aws.amazon.com/marketplace/pp/B00IOYDTV6?ref=cns_srchrow
</li>
<li>Once the instance is up, I run updates using:
Code:
sudo yum update -y
</li>
<li>One updated, I set it up as a LAMP web server using these instructions:
Code:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
In addition to the above steps, I allow port 80 tcp connections on the built-in firewall. I run these commands:
Code:
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
and
Code:
sudo service iptables save
Once this is done, I test my site at
Code:
http://IP-ADDRESS
(this shows me the Apache Test Page)</li>
<li>Once LAMP is installed, I install the MySQL Server by running this:
Code:
yum install mysql-server
After that is installed, I proceed to the "To secure the MySQL server" instructions on the previous Amazon document.</li>
<li>Next, I install PHPMyAdmin using these two tutorials:
Code:
http://tecadmin.net/installing-apache-mysql-php-on-centos-redhat/#
and
Code:
http://tecadmin.net/how-to-install-phpmyadmin-on-centos-using-yum/
</li>
<li>At this point, I have a fully functioning web server. Now, I want to use the AWS EBS volume to store all the databases and website files. First, I attach the newly create AWS EBS volume. I use this tutorial to do this:
Code:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
</li>
</ol>

THIS IS WHERE THE PROBLEMS START.
Using the information in this tutorial:
Code:
aws.amazon.com/articles/1663?_encoding=UTF8&amp;jiveRedirect=1
. It says FAILED.