Installing LAMP (Linux Apache MySQL and PHP) Stack on CentOS 7 64bit
A "LAMP" stack is a group of open source software built together to enable hosting of websites, applications & databases. The term "LAMP" is used to identify it as Linux, Apache, MySql and Php.
In this tutorial will help you install and configure the LAMP stack on a CentOS 7 6bit server.
Prerequisites
We will need the following to be able to successfully setup an LAMP Server on Ubuntu:
- An CentOS 7 x64 VPS server
- Root Access to the server
- An SSH client (You can download Putty[1] or Bitvise[2] depends on your operating system and liking)
When you have all this ingredients we can now start setting up our LAMP Server. Please follow the guide carefully, remember, you can always copy and paste the commands below for ease of installation and configuration.
Installing Apache
The apache web server is the most popular web server in the world. It is a product of the collaboration of many developers worldwide to develop a feature rich, open-source http web server.
We will start by typing the below command:
sudo yum -y install httpd
That's it! your web server is installed, now you would want to run and enable it on startup it by the commands.
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
Now go to your browser and type in the ip of your server. You should see the below information:
Installing MySql-Server (MariaDB)
Now we will install MariaDB. It is a fork of the Mysql-Server originally from the developers of MySql itself, it is the most used sql server worldwide and is currently being used by major websites such as facebook, Wikipedia and more.
To start installing MariaDB, we issue the command:
sudo yum install mariadb-server mariadb
Then we can start mariaDB with.
sudo systemctl start mariadb
MariaDB will now run, so we will make sure to secure our server by running a script to update our passwords.
sudo mysql_secure_installation
As a newly installed server we still don't have root password for the database so we have to create one. make sure to read each succeeding instructions carefully.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y
... Success!
Disallow root login remotely? [Y/n] y
... Success!
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!
Thanks for using MariaDB!
We will want to enable MadiaDB on boot so we execute the command.
sudo systemctl enable mariadb.service
Installing PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
We will need php so we can interact with our database, collecting data, access control, user interactions and many more. We will start by installing the basic php modules.
sudo yum install php php-mysql
That modules should communicate with any database programs you will make later on, for now we will have to restart apache for the changes to be reflected.
sudo systemctl restart httpd.service
Installing other PHP modules
In order for us to install php modules we must know the name of the module and the purpose of it. So we will look for modules that we need by running the command.
sudo yum search php-
We will get a list of available modules to install just like in the below info:
php-whitehat101-apr1-md5.noarch : Apache's APR1-MD5 algorithm in pure PHP
php-xcache.x86_64 : Fast, stable PHP opcode cacher
php-xml.x86_64 : A module for PHP applications which use XML
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-xmlseclibs.noarch : PHP library for XML Security
php-xmpphp.noarch : XMPPHP is the successor to Class.Jabber.PHP
php-zendframework-zend-diactoros.noarch : PSR HTTP Message implementations
php-zendframework-zendpdf.noarch : Zend Framework ZendPdf component
php-zendframework-zendxml.noarch : Zend Framework ZendXml component
php-zetacomponents-base.noarch : Zeta Base Component
php-zetacomponents-console-tools.noarch : Zeta ConsoleTools Component
To know what is a module for we can execute.
sudo yum info php-zendframework-zendxml
Then you will see its version, size and information.
Name : php-zendframework-zendxml
Arch : noarch
Version : 1.0.2
Release : 2.el7
Size : 10 k
Repo : epel/x86_64
Summary : Zend Framework ZendXml component
URL : http://framework.zend.com/
License : BSD
Description : An utility component for XML usage and best practices in PHP.
To install it we will run.
sudo yum install php-zendframework-zendxml
You can install more modules as you need fit by just repeating the above commands.
Viewing Php Information
To see what php modules we have installed in our web server we have to create a php file in the web directory of apache. For this guide we will name it info.php.
Create a file in the directory /var/www/html/
with a filename of info.php.
sudo nano /var/www/html/info.php
Copy the below texts and save the file.
<?php
phpinfo();
?>
Now go to your browser and enter the ipaddress of your server followed by /info.php like below:
http://12.14.15.10/info.php
make sure to replace 12.14.15.10 with the ip of your web server.
You should be able to see your php information much like what I have below depending on your installed php modules.
Thats it! Now you have your newly installed web server running. You can now upload files and serve them to your clients and users.
We hope you enjoy learning and reading our guide. If you do, please do not forget to write a comment.
[1]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
[2]: https://www.bitvise.com/ssh-client-download
Related Tutorials
Setup and Configuration of OpenVPN Server on CentOS 7.2Setup a Master-to-Master Replication Between Two MariaDB Servers
Setup and Configuration of FreeRadius + MySql on Ubuntu 14.04 64bit
Install and Configure CSF (ConfigServer Firewall) on Centos7 64bit
Install Node.js on CentOS 7
comments (3)
VPSUser 001
- 7 years ago1
VPSUser 001
- 7 years ago1
Abigail Ava
- 7 years agoSometimes we get an error when we try to delete a File or a folder for no reason , but of course there is a reason.We have many damage file or blocked files. Do not worry if we want to remove the error files or too long path files from our system,here I suggest a smooth way.So use âLong path toolâ software and keep yourself.