Topics Included:
-LAMP(Linux, Apache, MySQL,, PHP) Installation
-Hosting a site
-creating custom HTML Doc in directory.
-creating PHP Script
-Hosting custom domain in Linux server.
2. Oracle VM VirtualBox is cross-platform
virtualization software that allows users to
extend their existing computer to run
multiple operating systems including
Microsoft Windows, Mac OS X, Linux, and
Oracle Solaris, at the same time.
Here Click on Next and proceed.
Installing The Virtual Box
3. Once VitualBox is installed, we can create,
add or import new VMs using toolbar
buttons.
Installing The Virtual Box
4. Click New on Virtual Machine
toolbar and add details about
the new VM and required OS.
Installing Linux (Ubuntu) Server
Step 1:
5. Select the Base Memory and
Processors to be allocated to
the Virtual Machine.
Installing Linux (Ubuntu) Server
Step 2:
6. Select the size of memory to
be allocated for Virtual Hard
Disk.
Installing Linux (Ubuntu) Server
Step 3:
7. This is the interface for the
newly created Virtual Machine
for Ubuntu Server.
Select Server and Press on
Start to run the Virtual
Machine.
Installing Linux (Ubuntu) Server
Step 4:
8. Press Enter to install Ubuntu
Server.
Installing Linux (Ubuntu) Server
Step 5:
9. Select the preferred language
and press Enter.
Installing Linux (Ubuntu) Server
Step 6:
10. Select the preferred keyboard
layout and its variant, select
Done once finished and press
Enter.
Installing Linux (Ubuntu) Server
Step 7:
11. Select the preferred Base for
the installation, select Done
once finished and press Enter.
Installing Linux (Ubuntu) Server
Step 8:
12. Select the preferred network
connection for the server to
connect with other machines,
select Done once finished and
press Enter.
Installing Linux (Ubuntu) Server
Step 9:
13. Select the proxy address if
needed, select Done once
finished and press Enter.
Installing Linux (Ubuntu) Server
Step 10:
14. Select the archive for Ubuntu,
select Done once finished and
press Enter.
Installing Linux (Ubuntu) Server
Step 11:
15. Configure the storage/ disk
space for the server(you can
change or select the default
value selected at the beginning
of the installation), select Done
once finished and press Enter.
Installing Linux (Ubuntu) Server
Step 12:
16. Configure the storage/ disk
space for the server(you can
change or select available
space and used spaces), select
Done once finished and press
Enter.
Installing Linux (Ubuntu) Server
Step 13:
17. Setup the profile for the user
that includes username,
password, server’s name etc,
select Done once finished and
press Enter.
Installing Linux (Ubuntu) Server
Step 14:
18. Setup OpenSSH to allow
remote access to the server,
select Done once finished and
press Enter.
Installing Linux (Ubuntu) Server
Step 15:
19. Select the required snaps
(Enter Space to select/deselect
particular snaps), select Done
once finished and press Enter.
SNAP:
A snap is an application
containerized with all its
dependencies.
Installing Linux (Ubuntu) Server
Step 16:
20. The installation of the server
starts, it may take few mintues
depending upon our setup,
once finished select Reboot
Now and press Enter.
Installing Linux (Ubuntu) Server
Step 17:
21. Once the server reboots it will
ask us for Login Credentials,
enter the credentials set at the
beginning of the installation
and press Enter.
The given screen will appear
once the credentials match.
Installing Linux (Ubuntu) Server
Step 18:
22. Now we will update and
upgrade the server.
To Update & Upgrade:
$ sudo apt update
$ sudo apt upgrade -y
Installing Linux (Ubuntu) Server
Step 19:
23. Now we will install Apache in
the server.
To install Apache :
$ sudo apt install apache2
You will be prompted to
confirm Apaches installation by
pressing Y, then Enter.
Installing APACHE
Step 20:
24. Once the installation is
finished, we need to adjust
firewall settings to allow HTTP
traffic.
UFW has different application
profiles that you can leverage
for accomplishing that. To list
all currently available UFW
application profiles
we can run:
$ sudo apt install apache2
.
Installing APACHE
Step 21:
25. Meaning of the profile:
• Apache : This profile opens ony port 80.
• Apache Full : This profile opens both port 80
and port 443.
• Apache Secure : This profile opens ony port 443.
To allow traffic on port 80, we will use Apache
profile as:
$ sudo ufw allow in "Apache“
Now we will verify the profile change by :
$ sudo ufw status
Installing APACHE
Step 22:
26. We can do a spot check right away
to verify that everything went as
planned by visiting our server’s
public IP address in our web
browser. We will see the default
Ubuntu Apache page.
In my case, public ip is :
http:// 192.168.1.76
.
Installing APACHE
Step 23:
27. Now that we have a web server
up and running, we need to
install the database system to
be able to store and manage
data for our site.
we can run:
$ sudo apt install mysql-server
When prompted confirm the
installation by typing Y and then
Enter.
.
Installing MySQL
Step 24:
28. When we’re finished, test if
we’re able to log in to the MySQL
console by typing:
$ sudo mysql
This will connect to MYSQL
server as root user. We will see
an output as in the figure.
To exit the MySQL console, type:
mysql>exit
Installing MySQL
Step 25:
29. PHP is the component of our setup
that will process code to display
dynamic content to the final user.
$ sudo apt install php libapache2-
mod-php php-mysql
Here we install package such as:
• php-mysql: allows php to
communicate with MySQL—
based databases.
• libapache2-mod-php: enables
Apache to handle PHP files.
When prompted confirm the
installation by typing Y and then
Enter.
Installing PHP
Step 26:
30. Create the directory for ost_project as follows:
$ sudo mkdir /var/www/ost_project
We assign ownership of the directory with $USER
that will reference the current system user.
sudo chown -R $USER:$USER /var/www/ost_project
Creating a Virtual Host for Website
Step 27:
31. We open a new configuration file in Apache’s
sites-available directory using :
$ sudo nano /etc/apache2/sites-
available/ost_project.conf
We will enter the bare-bones configurations on
the newly created blank file.
Now we save and close the file when we’re
done. When we are using nano, we can do it by
pressing CTRL+X, then Y, and ENTER.
Creating a Virtual Host for Website
Step 28:
32. Now, We will use a2ensite to enable the virtual
host.
$ sudo a2ensite ost_project
We will disable Apache’s default website by:
$ sudo a2dissite 000-default
To make sure our configuration file doesn’t
contain syntax error, we run:
$ sudo systemctl reload apache2
Creating a Virtual Host for Website
Step 29:
33. Now, our new website is active, but the web-root
/var/www/ost_project is still empty. So we will create
an index.html file in that location and test the host if it
works as expected.
$ nano /var/www/ost_project/index.html
Now, we include the content on this file
as shown in the 2nd figure.
Creating a Virtual Host for Website
Step 30:
34. Now, we access our server’s domain name or IP
address once again from our browser and check
if Apache ‘s virtual host is working as expected.
In my case IP address is :
http://192.168.1.77
If we can see this page it means our Apache
virtual host is working fine.
Creating a Virtual Host for Website
Step 31:
35. Now, we’ll create a PHP test script to confirm
that Apache is able to handle and process
requests for PHP files.
We will create a new file named info.php inside
our common web folder as:
$ nano /var/www/ost_project/info.php
This will open a blank file. We will as valid php
script as shown in figure , in the file.
Testing PHP Processing on our Web Server
Step 32:
36. Once the file is saved, we will test the script by
accessing the server’s domain name or IP
address as
http://192.168.1.77/info.php
If we can see this page, PHP processing on our
Web Server is working as expected.
Testing PHP Processing on our Web Server
Step 33: