Inevitably, there were some additional tweaks I ended up needing to do after the 5-min tutorial setup, so I'll outline what I did here:
- Open up MySQL port. To ensure that my code could access the database (and not just MySQL Workbench), I had to open up the mysql port (3306). To do this, go to the EC2 Dashboard; under Network and Security, click on Security Groups. Select the appropriate security group for your instance and, under 'Inbound', create a new rule for the mysql port. After click 'Add Rule', it should appear in the list of TCP Ports.
- Automatically startup services. To automatically have tomcat and mysqld start up whenever the ec2 instance restarts, run these commands:
Note: the different levels correspond to runlevels. To check that we have these services running with the right flags, we can run:sudo chkconfig --level 35 tomcat6 on sudo chkconfig --level 35 mysqld on
chkconfig --list
- Secure MySQL. To make MySql slightly more secure, add a password for root (by default, there's no password), remove the test database, and remove anonymous access to the database.
# create a new password for root sudo mysqladmin -u root password 'new-password' # login with the new password sudo mysql -u root -p # remove test database mysql> DROP DATABASE test; # remove anonymous access to database mysql> DELETE FROM mysql.user WHERE user='' ; mysql> FLUSH PRIVILEGES;
- Get phpMyAdmin working. Sometimes it's just easier to do DB stuff through a browser instead of a dedicated app like MySQL Workbench. To get phpMyAdmin up and running, I need to install Apache and php first. Having both Apache and Tomcat installed isn't problematic, since I have Apache handle the 80 port and Tomcat handle the 8080 port (which is the default for Tomcat anyways).
To install Apache:
To have the Apache service automatically run on startup:sudo yum install php sudo yum install httpd
Then I just went to https://gist.github.com/aronwoost/1105007 and followed the instructions in these sections: 'Setup phpMyAdmin', 'Make mod_write work', and 'Start apache'.sudo chkconfig --level 35 httpd on
First, to allow access from external IP's:
Then, we add the blowfish_secret so that cookie authentication will worksudo chmod 600 /etc/httpd/conf.d/phpmyadmin.conf sudo nano /etc/httpd/conf.d/phpmyadmin.conf # Web application to manage MySQL # # # Order Deny,Allow # Deny from all Allow from 127.0.0.1 # Alias /phpmyadmin /usr/share/phpmyadmin Alias /phpMyAdmin /usr/share/phpmyadmin Alias /mysqladmin /usr/share/phpmyadmin
Now we modify the httpd configuration to allow mod_rewrite to work:sudo chmod 600 /usr/share/phpmyadmin/config.inc.php sudo nano /usr/share/phpmyadmin/config.inc.php ... $cfg['blowfish_secret'] = 'put-a-magic-string-here'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ ... sudo chmod 644 /usr/share/phpmyadmin/config.inc.php
A few lines below that, look forcd /etc/httpd/conf sudo nano httpd.conf
AllowOverride None
and replace withAllowOverride All
. And now start up Apache:
Now phpmyadmin is up and running at:sudo service httpd restart
orhttp://Your_EC2_IP_Address/phpmyadmin
http://ec2-*.*.compute.amazonaws.com/phpmyadmin
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.