CentOS 7 how to install LAMP

With my new server I wanted to install LAMP stack so I can test WEB applications locally. Just to note that in CentOS 7 it is not exactly classic LAMP (Linux Apache MySQL PHP), but new LAMP ( Linux Apache MariaDB PHP).

As in most package oriented OS Installation of LAMP on CentOS 7 is generally simple and consist of running following commands:

0. Update you system and add EPEL repo

sudo yum update
sudo yum localinstall --nogpgcheck http://download.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm

1. Install packages

sudo yum install httpd mariadb-server mariadb php php-mysql php-gd php-pear php-xml php-bcmath php-mbstring php-mcrypt php-php-gettext

If you need additional php modules just add them.

2. Enable services

sudo systemctl enable httpd.service
sudo systemctl enable mariadb.service

3. Start services

sudo systemctl start httpd.service
sudo systemctl start mariadb.service

4. Secure MariaDB installation

sudo /usr/bin/mysql_secure_installation

5. Open firewall ports

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

5. Test components

To test PHP and apache installation create new php script

vi /var/www/html/phptest.php

Put following code inside:
< ?php phpinfo(); ?>

And visit your ip addres/phptest.php with a browser.

6. Install phpMyAdmin

sudo yum install phpMyAdmin

7. Configure phpMyAdmin to allow connections

vi /etc/httpd/conf.d/phpMyAdmin.conf

Comment out curent

<directory /usr/share/phpMyAdmin></directory>
 

And add

<directory /usr/share/phpMyAdmin>
        AllowOverride none
        Options none
        Require all granted
</directory>
 

Restart Apache
sudo systemctl restart httpd.service

and visit
your ip addres/phpMyAdmin

You should be able to login with you root account

Tagged with: , , , , ,

Leave a Reply