After ordering Linux VPS Hosting the VPS will automatically start with the Apache web server installed and running. While this is a great first step, most functional platforms also include MySQL and PHP. This article provides the steps needed to install MySQL and PHP on your new VPS.
Step 1 – Update the VPS
First, lets take a moment to update the packages on the VPS.
1. Login to your VPS using an SSH client like terminal on a mac or putty on windows.
# ssh root@your_ip_address
Where your_ip_address is the IP address assigned to your VPS. You will be prompted to supply your root password. The root password can be found in the customer control panel at https://cp.infoquest.com, under information for the VPS subscription.
2. Issue the command for yum to to update your VPS packages
# yum update
You will be prompted to confirm the download and installation of the updates
YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems.
Step 2 – Install MySQL and Configure Security Settings
From your command line enter:
# yum install mysql-server
Confirm the download and installation at the prompt.
Once the installation completes start MySQL
# service mysqld start
Next, set a root password for MySQL and finish the automated setup.
The prompt will ask you for your current root password.
Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.
Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.
CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
Step 3 – Install PHP with MySQL Support
PHP is an open source web scripting language that is widely used to build dynamic webpages.
To install PHP on your virtual private server, open terminal and type in this command:
# yum install php php-mysql
Once you answer yes to the prompt PHP will be installed
PHP also has a variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:
# yum search php-
A list of available libraries and modules will be displayed. For more information on a specific module type:
# yum info name-of-module
To install a particular module:
# yum install name-of-module
Step 4 – Automatically Start Apache and MySQL
We should also set the processes to run automatically when the server boots (php will run automatically once Apache starts):
# chkconfig httpd on
# chkconfig mysqld on
Step 5 – Test Your PHP Installation
Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info page
To set this up, first create a new file:
In this article we use nano to create / edit a file. Nano is not installed by default on your VPS, but can easily be installed using the command
# yum install nano
Once nano is installed
# nano /var/www/html/info.php
Add the following lines:
Then Save and Exit.
Visit the page in a web browser to view PHP configuration information for your VPS
Where your_ip_address is the IP address assigned to your VPS
Step 6 – Restart Apache
Restart Apache so that all of the changes take effect on your virtual server:
# service httpd restart
Congratulations you have successfully installed a LAMP stack (Linux, Apache, PHP, MySQL)