Setting up CentOS 7 64-bit LAMP (Linux Apache MySQL and PHP) Stack
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.
Requirements
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)
Once you have gathered all the ingredients, we can proceed with the LAMP Server setup. Please follow the guide attentively, and feel free to utilize copy and paste for the commands provided to simplify the installation and configuration process.
Apache Installation Guide
The Apache web server stands as the world’s most widely used web server. This renowned product is the result of collaborative efforts from developers across the globe, aiming to create a feature-rich, open-source HTTP web server.
We will start by typing the below command:
sudo yum -y install httpd
Congratulations! Your web server is now installed. To run and enable it on startup, execute the following commands.
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
Navigate to your web browser and enter the IP address of your server. You should then observe the following information:
MySql-Server (MariaDB) Installation Guide
Next, we will install MariaDB. As a fork of the MySQL Server, originally developed by the creators of MySQL, MariaDB stands out as one of the most widely used SQL servers globally. It is currently employed by major websites, including Facebook, Wikipedia, and others.
To start installing MariaDB, we issue the command:
sudo yum install mariadb-server mariadb
Then we can start mariaDB with.
sudo systemctl start mariadb
Now that MariaDB is installed, we need to ensure the security of our server. Run a script to update and strengthen the passwords.
sudo mysql_secure_installation
Since this is a newly installed server, a root password for the database hasn’t been set yet. Follow the upcoming instructions attentively to create and secure the root password.
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
PHP Installation Guide
PHP, which stands for PHP: Hypertext Preprocessor, is a versatile open-source scripting language widely employed for web development. It can be seamlessly embedded into HTML.
To enable interactions with our database, manage data, control access, and facilitate user interactions, we need PHP. Let’s commence by installing the fundamental 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
Setting up 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.
Examining PHP Details
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.
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.
Congratulations! Your newly installed web server is now up and running. You can begin uploading files and serving them to your clients and users.
We trust that you find our guide informative and helpful. If you’ve enjoyed the learning experience, please take a moment to leave a comment.
[1]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
[2]: https://www.bitvise.com/ssh-client-download