Setting Up EC2 Web Server

Getting X11 Forwarding Working

It can be confusing to see the report {code}WARNING! The remote SSH server rejected X11 forwarding request.{/code}. You’ve made sure that {bash}/etc/ssh/sshd_config{/bash} has X11 forwarding enabled and that a local X Server is running. The problem is that many servers do not have {bash}xauth{/bash} installed by default. Adding this enables X11 forwarding.

[bash] yum -y install xauth
[/bash]

LAMP

[bash] yum -y install httpd httpd-devel
chkconfig –levels 35 httpd on
service httpd start
[/bash]

Firewall

Before connecting to the web server, you will need to allow HTTP to pass through the firewall. The easiest way is to use {bash}system-config-firewall{/bash}. As I frequently have difficulty getting the text versions of the {bash}system-config-*{/bash} to run, I use the graphical version.

[bash] yum -y install system-config-firewall
echo $DISPLAY # make sure that X11 forwarding is in-place
system-config-firewall
[/bash]

MySQL

[bash] yum -y install mysql mysql-server mysql-devel
chkconfig –levels 35 mysqld on
service mysqld start
mysql_secure_installation # remember the root password here, you need it below
[/bash]

After setting up MySQL, you need to add a database:

[bash] mysql -u root -p # password is queried, not passed on the command line
[/bash] [sql] CREATE DATABASE wwyw;
USE mysql;
SHOW TABLES;
GRANT ALL ON wwyw.* TO whistlew IDENTIFIED BY ‘Great Password’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT;
[/sql]

PHP

Before the PHP installation will work, you need to enable some package repositories that are disabled by default. This is needed because {bash}php-mcrypt{/bash} is not available in the repositories enabled by default.

[bash]

perl -i.bak -lpe ‘s‘ /etc/yum.repos.d/CentOS-Base.repo

yum -y install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-pecl-imagick

[/bash]

Miscellaneous

You need to “activate” the EPEL repository before installing phpMyAdmin, which can be found at {bash}/etc/yum.repos.d/epel.repo{/bash}.

Quick ‘n Easy LAMP Install on Red Hat/CentOS
Virtual Host Example Configurations
An In-Depth Discussion of Virtual Host Matching
Running Apache2 hosts as different users
Run Apache2 Virtual Hosts as Different Users

[bash] rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
yum install –enablerepo=webtatic httpd-itk
[/bash]

Setting up HTTPS

Self-Signing a Certificate for SSL
Generating the Keys
Apache SSL on Red Hat

Allow Access to a Directory Only Via SSH
Password Protect Directories with Basic Authenication

Leave A Reply