DEV Community

Navdeep Singh
Navdeep Singh

Posted on

Steps to Launch new AWS EC2 Instance

Pre-setup:

  1. Select Ubuntu server.
  2. Create new key pair to connect with instance securely.
  3. After instance setup, connect with your instance
    1. Open an SSH client.
    2. Locate your private key file (keyname.pem). The wizard automatically detects the key you used to launch the instance.
    3. Your key must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 brand-nation.pem
    4. Connect to your instance using its Public DNS: ec2-12-345-678-91.compute-1.amazonaws.com
    5. Example: ssh -i "keyname.pem" ubuntu@ec2-12-345-678-91.compute-1.amazonaws.com

Setup:

  1. sudo apt-get update
  2. sudo apt-get dist-upgrade
  3. sudo apt-get install apache2
  4. sudo apt-get install mysql-server
  5. sudo mysql_secure_installation utility
  6. sudo apt-get install php libapache2-mod-php
  7. sudo adduser ubuntu www-data
  8. sudo chown -R www-data:www-data /var/www/html
  9. sudo chmod -R g+rw /var/www/html
  10. sudo mysql -u root -p
  11. sudo a2enmod rewrite
  12. sudo service apache2 restart
  13. sudo nano /etc/apache2/sites-available/000-default.conf
#Below “DocumentRoot /var/www/html” add the following lines:
<Directory “/var/www/html”>
AllowOverride All
</Directory>
Enter fullscreen mode Exit fullscreen mode

Common Issues:

  1. Assign security group to instance, so TCP, HTTP works
  2. Listing Directory Failed: Connect FTP via SFTP
  3. MYSQL permission issues (https://support.rackspace.com/how-to/installing-mysql-server-on-ubuntu/)
  4. Mysql extension is missing in php7 installation. Ubuntu 16.04 (sudo apt-get install php-mysql)

Start server and test:

sudo service httpd start
sudo service mysqld start
chkconfig --list httpd
Enter fullscreen mode Exit fullscreen mode

Top comments (0)