In this article you will learn installing apache php mysql by following the steps below.
First you need to open ssh client. Then login
To install apache Run the command
sudo apt-get update
sudo apt-get install apache2
Set Global ServerName to Suppress Syntax Warnings
sudo apache2ctl configtest
sudo nano /etc/apache2/apache2.conf
Since we added the global ServerName directive, all you should see is:
Restart Apache to implement your changes:
sudo systemctl restart apache2
Adjust the Firewall to Allow Web Traffic
sudo ufw app list
If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:
sudo ufw app info "Apache Full"
Go to your http://your_server_IP_address
An alternative method is to use the curl utility to contact an outside party to tell you how it sees your server. You can do this by asking a specific server what your IP address is:
sudo apt-get install curl
Step 2: Install MySQL
sudo apt-get install mysql-server
You need to set mysql password for root
When the installation is complete, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Start the interactive script by running:
Step 3: Install PHP
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
In most cases, we’ll want to modify the way that Apache serves files when a directory is requested. Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. We want to tell our web server to prefer PHP files, so we’ll make Apache look for an index.php file first.
sudo nano /etc/apache2/mods-enabled/dir.conf
To enable remote access for your mysql run the below command
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'Password' WITH GRANT OPTION;
Finally you need to restart apache2
sudo systemctl restart apache
We can also check on the status of the apache2 service using systemctl:
sudo systemctl status apache2
Install PHP Modules
apt-cache search php- | less
To get more information about what each module does, you can either search the internet, or you can look at the long description of the package by typing:
apt-cache show package_name
To Install a package
sudo apt-get install package1 package2 …
Step 4: Test PHP Processing on your Web Server
In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:
sudo nano /var/www/html/info.php
To Check The address you want to visit will be:
This page basically gives you information about your server from the perspective of PHP. It is useful for debugging and to ensure that your settings are being applied correctly.
If this was successful, then your PHP is working as expected.
You probably want to remove this file after this test because it could actually give information about your server to unauthorized users. To do this, you can type this:
sudo rm /var/www/html/info.php
Hope, this article help you to install apache php mysql properly. Check out Cakephp Important Commands here.