How to Install LAMP Stack on CentOS 7

Type 'c' to clear the current input statement.mysql> show databases;+——————–+| Database |+——————–+| information_schema || mysql || performance_schema || sys |+——————–+4 rows in set (0.00 sec)mysql> exit;ByeP — PHPPHP: Hypertext Preprocessor is a server-side scripting language designed for Web development and we going to install in our CentOS 7 Server.Enable Remi repository:# sudo yum install epel-release yum-utils# sudo yum install PHP7.2 from Remi repository:# sudo yum-config-manager –enable remi-php72Next, is to install PHP7 with common modules — I refer to Laravel Framework required PHP Extensions.# sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd php-openssl php-mbstring php-pdo php-bcmathOnce you are done, you can verify PHP7 installation:# php –versionPHP 7.2.13 (cli) (built: Dec 8 2018 12:11:34) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.13, Copyright (c) 1999-2018, by Zend TechnologiesYou can also verify PHP extensions installed — in my case, I need to make sure all PHP extensions required by Laravel i installed.Verify the following modules is installed by run php -m:OpenSSLPDOMbstringTokenizerXMLCtypeJSONBCMathLastly, make sure to restart your Apache service:# sudo systemctl start httpd.serviceSince we already installed Apache, let’s try something that showing the PHP is work when accessing from the browser.Create a new file /var/www/html:# touch /var/www/html/i.phpAdd the following in /var/www/html/i.php:<?php phpinfo(); ?>Hit your browser http://[ip-address]/i.php and you should see PHP7 loaded.PHP 7.2.13Once you are done verify it’s correct, do remove the file:# rm /var/www/html/i.phpGitGit is one of the Version Control System, VCS exist and most of the software development these days MUST have VCS over their codes..Else, it would be nightmare, in case of losing the codes, or try to rollback, or even to track changes made to the codes.To install Git:# sudo yum install gitVerify the installation:# git –version git version last stack we need these days, is dependency manager — in our stack is the PHP dependency manager — Composer.Back in the old days, I use to go to websites, to download the PHP package, require the file, and use the package..Sometimes the package just break, did not work as expected due to not meet the version or requirement of the package.With Composer available, with single command, we will get the package we want, with correct dependency.To be honest, the first time I use Composer it’s like, whaddaaa…how?.why? hard..but time flies..Now I manage to create my own PHP packages, even for Laravel frameworks — you may visit here..Cleanique Coders is a business I registered in 2016, for software development and training services related to software development, hence the Github account for it created..Most of packages created I do keep it there.So here the installation:# php -r "copy('', 'composer-setup.php');"# php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"# php composer-setup.php# php -r "unlink('composer-setup.php');"# mv composer.phar /usr/local/bin/composerAll the above commands will download the composer-setup.php file and verify the installer and run the installer..Once installed, it will remove the installer and make composer.phar available globally.Verify the installation:# composer –versionComposer version 1.8.0 2018-12-03 10:31:16RedisThe last part of this story, is Redis.Previously, I did not know anything about Redis and it purposes..Until I get my hands on Laravel..Exploring Laravel and ended up using Redis.Redis is good for you cache, reduced the I/O, connection to database by using in-memory key-value — it won’t store in any files or database, just memory, RAM.Other than use for cache, it can be use for session management like in Laravel.To install Redis:# sudo yum install redisStart the Redis:# sudo systemctl start redisCheck Redis status:# sudo systemctl status redis● redis.service – Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d └─limit.conf Active: active (running) since Wed 2019-01-02 06:00:27 UTC; 56s ago Main PID: 9810 (redis-server) CGroup: /system.slice/redis.service └─9810 /usr/bin/redis-server 02 06:00:27 centos-server systemd[1]: Starting Redis persistent k…Jan 02 06:00:27 centos-server systemd[1]: Started Redis persistent ke…Hint: Some lines were ellipsized, use -l to show in full.Now you are done setting up Redis in CentOS server..Do head to Redis documentation for it’s usage.SummaryNowadays web development is not just LAMP stack, you need other stack of technologies as well — in our case it’s Git, Composer and Redis.To have proper stack for the right tasks, is important and critical.And of course, my setup is not the only option we can use.. More details

Leave a Reply