Modul 16-WebServer On VPS
Modul 16-WebServer On VPS
04 VPS or Dedicated
Server
Prerequisites
An Ubuntu 18.04 VPS plan.
A non-root user that can perform sudo tasks.
Press ‘Y’ when you are prompted to confirm the Apache installation.
Once the installation is complete, enter your VPS machine public IP address on your
browser. You should see the default Apache web page as shown below:
1. $ sudo mysql_secure_installation
You will be taken through a series of questions. The prompts will allow us to set a
password policy and root password. We will also be prompted to remove the
anonymous user, test database and disable remote login as shown below.
1. VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security.
It checks the strength of password and allows the users to set only those passwords which
are secure enough. Would you like to setup VALIDATE PASSWORD plugin?
2.
3. Press y|Y for Yes, any other key for No: Y
4.
5. There are three levels of password validation policy:
6.
7. LOW Length >= 8
8. MEDIUM Length >= 8, numeric, mixed case, and special characters
9. STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
10. Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
11.
12. Please set the password for root here.
13. New password:
14. Re-enter new password:
15. Estimated strength of the password: 100
16.
17. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key
for No) : Y
18.
19. By default, a MySQL installation has an anonymous user, allowing anyone to log into
MySQL without having to have a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother. You should remove them before
moving into a production environment.
20.
21. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
22. Success.
23.
24. Normally, root should only be allowed to connect from 'localhost'. This ensures that
someone cannot guess at the root password from the network.
25. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
26. Success.
27.
28. 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
environment.
29.
30. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
31.
32. - Dropping test database...
33. Success.
34. - Removing privileges on test database...
35. Success.
36.
37. Reloading the privilege tables will ensure that all changes made so far will take effect
immediately.
38.
39. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
40.
41. Success.
42. All done!
You can now try login on your MySQL server by typing the command below:
1. $ sudo mysql -u root -p
Please note, you will be prompted to enter the root password that you created earlier on
this guide.
Testing PHP
We can test our PHP installation by creating a file on the root folder of our website. To
do this, type the command below:
1. $ sudo nano /var/www/html/info.php
Then copy paste the text below and click CTR+X and Y to save the file.
1. <?php
2.
3. phpinfo();
4.
5. ?>
Restart Apache
We need to restart Apache for the changes to take effect using the command below:
1. $ sudo systemctl restart apache2
Next, visit the php info file we created above on your browser via your server’s public IP
address. For example, if your IP address is 111.111.111.111 enter the below text on
your browser
1. 111.111.111.111/info.php
Output
You should see the PHP information file as shown below:
Conclusion
Those are the basic steps of installing Apache, MySQL, and PHP on your server. You
can now go ahead and install a graphical user interface for your database (e.g.
phpMyAdmin) to better manage your databases. With the LAMP stack, running your
dynamic websites is a breeze.
Reference: https://hostadvice.com