Comments on Install Apache, PHP And MySQL On CentOS 7 (LAMP)
This tutorial shows how you can install an Apache2 webserver on a CentOS 7.0 server with PHP5 support (mod_php) and MySQL support. LAMP is short for Linux, Apache, MySQL, PHP.
63 Comment(s)
Comments
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
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.
The Fedora package has been upreved. It is now epel-release-7-1.noarch.rpm
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.
The tutorial has been updated to a newer phpmyadmin version now.
Why mariaDB and not mysql, or are they the same now ?
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.
FYI, this process installed PHP 5.4.16, not PHP 5.5.x:
# php -v
<Directory "/usr/share/phpMyAdmin/">
Options Indexes
AllowOverride None
Require all granted
</Directory>
Thanks for the one stop instructions. Everything worked as expected. Very common setup for CMS systems.
-nick
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
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"
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 ;-)
Nice Clear Instructions. Thanks!
phpMyAdmin is not available in CentOS 7's default repository. before installing phpMyAdmin, run sudo yum install epel-release
See step one of the tutorial. It explains the installation of the epel repo.
phpMyAdmin Repo now at
rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
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 :)
thanks man!!!
you don't know how much your tutorial helped me.
all the best dearest man :)
thanks man. You don't know how much your tutorial helped me.
All the best dearest man :)
great tutorial,
Thanks!!
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?
Use your MySQL/MariaDB password. You are not using your Linux login to access the database, which you're trying to do with phpmyadmin
Hi,
I'm getting below things while I'm trying to access phpmyadmin in GUI mode.
ForbiddenYou don't have permission to access /phpMyAdmin on this server.
I'm having the same issue like you. Did you fix it?
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!
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> </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>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
First line requested url not found :-/
CentOS changes the package names / URL's quite often. I updated the URL to the new name now.
What a great tutorial for a lamp server.
Very helpful, thanks
Nice tutorial :)
Very useful tutorial. Keep the good work and thank you for sharing. Gracias
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:
[...]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 [...]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.
This is the correct link: rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
EPEL-7 repo URL seems to be out of date again
Muito obrigado por dedicar um tempo a ajudar outras pessoas... Foi o único tutorial que funcionou. Parabens !!!
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/
muy buena guia, completa y clara mil gracias
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?
Maybe you didn't close it properly. tail -f /var/log/httpd/error_logs will give you exactly whats wrong usually.
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
Really thanks you.
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
results in: import read failed(0)
Any idea what I might be doing wrong??
Thanks A Lot :)
Apache "placeholder" doesn't actually work...so there's that.
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.
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
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>
</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
/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
Very helpfull tutorial.
Thank you
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 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.
Same here
how update phpmyadmin version without reinstalling everything ?
You are hero. :)
Excelente tutoria. Gracias por compartilo
When try to access: http://192.168.0.1/phpmyadmin im getting:
ForbiddenYou don't have permission to access /phpmyadmin/ on this server.
any idea?
great tutorial,
Thanks a lot
really great tutorial, God bless
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!
No mod_ssl & Full database access using plain text http (through phpmyadmin). Your work is usually so detailed, what happened here?
Nice. Work properly!
Thank you very much for sharing your knowledge, greetings