0% found this document useful (0 votes)
135 views24 pages

Install Apache, PHP and MySQL On CentOS 7 (LAMP)

Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Uploaded by

Aldo Enginer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views24 pages

Install Apache, PHP and MySQL On CentOS 7 (LAMP)

Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Uploaded by

Aldo Enginer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Log in or Sign up

Tutorials Tags Forums Linux Commands Subscribe ISPConfig News

 Tutorial search 

Home Install Apache, PHP And MySQL On CentOS 7 (LAMP)

There is a new version of this tutorial available for CentOS 7.6.

Install Apache, PHP And MySQL On CentOS 7


(LAMP)

This tutorial shows how This tutorial exists for these OS versions
you can install an
Apache2 webserver on a CentOS 7.6
CentOS 7.0 server with CentOS 7.4
PHP5 support (mod_php) CentOS 7.3
and MySQL support. CentOS 7
LAMP is short for Linux, CentOS 6.5
Apache, MySQL, PHP. CentOS 6.2

On this page

1 Preliminary Note
1 Preliminary 2 Installing MySQL / MariaDB
3 Installing Apache2
Note 4 Installing PHP5
5 Testing PHP5 / Getting Details About Your PHP5
In this tutorial, I use the Installation
hostname 6 Getting MySQL Support In PHP5
server1.example.com 7 phpMyAdmin installation
with the IP address 8 Links
192.168.0.100. These
settings might differ for
you, so you have to replace them where appropriate.

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 1/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

I will add the EPEL repo here to install latest phpMyAdmin as follows:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*


yum -y install epel-release

2 Installing MySQL / MariaDB

MariaDB is a MySQL fork of the original MySQL developer Monty Widenius. MariaDB is
compatible with MySQL and I've chosen to use MariaDB here instead of MySQL. To
install MySQL, we do install MariaDB like this:

yum -y install mariadb-server mariadb

Then we create the system startup links for MySQL (so that MySQL starts
automatically whenever the system boots) and start the MySQL server:

systemctl start mariadb.service


systemctl enable mariadb.service

Set passwords for the MySQL root account:

mysql_secure_installation

[root@server1 ~]# mysql_secure_installation


/usr/bin/mysql_secure_installation: line 379: find_mysql_client:
command not found

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): <--ENTER


https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 2/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

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]


New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing


anyone
to log into MariaDB 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] <--ENTER


... 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] <--ENTER


... Success!

By default, MariaDB 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] <--ENTER


- 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.
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 3/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Reload privilege tables now? [Y/n] <--ENTER


... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!


[root@server1 ~]#

3 Installing Apache2

CentOS 7 ships with apache 2.4. Apache2 is directly available as a CentOS 7.0
package, therefore we can install it like this:

yum -y install httpd

[root@server1 ~]# yum install httpd


Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.plusline.de
* extras: mirror.23media.de
* updates: mirror.23media.de
Package httpd-2.4.6-17.el7.centos.1.x86_64 already installed and
latest version
Nothing to do
[root@server1 ~]#

By default apache will be installed, if-not then please install it as shown above

Now configure your system to start Apache at boot time...

systemctl start httpd.service

systemctl enable httpd.service

In CentOS 7.0 uses Firewall-cmd, so I will customize it to allow external access to port
80 (http) and 443 (https).

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 4/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

firewall-cmd --permanent --zone=public --add-service=http


firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

Now direct your browser to http://192.168.0.100, and you should see the Apache2
placeholder page:

4 Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:

yum -y install php

We must restart Apache afterwards:

systemctl restart httpd.service

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 5/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

5 Testing PHP5 / Getting Details About Your PHP5


Installation

The document root of the default website is /var/www/html. We will now create a
small PHP file (info.php) in that directory and call it in a browser. The file will display
lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/html/info.php

<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as
shown in the Server API line. If you scroll further down, you will see all modules
that are already enabled in PHP5. MySQL is not listed there which means we don't
have MySQL support in PHP5 yet.

6 Getting MySQL Support In PHP5


https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 6/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

To get MySQL support in PHP, we can install the php-mysql package. It's a good idea
to install some other PHP5 modules as well as you might need them for your
applications. You can search for available PHP5 modules like this:

yum search php

Pick the ones you need and install them like this:

yum -y install php-mysql

In the next step I will install some common PHP modules that are required by CMS
Systems like Wordpress, Joomla and Drupal:

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc p


hp-mbstring php-snmp php-soap curl curl-devel

Now restart Apache2:

systemctl restart httpd.service

Now reload http://192.168.0.100/info.php in your browser and scroll down to


the modules section again. You should now find lots of new modules like curl etc
there.:

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 7/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

7 phpMyAdmin installation

phpMyAdmin is a web interface through which you can manage your MySQL
databases.
phpMyAdmin can now be installed as follows:

yum install phpMyAdmin

Now we configure phpMyAdmin. We change the Apache configuration so that


phpMyAdmin allows connections not just from localhost (by commenting out the
<Directory "/usr/share/phpmyadmin"> stanza):

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

[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 8/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>

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

[...]

Next we change the authentication in phpMyAdmin from cookie to http:

vi /etc/phpMyAdmin/config.inc.php

[...]
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication met
hod (config, http or cookie based)?
[...]

Restart Apache:

systemctl restart httpd.service

Afterwards, you can access phpMyAdmin under


http://192.168.0.100/phpmyadmin/:

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 9/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

8 Links

Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
CentOS: http://www.centos.org/
phpMyAdmin: http://www.phpmyadmin.net/

view as pdf | print

Share this page:

Suggested articles

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 10/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

63 Comment(s)
Add comment
Name * Email *

Submit comment

Comments

By: ShootDawg Reply

links at the bottom of the page, says 8, only 5 listed.


of the 5 listed, everything after php points to php.net instead of their desired target

By: Reply

Thnak you for pointing out the broken link targets, it is fixed now. 8 is the number of the chapter
here, not the number of the links.

By: Gavin Reply

The Fedora package has been upreved. It is now epel-release-7-1.noarch.rpm

By: Pudgy Reply

Hello, just wanted to let you know that you actually installed an old phpMyAdmin package. There are
two PMA packages, "phpmyadmin" which installs v2.11.11 and "phpMyAdmin" which installs v3.5.7. I
don't know if you wanted to use the old version intentionally, but I just thought that I'd point it out.

By: Reply

The tutorial has been updated to a newer phpmyadmin version now.

By: Reply

Why mariaDB and not mysql, or are they the same now ?

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 11/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

By: admin Reply

MariaDB is the free MySQL fork, MariaDB is compatible with MySQL and the commands from
MariaDB are still nemad "mysql" or "mysqldump", so there are no differences from the Client
side. All Major Linux Distributions replaced MySQL with MariaDB now, so we will use that for the
tutorials as well. Some users also Report that MariDB is faster then MySQL in the latest releases.

By: Anonymous Reply

FYI, this process installed PHP 5.4.16, not PHP 5.5.x:


# php -v
PHP 5.4.16 (cli) (built: Jun 10 2014 02:52:47)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

By: Erick Reply

Following the article, I just installed the phpMyAdmin-4.2.7.1.


And, after install, and doing the comments suggested in the lines of Directory for phpMyAdmin, it
doesn't show in the webpage. I did to include this lines to see it in the url:
<Directory "/usr/share/phpMyAdmin/">
Options Indexes
AllowOverride None
Require all granted
</Directory>
Any alternative?

By: Nick Reply

Thanks for the one stop instructions. Everything worked as expected. Very common setup for CMS
systems.
-nick

By: Ted van den Brink Reply

Step one, installing EPEL can be done by simply installing it with yum, since it is included in the
default repository;
yum install epel-release

By: Jonathan Reply

Strange, but true...


I could net get access to my new site after extracting it to the html folder until I disabled selinux.
I was able to access info.php no problem, but not index.php or / "root"

By: PatL Reply

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 12/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Thanks for this howtoforge LAMP/CentOS7


Just one point... which annoyed me; you should consider changing all MySQL terms by MariaDB... or
at least mention MySQL only as a reference and only once as it is not about installing MySQL at all
but MariaDB (MySQL has been thrown out by many Linux distros as of now) my 2 cents ... but again
thanks a lot for this howtoforge tutorial which saved me a lot of research time ;-)

By: Andries Ellis Reply

Nice Clear Instructions. Thanks!

By: Sumeet Shetty Reply

phpMyAdmin is not available in CentOS 7's default repository. before installing phpMyAdmin,
run sudo yum install epel-release

By: till Reply

See step one of the tutorial. It explains the installation of the epel repo.

By: Jamie Reply

phpMyAdmin Repo now at


rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
 

By: thanks Reply

I want to thank you very much for this very helpful tutorial, appreciate it, please don't stop writing
as you've a very good skills in explaining things :)

By: Eli Goldhar Reply

thanks man!!!
you don't know how much your tutorial helped me.
all the best dearest man :)

By: Eli Goldhar Reply

thanks man. You don't know how much your tutorial helped me.
All the best dearest man :)

By: Itamar Reply

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 13/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

great tutorial,
Thanks!!

By: Rich Reply

I was able to get this all installed and working. Only problem I am having is I cannot login to
phpmyadmin from my laptop to my headless CentOS server. It will not take my login credentials on
root, my regular user account, or leaving it blank. I can login to both the root and my user account
via my ssh connection to the server with no problem. But the same accounts will not work via the
web page. I get the prompt, but it just keeps reprompting me. Any ideas on what to check?

By: Jakke Reply

Use your MySQL/MariaDB password. You are not using your Linux login to access the database,
which you're trying to do with phpmyadmin

By: Anil Reply

Hi,
I'm getting below things while I'm trying to access phpmyadmin in GUI mode.
Forbidden
You don't have permission to access /phpMyAdmin on this server.

By: Carlos Reply

I'm having the same issue like you. Did you fix it?

By: Brian Reply

Great tutorial and very well-explained. Works perfectly if you follow all the steps. I did notice the link
for epel in step 1 is old. I used the latest one, 7.5, which is referenced elsewhere in these
comments. Also, when I commented out the section of code in phpMyAdmin, I could not log into it
from localhost, so I un-commented them since I likely would not be logging into phpMyAdmin from a
different machine anyway. Otherwise, Great stuff! Thanks a million!

By: uptoeleven Reply

If you comment out the entire


<Directory /usr/share/phpMyAdmin/>
then no-one can use phpMyAdmin - because the directory can't be served by Apache.
The correct approach as per http://stackoverflow.com/questions/23235363/forbidden-you-dont-
have-permission-to-access-phpmyadmin-on-this-server is to only comment out two "Require IP" lines
and replace them with a Require all granted thus:
<Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> #
Apache 2.4 <RequireAny> #Require ip 127.0.0.1 #Require ip ::1 Require all granted </RequireAny>
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 14/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

</IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow
from 127.0.0.1 Allow from ::1 </IfModule> </Directory>

By: mutwakel Reply

Strange, but true...

I could net get access to my new site after extracting it to the html folder until I disabled selinux.

I was able to access info.php no problem, but not index.php or / "root"


------------------------------------------------------------------------------------------
solve this by
$ restorecon -r /var/www/html

By: Janus Reply

First line requested url not found :-/

By: till Reply

CentOS changes the package names / URL's quite often. I updated the URL to the new name
now.

By: Dave Reply

What a great tutorial for a lamp server.

By: Chris Reply

Very helpful, thanks

By: Din Reply

Nice tutorial :)

By: Edgar Reply

Very useful tutorial. Keep the good work and thank you for sharing. Gracias

By: axi6ne8us Reply

Thank you for great article for noobs like myself. I have running into a problem after I edited the
phpmyadmin.conf file with commenting out the line you said. Now when I run #systemctl restart
httpd.service, I get this error: "job for httpd.service failed because the control process exited with
error code. see "systemctl status httpd.service" and "journalctl -xe" for details."
What did I get wrong?
This is conf edited:

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 15/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

[...]Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin #


<Directory "/usr/share/phpMyAdmin/"> # # # Apache 2.4 # # Require ip 127.0.0.1 # Require ip ::1
Require all granted # # # # # Apache 2.4 # Order Deny,Allow # Deny from All # Allow from
127.0.0.1 # Allow from ::1 # # Options none AllowOverride Limit Require all granted [...]

By: red_fairview Reply

Great tutorial. I do have one request, can you add some information about getting SELinux to play
nice with Apache? I'm new to setting up Linux servers and this is the first time I have worked with
CentOS, so I wasn't aware of what kinds of problems can be caused by SELinux, or how easy it is to
fix them. Lets just say it would have saved me some time, and a lot of frustrations if I had known
about the restorecon command before trying to install a CMS.

By: Alberto Bernal Reply

This is the correct link: rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-


6.noarch.rpm

By: Mintia Reply

EPEL-7 repo URL seems to be out of date again

By: Lenilson Reply

Muito obrigado por dedicar um tempo a ajudar outras pessoas... Foi o único tutorial que funcionou.
Parabens !!!

By: Nattapol Reply

at June 2016, epel version release is 7.7you can checked version in url in this
belowhttp://dl.fedoraproject.org/pub/epel/7/x86_64/e/

By: Alfonso Reply

muy buena guia, completa y clara mil gracias

By: Ryan B Reply

I can't seem to get the phpinfo to display in the browser. I typed myip/info.php (obviously my ip
address instead of myip) and also tried localhost/info.php however it just brings me to a still white
screen. Not sure if I have to enable something?

By: Joshua Atlee Reply

Maybe you didn't close it properly. tail -f /var/log/httpd/error_logs will give you exactly whats wrong
usually.

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 16/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

By: VAISHU Reply

Hey!! good tutorial. one thing which i want to point out is that CentOs 7 has bugs with php5. Php 7
works better. I followed all the steps except that I installed php 7. In the editor/console, I checked
and LAMP is installed. Even my welcome page after installing apache was working. But after i
created info.php, in the web server I am having three problems:
1. http://localhost/ gives me a blank page.
2. http://my-ip-address/info.php/ the requested url was not found in this server/
3. http://my-ip-address/phpmyadmin the requested url was not found in this server

really really need help. I am a newbie. Thanks a lot . :D

By: Bonnet.cl Reply

Really thanks you.

By: JeffH Reply

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*


results in: import read failed(0)
Any idea what I might be doing wrong??

By: Kudret Reply

Thanks A Lot :)

By: Xander Reply

Apache "placeholder" doesn't actually work...so there's that.

By: till Reply

Then you might have missed a step. Re-Check that you run all installation commands and then
check the httpd error.log to see if there are any errors on your server.

By: Techno Crusaders Reply

Setting up centos 7 in vmwere for developemnt


disable Firewall
---------------
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
// connect via ftp
ifconfig to find out Ip
ifconfig

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 17/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500


inet 192.168.170.128 netmask 255.255.255.0 broadcast 192.168.170.255
inet6 fe80::20c:29ff:fec4:b8ca prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:c4:b8:ca txqueuelen 1000 (Ethernet)
RX packets 254 bytes 20919 (20.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 95 bytes 10225 (9.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
192.168.170.128 is the ip
connect with FileZilla
----------
setup LAMP
-----------
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service
mysql_secure_installation
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
yum -y install php
service httpd restart
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp
php-soap curl curl-devel
service httpd restart
yum install phpMyAdmin
on windows open cmd, type ipconfig
find
Ethernet adapter VMware Network Adapter VMnet8:
Connection-specific DNS Suffix . : localdomain
Link-local IPv6 Address . . . . . : fe80::94b8:9e5c:c772:3d47%19
IPv4 Address. . . . . . . . . . . : 192.168.170.1 [ this is the widnows ip to allow ]
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway .
in /etc/httpd/conf.d/phpMyAdmin.conf change:
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 18/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
to:
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>

<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip [ WINDOWS IP TO ALLOW GOES HERE ]
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from [ WINDOWS IP TO ALLOW GOES HERE ]
Allow from ::1
</IfModule>
</Directory>
service httpd restart
change $cfg['Servers'][$i]['auth_type'] = 'cookie'; to $cfg['Servers'][$i]['auth_type'] = 'http';
service httpd restart

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 19/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

/etc/selinux/config change
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
to
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
reboot centos
IN WINDOWS POINT BROWSER TO: http://192.168.170.128/phpmyadmin, should be all good
copy website to: /var/www/html/[ WEBSITE NAME ]
chmod -R 777 html

By: Ezechiel Reply

Very helpfull tutorial.


Thank you

By: deandownsouth Reply

If you are going to show people how to disable all security, as you do by by commenting out the
entire block, you should warn them that this makes it so any IP is accepted--so if they place this
configuration on a web facing network, anyone will be able to get to phpmyadmin from any IP

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 20/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

address. They should be asked if that is what they intend. However, it is far better to simply show
them the correct way, that is by putting in either their internal subnet only, if they only manage from
a private IP space (so that would be done in CIDR format as in 192.168.1.0/24 or 10.0.0.0/24 and
so on. If they want to be able to get to and manage from the Internet (which should only be done if
you don't have any other way to get to it) they should find out what their external IP is from where
they will be managing and put that IP address in i.e. 67.67.77.156 but certainly you don't want any
of the millions of IP address from all over the planet to be able to bang away at the php
administration logon, do you?
For those that say this is just for testing or developing...I've lost count of how many times a dev or
test system somehow got placed in production with security either very relaxed or non-existent and
then next thing you know, the site is hacked.

And for those requesting that SELinux be disabled. Do yourselves a favor, learn how to work with it.
Don't just disable it or put it in permissive mode. It is one of many things that is between you and
hackers. Why purposely, for the lack of spending time with a book or documentation, weaken the
security of a system on the Internet?
If a person can't deploy and configure a LAMP stack without disabling security then maybe they
shouldn't be trying to deploy and configure a LAMP stack.
Do it right or don't do it at all.

By: Ioana Reply

Same here

By: franco Reply

how update phpmyadmin version without reinstalling everything ?

By: Abdullah Reply

You are hero. :)

By: Jhon Hernandez Reply

Excelente tutoria. Gracias por compartilo

By: [email protected] Reply

When try to access: http://192.168.0.1/phpmyadmin im getting:


Forbidden
You don't have permission to access /phpmyadmin/ on this server.

any idea?

By: GGILIO Reply

great tutorial,
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 21/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Thanks a lot

By: ernesto Reply

really great tutorial, God bless

By: Francisco Reply

Just starting with VPS and this tutorial is a lifesaver. I have save it to my bookmarks. Please always
keep it up to date if it is not too much to ask. Amazing contribution to the community this is!

By: Security Concern Reply

No mod_ssl & Full database access using plain text http (through phpmyadmin). Your work is usually
so detailed, what happened here?

By: Achmad Reply

Nice. Work properly!

By: Carlos Reply

Thank you very much for sharing your knowledge, greetings

Home Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Sign up now!

 Tutorial Info

Author: howtoforge
Tags:
apache, centos, linux, mysql, php, server, web
server

 VMware image download

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 22/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Install Apache, PHP And


MySQL On CentOS 7
(LAMP) as ready to use
virtual machine image
download in ovf/ova
format, compatible with
VMWare and Virtualbox.

Download: centOS7.0_perfect_lamp_server.ova
Guide: VMWare Image Import Guide.
Other Downloads: List of all VMWare Images

 Share This Page

40.2k Followers

 Popular Tutorials

How to use grep to search for strings in files on the


shell

How do I edit files on the command line?

The Perfect Server - Debian 10 (Buster) with


Apache, BIND, Dovecot, PureFTPD and ISPConfig
3.1

How to use the Linux ftp command to up- and


download files on the shell

How to Install and Configure Algo VPN Server on


Ubuntu 20.04

Advanced Git Tutorial

How to Manage Systemd Services with Systemctl on


Linux

How to Install Kubernetes with Minikube on Ubuntu


20.04

How to search files from the Terminal on Linux

How to Setup ZSH and Oh-my-zsh on Linux

Xenforo skin by Xenfocus Contribute Contact Help Imprint and Legal Notice

Howtoforge © projektfarm GmbH. Terms and Rules Privacy Policy

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 23/24
2/1/2021 Install Apache, PHP And MySQL On CentOS 7 (LAMP)

https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp 24/24

You might also like