Wednesday, February 29, 2012

AWS EC2: Quick and secure LAMP on Amazon Linux

Source: http://imperialwicket.com/aws-quick-and-secure-lamp-on-amazon-linux

sudo su -
yum update
# add the AMP
yum install httpd mysql mysql-server php php-mysql php-xml php-pdo php-odbc php-soap php-common php-cli php-mbstring php-bcmath php-ldap php-imap php-gd

# Add a user and give sudo privs
useradd someUser
passwd someUser
# Give password
vim /etc/sudoers
# if this is unfamiliar to you, be careful:
# insert line "someUser ALL=(ALL)   ALL"

# Configure ssh key and disable password authentication
cd /home/someUser
mkdir .ssh
vim .ssh/authorized_keys
chown -R someUser:someUser
chmod 700 .ssh
chmod 600 .ssh/*
vim /etc/ssh/ssh_config
# insert line "PasswordAuthentication no"
service sshd restart
# Validate connection in another terminal before exiting the current session!

# Primary MySQL config
chkconfig mysqld on
service mysqld start
/usr/bin/mysql_secure_installation
# Root access from local only
# Set a root password (that's good)
# Delete test db
# Delete anonymous users

# Apache chkconfig on
chkconfig httpd on
service httpd start

# Create a mysql user/schema for your site(s)
# DON'T CONNECT AS ROOT FOR YOUR WEB APPS
mysql -u root -p
# Enter the password you set
mysql> CREATE SCHEMA someAppName;
mysql> GRANT ALL ON someAppName.* TO someAppName@'%' IDENTIFIED BY 'somePassword';

No comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!