AWS EC2 Setup Up

Installing a LAMP Web Server

Set Elastic IP

Config Security Group for inbound rules

Migrate PHP 5.3 to 5.6

# remove old package of php 5.3 and Apache 2.2
sudo yum remove php httpd php-cli php-xml php-common httpd-tools
# install new package
sudo yum install httpd24 php56 mysql55-server php56-mysqlnd php56-mbstring
# optional install for other php dependencies
sudo yum install php56-opcache php56-mcrypt php56-gd php56-mbstring
# check version
php -v
apachectl -V
# start web server and config to run at system boot
sudo service httpd start
sudo chkconfig httpd on
# start mysql server and config to run at system boot
sudo service mysqld start
sudo mysql_secure_installation
sudo chkconfig mysqld on


Fix `-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory` warning

sudo vi /etc/environment
# add below two lines

Display Error in PHP

sudo vim php-5.6.ini
display_errors = On
sudo service httpd reload

Node JS and NPM Install


Install PHP Driver for Rockmongo

Apache Default Config

sudo vim /etc/httpd/conf.d/httpd.conf
sudo httpd -t
sudo service httpd reload
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D HTTPD_ROOT=”/etc/httpd”
-D SUEXEC_BIN=”/usr/sbin/suexec”
-D DEFAULT_PIDLOG=”/var/run/httpd/”
-D DEFAULT_SCOREBOARD=”logs/apache_runtime_status”
-D DEFAULT_ERRORLOG=”logs/error_log”
-D AP_TYPES_CONFIG_FILE=”conf/mime.types”
-D SERVER_CONFIG_FILE=”conf/httpd.conf”

Install phpMyAdmin

sudo yum --enablerepo=epel install phpmyadmin
sudo ln -s /usr/share/phpMyAdmin /data/webroot/uphpmyadmin

Webadmin Account Setup

# create user
sudo adduser webadmin
# set password
sudo passwd webadmin
# create webroot directory
sudo mkdir -p /data/webroot
sudo chown webadmin.webadmin /data/webroot
# change webroot owner for FTP access for wordpress
sudo chown -R apache:apache /data/webroot
# change home dir to webroot
sudo usermod -m -d /data/webroot webadmin
# change PasswordAuthentication to yes 
sudo vim /etc/ssh/sshd_config
# restart sshd
sudo service sshd restart
# add www groups for webroot
sudo groupadd www
sudo usermod -a -G www webadmin
sudo chown -R webadmin:www /data/webroot
sudo chmod 2775 /data/webroot
find /data/webroot -type d -exec sudo chmod 2775 {} +
find /data/webroot -type f -exec sudo chmod 0664 {} +

httpd.conf Sample

<VirtualHost *:80>
ServerName ec2–52–74–204–
DocumentRoot /data/webroot/
DirectoryIndex index.html index.php
<Directory "/data/webroot/">
AllowOverride All
Require all granted
<VirtualHost *:80>
DocumentRoot /data/webroot/
ErrorLog logs/superpowerlab.net_error_log
CustomLog logs/superpowerlab.net_access_log common
DirectoryIndex index.html index.php
<Directory "/data/webroot/">
AllowOverride All
Require all granted
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.superpowerlab\.net [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*)$1 [L,R,NE]

Wordpress Setup

# download latest source code
tar -xzvf latest.tar.gz
rm latest.tar.gz
# add apache to group www
sudo usermod -a -G www apache
# change owner to apache for file upload in wp-admin
sudo chown -R apache:www /data/webroot/
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.