How to Install Apache, PHP, PostgreSQL, MySQL in Ubuntu Server 17.04 from command line

Mini Bytes: Ubuntu 17.04 was released and most of the users are still struggling to install Apache, PHP, PostgreSQL or MySQL in the latest version of Ubuntu Server 17.04. Since Ubuntu 17.04 does not have GUI version (if needed we need to install the packages manually) we are going to install all the above mentioned packages through command line. I have tested all the below used commands in the Ubuntu Server 17.04 and i don’t tell that these commands may not work in another version of Ubuntu. You can try at your own risk in a non production server.

As the first step, we can see how to install and configure the web server and later on we can move to the further configurations. We need to install Apache at first because, later on while installing the database and the PHP server packages, they need to download the dependencies for the web server. To avoid any contingencies, as a first step we are installing the Apache Server.

How to install Apache:

While running the above command, it will ask for a confirmation whether to proceed install or to stop. You just need to give “Y” to proceed the installation.

Basic Apache Configuration:

After installing the Apache server, you need to adjust the firewall setting to allow port 80 & port 443 to access the web server. To do this you need to follow the below steps.

Running the above command will list the firewall applications like below.

here you need to select “Apache Full”, its because Ubuntu firewall will allow Port 80 & 443 while enabling this option. You can enable this option by running the command below.

After running the command successfully, make sure to check your Ubuntu firewall, whether it allows the “Apache Full” application. Below command can be used to check the status of the Ubuntu firewall.

Note: You can also disable the Ubuntu firewall for time-being to check the status of the Apache server. But it was not considered as a best practices. But i will give you the command to disable the firewall. “sudo ufw disable“. Running this command will disable the firewall from startup too.

After completing the above all task, you you need to restart the Apache service and check its status whether it was running status.

In order to enable Apache service to start at the startup, you need to enable the service using the systemctl command.

Its all done, not you can access your web server using the server’s IP address.

Config file location:

In order to make changes to you Apache server you need to change the default configurations in the config file. Regarding the configurations i will share you in another post. Below is the config file locations.

  1. /etc/apache2/apache2.conf -> Apache global configuration file.
  2. /etc/apache2/ports.conf -> Apache port configuration file.

Logs file location:

  1. /var/log/apache2/access.log -> Apache access log.
  2. /var/log/apache2/error.log -> Apache error log.

How to Install PHP 5.6:

Since PHP 5.6 is the stable version and contains most of the library files in this article i am going to show you how to install PHP 5.6 in the Ubuntu Server 17.04. Trust me we can use PHP 7 but we are still lack of many library files for the latest version of the PHP. They are still in development basis. For all my web projects i am still using PHP 5.6 only.

Above command will add the respected repositories inĀ  your server and later after doing an update, you can install the PHP 5.6. In order to install the PHP 7.1, you need to run first 3 command in your Ubuntu server and later on you need to run the below command to install the latest version of PHP.

After successfully completing the installation of PHP, in order to check the PHP version simple run the below command.

Now both your Apache and PHP server was ready to use.

How to Install PostgreSQL in Ubuntu:

PostgreSQL is one of the most powerful database system which was used in most of the enterprise currently.

You may also like...

4 Responses

  1. angelita says:

    Thanks for this post man…you saved my life…

  2. alexandria says:

    I am not sure why i am getting error while installing Apache and PHP…May be your way of installaling will be helpful i think so…thank you..

  3. virgilcreed says:

    Hi my friend! I wish to say that this post is amazing, great on LAM installation in Ubuntu..thank you..

  4. antonetta says:

    Can you make content for the latest version of Ubuntu 18.04…

Leave a Reply

Your email address will not be published. Required fields are marked *

three × 4 =