Aws Apache Web Server



Apache has been the most popular web server on the Internet Apache HTTP Server httpd was launched in 1995 and it has been the most popular web server on the Internet since April 1996.Latest release from the 2.4.x stable branch represents the best available version of Apache HTTP Server. Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web. Apache is a very well known open-source Web Server. It is not only popular but also very old Web Server. Like any other Web Servers, Apache also accepts requests from the clients, search for the requested queries and then send the response back to them. Launching EC2 Instance on AWS.

  1. Aws Apache Web Server Login
  2. Apache Web Server Aws

Have you ever wanted to set up your own web server? I recently wanted to see the difference between setting up my own server and using a shared hosting solution. The problem was that I had no previous experience with Linux and had to learn everything from scratch. But I soon learned that Linux is not that complicated and installing web services is even more easy on Linux than on Windows Server.

Setting up your EC2 Instance on AWS

Start off by registering on Amazon AWS. For new users, you will get a free tier available for 12 months which means that you can use a Virtual Machine free for 12 months!

Now we want to create an EC2 Instance, so search for EC2 on the AWS services and open it up. Click Launch Instance and choose Amazon Linux AMI. Now you can select the desired hardware for your virtual machine. If you choose t2.micro, you will get it free for the first 12 months.
Choose Configure Instance Details, and on the next page, you can leave everything as default except for termination protection. This option is recommended to be turned on if you don’t want to accidentally delete your whole server. Click Next to add storage. Here, you can leave everything as default, the standard is 8GB General Purpose SSD. Extra storage can easily be added later. Skip tags and go directly to Configure Security Group.

On this page, you are basically choosing which ports you want to open. You will have to open these ports: HTTP port 80, HTTPS port 443 (if you want to use SSL), SSH port 22 and FTP port 20-21. HTTP and HTTPS must be opened to everyone, but you can set SSH and FTP to only be available to your own public IP; this is recommended to avoid brute force attacks. Now click Review and Launch, then click Launch again.

You are now prompted to create a new key pair and download it to a secure location on your own computer. This key pair is the only way to access your server, and if lost you will have a big problem, so I suggest you create at least one backup.

Your EC2 Instance should now be starting up for the first time which will take about 2-5 minutes. Go to Instances and you will see Instance State: Running when it is ready to use. If you want to have a static IP address, you will have to go to Elastic IP’s and Allocate a new address, then you have to associate the address with your new instance. If you skip this step, your virtual machine will get a new public IP on every reboot.

Now it’s time to connect to your server with a SSH client. In this guide, I will be using Putty on Windows 10.
Go here to download Putty and Puttygen. We will start off by using Puttygen to export our private key which is in .pem format to the compatible Putty format .ppk. Open up Puttygen and click Load and choose your private key, click Save private key and choose a name.
We are now ready to open Putty and add your EC2 server info. When Putty is open, you can start off by adding your IP address (find your IP under instances in the AWS console) and port (22), then go to Data and write ec2-user on Auto-login username, this is the standard username on Amazon Linux. Now you have to add your private key, open up SSH and select Auth, under Private key file just browse and choose your .ppk private key file. Everything should now be ready to connect. Just go to session and save your settings before you click Open. When you connect for the first time, you will get a security alert, just click Yes and you will get connected.

Installing Apache, MySQL and PHP

When you connect, you will see something like this:

First, I will explain some basic Linux commands so you can have some idea of what we are doing.
Remember, you can always use –help behind the command to get some more info.

sudo – Allow current user to execute a command as superuser. Use “sudo -i” to log in as superuser.
cd – Open folder FOR example cd /var/www/ you can ALSO use “cd ..” to go back.
ls – List files and folders.
mv – Move files or folders. Example “mv /var/www/index.php /etc/” will move the file to the folder “etc”.
cp – Copy files or folders. Example “cp /var/www/index.php /etc/” this will copy the file to the folder “etc”.
rm – Remove files or folders. Example “rm /var/www/index.php” this will remove index.php or if you are in the folder you can use “rm index.php”.
Use “rm -r” to remove folders.
mkdir – Create a directory. Example “mkdir /var/www/vhost”.
nano – Text editor. Example “nano /var/www/index.php” this will open index.php in nano text editor.

Aws Apache Web Server

We can start by typing “sudo yum update”. This will update some packages mostly for security reasons. Use “y” to answer yes when prompted.
We will now install Apache, Mysql and PHP packages.

Aws Apache Web Server Login

Start the Apache web server.

Make sure Apache starts automatically at system boot.

Now you can test if everything is working by typing your IP in a web browser.

The root that you now see is placed at this directory /var/www/html and this test page only appears when there is no content, so let’s create an index file to check if it works.

This will create an index.php file in your root folder for the Apache server. Copy and paste this content in the nano text editor. To paste, just press the right mouse button.

Press Ctrl+X then press y and enter to save the file.

Reload the page and you should see a white page with the text “Hello World. Check out this super cool site.”

Ownership and Permissions

If you want the ec2-user to be able to edit files in the www directory, you will have to do some configuring.
In this example, we want to create a www group that will have full permission on the www directory. Start by creating the www group.

Now we will add the ec2-user to the www group, -g means that you add the user to the specified group.

Now, exit and log back in again to verify your membership of the group. Just write “groups” and you should see something like this.

Change the ownership of the www directory to the group www.

Aws apache web server login

Check the ownership of the www directory and you should see something like this.

Now you’ll need to set some permissions if you want the www to have write permissions on the www folder type this.


Secure the MySQL server

We want to secure the MySQL server as it’s only set to a default development configuration. First, start the MySQL server and make sure it starts on boot.

Then start the mysql secure installation.

Just press Enter on password and press y to set a root password, press y to remove anonymous users, y to disallow root login remotely, y to remove test database, and finally, y to reload privilege tables. Your mysql server should now be ready to use.

Conclusion

You have now configured a fully functional apache web server with PHP and MySQL. The difference between running your website on your own virtual machine or using a shared hosting solution is big. There is no limit to what you can do, and you will most likely experience better performance. I will also go into possibilities to boost your website performance in future posts because there’s really a lot of possibilities out there. On the next post, I will explain how you can setup multiple websites on one server. I will also show you how to configure a SSL certificates for each domain.

Apache Web Server Aws

If you have any questions, don’t hesitate to ask in a comment or create a new topic in the Forum, see you!