Friday, October 4, 2019

Install Apache2, MySQL, PHP, phpMyadmin, aktivasi page phpMyadmin On Ubuntu 19

1. Install Apache

First of all, update Ubuntu server using commands :
Login with root :
apt update
apt upgrade
Next, install Apache web server :
apt install apache2
Check if Apache web server is running or not :
systemctl status apache2
Sample output would be:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2019-10-04 06:24:08 UTC; 11min ago Docs: Process: 21511 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 21531 (apache2) Tasks: 7 (limit: 4648) Memory: 20.9M CGroup: /system.slice/apache2.service ├─21531 /usr/sbin/apache2 -k start ├─21532 /usr/sbin/apache2 -k start ├─21533 /usr/sbin/apache2 -k start ├─21534 /usr/sbin/apache2 -k start ├─21535 /usr/sbin/apache2 -k start ├─21536 /usr/sbin/apache2 -k start └─21537 /usr/sbin/apache2 -k start Oct 04 06:24:08 xbox-01 systemd[1]: Starting The Apache HTTP Server... Oct 04 06:24:08 xbox-01 apachectl[21511]: AH00558: apache2: Could not reliably determine the server's fully quali Oct 04 06:24:08 xbox-01 systemd[1]: Started The Apache HTTP Server.
Now, open your web browser and access Apache test page by navigating to
http://localhost/ or http://IP.ADDRESS -

2. Install MySQL

To install MySQL On Ubuntu, run :
apt install mysql-server
Verify if MySQL service is running or not using command :
systemctl status mysql
Sample output :

root@xbox-01:~# systemctl status mysql
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-10-03 15:03:47 UTC; 15h ago
 Main PID: 4849 (mysqld)
    Tasks: 28 (limit: 4648)
   Memory: 176.6M
   CGroup: /system.slice/mysql.service
           └─4849 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/

Oct 03 15:03:46 xbox-01 systemd[1]: Starting MySQL Community Server...
Oct 03 15:03:47 xbox-01 systemd[1]: Started MySQL Community Server.
Mysql is running!


By default, MySQL root user password is blank. You need to secure your MySQL server by running the following script :
If your answer is Yes, you will be asked to choose the level of password validation.

The available password validations are lowmedium and strong. Just enter the appropriate number (0 for low, 1 for medium and 2 for strong password) and hit ENTER key.

Now, enter the password for MySQL root user. Please be mindful that you must use password for mysql root user depending upon the password policy you choose in the previous step. If you didn’t enable the plugin, just use any strong and unique password of your choice.
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

For the rest of questions, just type y and hit ENTER. This will remove anonymous user, disallow root user login remotely and remove test database.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...

- Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!

Run the following command at the mysql prompt to find the current authentication method for all mysql user accounts :
SELECT user,authentication_string,plugin,host FROM mysql.user;
Change this authentication to mysql_native_password method.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'isipassword';
Update the changes using command :
Now check again if the authentication method is changed or not using command :
SELECT user,authentication_string,plugin,host FROM mysql.user;

Good! Now the myql root user can authenticate using password to access mysql shell.
Exit from the mysql prompt :

2. Install PHP

To install PHP, run :
apt install php libapache2-mod-php php-mysql
After installing PHP, create info.php in folder /var/www/html/ 
Let us create info.php file in the apache root folder:
nano /var/www/html/info.php
Add the following lines :
Press CRTL X Y to save and quit the file. Restart apache service to take effect the changes.
systemctl restart apache2

Open up your web browser and navigate to http://IP-address/info.php

Usually, when a user requests a directory from the web server, Apache will first look for a file named index.html. If you want to change Apache to serve php files rather than others, move index.php to first position in the dir.conf file as shown below
nano /etc/apache2/mods-enabled/dir.conf
Here is the contents of the above file.
<IfModule mod_dir.c>
        DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Move the “index.php” file to first. Once you made the changes, your dir.conf file will look like below.
<IfModule mod_dir.c>
        DirectoryIndex index.php index.cgi index.html index.xhtml index.htm

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Press CRTL X Y to save and quit the file. Restart apache service to take effect the changes.
systemctl restart apache2

To improve the functionality of PHP, you can install some additional PHP modules.
To list the available PHP modules, run :
apt-cache search php- | less
apt-cache show php-gd
To install a php module run :
apt install php-gd
To install all modules (not necessary though), run :
apt-get install php*
After Then
systemctl restart apache2

2. Install phpMyAdmin

Once you’ve setup LAMP stack, enable ‘universe’ repository, which is disabled by default on Ubuntu 19.  To do so, run :
add-apt-repository universe
Now is the time to install phpMyAdmin.
To install phpMyAdmin on Ubuntu 19, run :
apt update
apt install phpmyadmin php-mbstring php-gettext
Hit the TAB key to choose OK and again hit ENTER key to continue.

Hit ENTER to continue.

Choose Yes to configure database for phpmyadmin :

Provide mysql application password phpmyadmin. using the first password you set before.

Enter password :
Re-enter password :

Once phpmyadmin is installed, enable mbstring php extension and restart Apache service update the changes as shown below.
phpenmod mbstring
systemctl restart apache2
You can now verify if mbstring extension is enabled or not by loading into info.php file from the web browser. http://ip.address/info.php

To do so, login to mysql shell using command:
mysql -u root -p
Enter your mysql root password. You will now be in mysql shell.
Enter the following command to create a new dedicated user for phpmyadmin :
CREATE USER 'phpmyadminuser'@'localhost' IDENTIFIED BY 'isipassword';
Here, phpmyadmin is the new user for accessing phpmyadmin dashboard. The password for phpmyadminuser is isipassword. Replace these values with your own.
Next give the appropriate privileges to the ‘phpmyadminuser’ using command :
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadminuser'@'localhost' WITH GRANT OPTION;
Finally exit from mysql shell :

Before access phpMyAdmin dashboard http://IP.ADREESS/phpMyAdmin

Edit apache2.conf

nano /etc/apache2/apache2.conf

Then add the following line to the end of file : 

Include /etc/phpmyadmin/apache.conf

Then Restart apache2

systemctl restart apache2

Access phpMyAdmin dashboard

Open your web browser and navigate to :


Then Log in using root password.


Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons