fbpx

To get an in-depth knowledge on Apache Web Server, please visit, this.

As for now let us begin up setting shop with the one and only Apache Server, in this guide I’ll show you how to install Apache, how to run it, and begin your site.

So, follow along with me in the video as below, and to copy and paste the commands please visit just below the video.

INSTALL APACHE

Step 1 – As usual, installing Apache webserver on Ubuntu is as easy as a piece of cake. By default, Ubuntu has included the package and it is available in default repository. Just issue following command :

1
apt-get install apache2

Do not forget to always answer Y when asked.

Step 2 – Now let’s enable Apache2 service and start it.

1
2
systemctl enable apache2
systemctl start apache2

Step 3 – Verify the status of Apache whether it has run properly or not.

1
systemctl status apache2

Step 4 – Open up your favorite web browser (e.g: Firefox) and access your server through the IP address. You should then see Apache’s default page.

INSTALL MARIADB SERVER

Assuming that you use fresh Ubuntu server, so I’ll go straight forward with the steps. Otherwise, if you have MySQL running then you have to firstly stop and remove its service.

Step 1 – Again, we can simply use apt-get command because its package is available in default repository.

1
apt-get install mariadb-server

Step 2 – During the process, you may be asked to enter database root password. Remember, database root user is not the same as your server root user. Therefore, it is always a good idea to have different password set for each. However, if the system does not ask you to define database root password for MariaDB, then you can simply issue following command :

1
mysql_secure_installation

Step 3 – You’ll be asked to answer a series of questions.

INSTALL PHP7

Step 1 – Before we install it, let’s firstly update your apt database :

1
apt-get update -y

Step 2 – Now let’s install PHP7 on your Ubuntu 16.04 server plus few of its common PHP7 modules:

1
apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0

The command above will automatically install following packages : php7.0, libcurl3, php-common, php7.0-cli, php7.0-common, php7.0-opcache, php7.0-readline, php7.0-cgi, php7.0-curl, php7.0-mysql, and soon.

Step 3 – Verify that you have truly installed php 7 by issuing this command :

1
php -v

Step 4 – Now create a PHP test file :

1
vi /var/www/html/testphp.php

Note: Press “i”, to get into insert mode, “Esc” to get out of insert mode, then “:wq” to write and exit the file.

Step 5 – Then put this code :

1
2
3
<?php
phpinfo();
?>

Do not forget to hit Control+O to save the file and Control+X to exit Nano editor.

Step 6 – Now open up your web browser again and try accessing that file :

http://x.x.x.x/test.php

Step 7 – Now install this additional php module :

1
apt-get install libapache2-mod-php

Now restart apache2 service and try it again on your browser

1
service apache2 restart

That’s all. From this point your server is basically ready to use. What’s next to do is simply creating virtual hosts file to add your website on it.

Categories: Tutorials

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.