How To Install Linux, Apache, MySQL, PHP on Ubuntu 16?

Linux Server Management Tips and Tricks
Post Reply
arnlweb
Site Admin
Posts: 92
Joined: Wed Jun 22, 2016 1:28 pm
Location: India
Contact:

How To Install Linux, Apache, MySQL, PHP on Ubuntu 16?

Post by arnlweb » Wed Sep 20, 2017 1:02 pm

Firstly Login into your server via SSH.

Run this command

Code: Select all

sudo apt-get update

Code: Select all

sudo apt-get install apache2
Open up the main apache configuration file and edit:

Code: Select all

sudo nano /etc/apache2/apache2.conf
Enter line at bottom

Code: Select all

ServerName you_server_IP_or_domain_name
After that reload Apache

Code: Select all

sudo systemctl restart apache2
Now, you can check Apache Syntax by typing,

Code: Select all

sudo apache2ctl configtest
Firewall Adjustment:

Install ufw

Code: Select all

sudo apt-get install ufw
And run...

Code: Select all

sudo ufw app list 

Code: Select all

sudo ufw app info "Apache Full"
Finally test your Apache installation.

http://IP_address_of_your_server

Install MySQL

Code: Select all

sudo apt-get install mysql-server
Set your mysql root password.

Install PHP

Code: Select all

sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Move "index.php" word in dir.conf file

Code: Select all

sudo nano /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

Should look like this:

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

Code: Select all

sudo systemctl restart apache2
You can check your Apache Status

Code: Select all

sudo systemctl status apache2
Install PHP Modules

Code: Select all

sudo apt-get install php-curl

Code: Select all

sudo apt-get install php-gd

Code: Select all

sudo apt-get install php-xml

Code: Select all

sudo apt-get install packagename1 packagename2
Enabling mod_rewrite if you want.

Code: Select all

sudo a2enmod rewrite

Code: Select all

<VirtualHost *:80>
    [i]<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>[/i]

Code: Select all

sudo systemctl restart apache2

Code: Select all

sudo nano /var/www/html/.htaccess
Add in .htaccess

Code: Select all

RewriteEngine on
Test PHP on your Web Server.

Code: Select all

sudo nano /var/www/html/info.php

Code: Select all

<?php
phpinfo();
?>
Save the file (Ctrl+X,Y,Enter)

http://IP_address_of_your_server/info.php
Attachments
phpinfo.png
phpinfo.png (111.41 KiB) Viewed 74 times

Post Reply