LAMP stack is a group of open source software
used to get web servers up and running. The acronym stands for Linux, Apache,
MySQL, and PHP. Since the server is already running CentOS, the linux part is
taken care of. Here is how to install the rest.
Step 1—Install Apache
To install apache, open terminal and type in this command:
#yum install httpd
Once it installs, you can start apache running:
#service httpd start
That’s it. To check if Apache is installed, direct your browser to your
server’s IP address (http://Your-server-ip-adress). The page should display the
words “It works!".
Step 2—Install MySQL
To install MySQL, open terminal and type in these commands:
#yum install mysql-server
#service mysqld start
During the installation, MySQL will ask you for your permission twice.
After you say Yes to both, MySQL will install.
Once it is done
installing, you can set a root MySQL password:
sudo /usr/bin/mysql_secure_installation
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.
mysql> Enter current
password for root (enter for none):
OK, successfully used password, moving on...
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.
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.
Remove anonymous users? [Y/n] y
... Success!
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? [Y/n] y
... Success!
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.
Remove test database and access to it? [Y/n] y
- Dropping test
database...
... Success!
- Removing
privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes
made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If
you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Step 3—Install PHP
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 PHP prompt, PHP will be installed.
Step 4—RESULTS: See PHP on your Server
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:
# vi /var/www/html/info.php
Add in the following line:
<?php
phpinfo();
?>
Then Save and Exit.
Restart apache so that all of the changes take effect on your virtual
server:
sudo service httpd restart
Finish up by visiting your php info page (http://Your-server-ip-adress/info.php