Serie: Sharedhosting to VPS. Create date: 16-09-2017
Next it's time to install PHP and MySQL. I will start with the minimal settings and make more changes along the way. Remember that this is the first time I'm doing this from start to finish so please let me known if I'm doing stupid things.
PHP
PHP is not installed by default I found out when I created a PHP file and tried to view it in my browser. We can install PHP and some extra modules with this command:
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Yes my PHP file is now being parsed. For me this is really cool because I can finally use PHP 7 now, my shared hosting site runs on PHP 5.4. This is going to give my site a small speed boost and I can finally use some nice new features. On the other hand, it’s more work to get my website up and running on my VPS but that’s not a problem of course.
A fellow worker told me that I could use an even higher PHP version but advised me not to do this because this is a hassle and you get new versions with the update/upgrade commands over time.
Now I want to give PHP files priority over HTML files. I changed this file and moved index.php to the top:
sudo nano /etc/apache2/mods-enabled/dir.conf
sudo systemctl restart apache2
I also want to install an extra PHP module. You can show a list of all available modules with this command:
apt-cache search php- | less
Use this command to find more information about the module:
apt-cache show php-cli
CLI is an abbreviation for command-line interface and this is something that I really need so I used this command to install this:
sudo apt-get install php-cli
There might be more PHP modules that I should install but I will do this along the way.
MySQL
Now it’s time to install MySQL with this command:
sudo apt-get install mysql-server
You’ll be asked to enter a password. Of course I used a strong password and also added it to KeePass. In the blog that I use as a manual they mention a script which you can use to secure some things, that sounds good so let’s try this. Another thing that you just have to know this exists.
mysql_secure_installation
Next you’ll be asked to install a password validation plugin. I chose not to because I always use strong passwords. After this I answered “no” to the question to change the root password because I’ve just set it. After this I answered all the other questions with “Yes”.
In a later blog I’m going to change some more MySQL settings.
Sources
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04