This how-to guide explains how to install the latest version of Apache, MySQL (or MariaDB), and PHP, along with the required PHP modules, on RHEL-based distributions such as Fedora, Rocky, and Alma Linux.
This combination of the operating system (Linux) with the web server (Apache), database server (MariaDB/MySQL), and server-side scripting language (PHP) is known as the LAMP stack.
Step 1: Installing Apache Web Server
Before starting the installation process of the web server, ensure that your server is up-to-date by running the following yum or dnf commands.
sudo yum update Or sudo dnf update
Next, you need to enable the epel repository, which is a community-based repository that offers add-on software packages for RHEL-based Linux distributions such as Rocky and Alma Linux.
sudo yum install epel-release
Now you can install Apache, which is a widely used open-source web server software that serves web content over the HTTP protocol.
sudo yum install httpd
Once the Apache web server is installed, you can enable it to start automatically at system boot.
sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd
If you are running firewalld, make sure to allow Apache traffic on the firewall.
sudo firewall-cmd --zone=public --permanent --add-service=http sudo firewall-cmd --zone=public --permanent --add-service=https sudo firewall-cmd --reload
To access the Apache web page after installation, open a web browser on your computer and type the IP address or hostname of your Linux server where Apache is installed.
http://IP_address/
Step 2: Installing PHP Using Remi Repository
PHP is a free and open-source server-side scripting language that is best suited for web development. It can be used to produce dynamic web pages for a website and is most frequently found in Nix servers.
sudo yum install php
One of the advantages of PHP is that it is easily extensible through the use of a wide variety of modules.
sudo yum install php-mysqlnd php-pdo php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
Once PHP is installed, restart the Apache service to apply the changes.
sudo systemctl restart httpd
Step 3: Installing MySQL or MariaDB in Linux
In this section, we will show you the installation of both databases MySQL and MariaDB, so it’s up to you what to choose based on your requirements.
Installing MySQL in Linux
MySQL is one of the world’s most popular open-source relational database management systems (RDBMS) that runs any server by providing multi-user access to multiple databases. MySQL runs with Apache.
sudo yum install mysql-server
Installing MariaDB in Linux
MariaDB is a fork of the well-known MySQL, one of the world’s most popular relational database management systems (RDBMS). It is entirely developed by the community and as such it is intended to remain FOSS and compatible with the GPL.
sudo yum install mariadb-server
After successful installation of MySQL or MariaDB, it’s time to start the service and enable it to start on boot.
sudo systemctl start mysqld # For MySQL sudo systemctl enable mysqld sudo systemctl status mysqld sudo systemctl start mariadb # For MariaDB sudo systemctl enable mariadb sudo systemctl status mariadb
After installation, it is essential to secure your database server by running the following command and following the prompts to set a root password and remove insecure defaults.
sudo mysql_secure_installation
Step 4: Verify Installation
Once Apache, MySQL/MariaDB, and PHP are installed, restart the Apache service to apply the changes.
sudo systemctl restart httpd
Next, create a PHP test file called info.php in the Apache document root directory (/var/www/html/).
sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Now point your web browser to the following address and check the presence of the installed modules and additional software by scrolling down the page (replace [server]
with your domain or the IP address of your server).
http://your_server_ip/info.php
Your output should be similar to:
Conclusion
Congratulations! You have successfully installed Apache, MySQL/MariaDB, and PHP on your RHEL server. With this LAMP stack set up, you are ready to host and deploy dynamic websites and web applications.
Thank you , you are wonderful
Best Post Everr !!!!!!!
thanx a lot buddy………. very very usefull….
thank you so much
Informative article, exactly what I waas looking for.
BOSS ?? Distro From Indian Govt. Org C-DIT Chennai
Plz help to get job on linux platform.
i am getting problem…while installing
it is you can try skip broken problem….like this
i am getting error while installing……it showing yum skip broken problemmmmm…..like this….
Hi,
my current version of soft. running on server are –
1.php – 5.3
2.mysql-5.1
I need to upgrade php5.3 to 5.4 but during upgrading one of php module (i.e php-mysql) trying to upgrade my mysql server too as it considering it as its dependency.
I need to use mysql5.1 with upgraded version of php5.4 and need php-mysql module to have proper communication with them but do not want to upgrade my mysql version.Is it possible?
Please help.
@Rohit,
The best optiont is to compile php from source..this is the only way…
Hi, I am getting an error while re-installing PHP packages on centos 6.6
I do have mysql 5.6.12 (server version) and I want to install PHP enbled with mysqli support. Can you please tell me without changing any other configuration how can I get PHP installed with mysqli support.
@Sneha,
Could you please tell us what error you getting while re-installing PHP? Could you post that error here, so that we can work around for the solution…
Hello,
I’m trying to setup my server for the latest version of moodle, which has requirements in mysql and php which you have made easy through this tutorial, however while running the install command for apache, mysql ,and php I get the following error:
Finished Dependency Resolution
Error: Package: php-common-5.5.15-0.1.RC1.el6.remi.x86_64 (remi-test)
Requires: php-pecl-zip(x86-64)
Available: php-common-5.4.33-1.el6.remi.x86_64 (remi)
php-pecl-zip(x86-64) = 1.11.0
Available: php-common-5.4.33-2.el6.remi.x86_64 (remi)
php-pecl-zip(x86-64) = 1.11.0
Removing: php-common-5.3.3-27.el6_5.1.x86_64 (@rhel-x86_64-server-6)
Not found
Updated By: php-common-5.5.15-0.1.RC1.el6.remi.x86_64 (remi-test)
Not found
Available: php-common-5.3.2-6.el6.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.2-6.el6_0.1.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-3.el6.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-3.el6_1.3.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-3.el6_2.5.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-3.el6_2.6.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-3.el6_2.8.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-14.el6_3.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-22.el6.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-23.el6_4.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-26.el6.x86_64 (rhel-x86_64-server-6)
Not found
Available: php-common-5.3.3-27.el6_5.x86_64 (rhel-x86_64-server-6)
Not found
Any Ideas?
Hello Ravi Saiveji,
first of all thanks for the tutorial.I am a regular reader of your website, I learn a lot from it, thanks for your all post.
Can you give details for BOSS OS and How to install LAMP in BOSS.
BOSS OS? never heard such distro, let me check it and if possible will surely provide a complete howto on LAMP
BOSS Stands For Bharath Operating System Ravi Saive From Indian Govt. Org C-DIT
Hello Mr. Ravi Saive,
I am a regular reader of your post, I learn a lot from it, thanks for your all post.
Today I will request you for a topic about Apache & ftp(vsftp or proftp) configuration . Here I am sharing the issue.
I have 2 sites in same server say site1.abc.com & site2.abc.com. I have 2 developer for each site say user1 & user2.
Now I need to configure apache & ftp server, so that both developer can upload site contain to there site folder(/var/www/html/site1 & /var/www/html/site2).
How to configure this type of setting. Hope you understand the issue & will share configuration tips on this. I ma using CentOS 6.5 64 bit Os.
Dear Ananda,
Thanks for being regular reader of TecMint.com. After looking into your requirements, I can say first you have to install apache and vsftp. Once these required packages are installed, follow the below configuration steps.
1. Create two Virtual hosts in apache configuration for both the domains with respective folders. For example,
For more information about how to create Vhosts, read our following article.
https://www.tecmint.com/apache-ip-based-and-name-based-virtual-hosting/
2. Create two FTP users say user1 and user2 with their respective passwords with home directories as site1 and site2.
3. Now grant permission as owner and group to new Vhosts folders.
That’s it now they are able to login to their respective folder and do ftp.
Need to upgrade PHP to 5.4 or above. Server don’t have internet connection. How do I do it?
How to install on CentOS 7 x86_64 ?
Please use the following link to setup LAMP environment in CentOS 7.
https://www.tecmint.com/install-lamp-in-centos-7/
Hi Ravi,
As per your guide am installed apache 2.2.15,now i need upgrade httpd 2.2.10 to 2.4.x in centos 6.5..how can i upgrade…
I don’t know, actually I haven’t tested yet, but as per your requirement, will try to uprade httpd 2.4.x. Please stay tuned for the update.
Hi Ravi,
Nice article and proper procedure.
I complected LAMP installation on CentOS6.5 using your article. However I stucked while issuing password. After going through post section I understood where I made mistake.
My suggestion is you may have to add a step or link to configure MYSQL
Anyhow wonderful work.
Thanks Saravana, will surely add a procedure on how to configure MySQL to the write-up.
Thank you so much ! It worked very well !
Thanks Ravi,
I done uninstall APC. After that memcahe not able to configure my application..
Ravi,
Yesterday, I installed CentOS6.5, clean install, with a LAMP installation with MySQL 5.1 included (misery to upgrade with all those dependencies). This is the first website, where a procedure has been published to smoothly replace the MySQL5.1 with the MySQL5.5 version, including more recent version of PHP and Apache. I followed exactly all the steps that you described, and the result was wonderfull ! Not one error showed up and not one time I had to google to solve an unexpected problem. Thank you very much for this perfect installation procedure, you did a great job, it’s really great !
Thanks !
Kind regards,
Dirk.
Hi Ravi,
Thanks lot. As per your guide i installed Apache , PHP and Mysql. I Verified my php in http://localhost/phpinfo.php . i Would like to use APC and memcache or memcached in my application. i choose APC its working but if i select memcache in my application its not working.. how can i solve this problem
Why you choosing both? use any one of them for better performance.
Hi Ravi,
Is there any chance to uninstall APC package? share uninstall command.
Not able to select memcache?
Use the following command to uninstall APC from the system.
Hi Ravi,
I use CentOS 6.5, and I got PHP 5.4.27, instead.
How do I get PHP 5.5.4?
Thanks
Ravi,
Great tutorial. I have followed it all on a brand new CentOS 6 install, but not getting the php pdo for mysql:
Skipped (dependency problems):
…
php-mysql.x86_64 0:5.4.26-1.e16.remi
…
a couple of others skipped too, but I’m not worried about them. the PDO driver for mysql is what I need. After first install, phpinfo() showed only pdo for sqlite. After a second install, it had added sqlite2, but still no pdo for mysql.
What am I missing?
TIA
Install php pdo package using yum command.
And i do not have internet to the server its on Vm machine
Hi Ravi
am fresh to this php i do not know any thing in na dout of this but i tried to do the installation i think i have screws the php in the system its linux box
pleae if you can help me on this
how do i clear the existing php and do a clean install
Thanks
Nagaraj
Just do a yum remove php on the terminal it will remove php completely.
HI I’m trying to get LAMP configured on Red Hat Linux 5.8 running the following version of php and mysq
[root@FBDMoodlePRD tmp]# php -v
PHP 5.3.3 (cli) (built: Dec 5 2013 06:39:35)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[root@FBDMoodlePRD tmp]# mysql -V
mysql Ver 14.14 Distrib 5.5.36, for Linux (x86_64) using readline 5.1
[root@FBDMoodlePRD tmp]#
l’m told I need the PDO drivers enbale for mysqli, see the php-i output below…
[root@FBDMoodlePRD tmp]# php -i | grep PDO
PHP Warning: Unknown: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘GMT/0.0/no DST’ instead in Unknown on line 0
PDO
PDO support => enabled
PDO drivers => mysql, odbc, pgsql, sqlite
PDO Driver for MySQL => enabled
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled
PDO Driver for PostgreSQL => enabled
PDO Driver for SQLite 3.x => enabled
I don’t know how to do it. The developer is running Moodle on the server and he says he needs it… Any ideas ? List of the current php pkg installed via yum
yum list installed | grep php
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
php-pear.noarch 1:1.4.9-8.el5 installed
php53.x86_64 5.3.3-22.el5_10 installed
php53-bcmath.x86_64 5.3.3-22.el5_10 installed
php53-cli.x86_64 5.3.3-22.el5_10 installed
php53-common.x86_64 5.3.3-22.el5_10 installed
php53-dba.x86_64 5.3.3-22.el5_10 installed
php53-devel.x86_64 5.3.3-22.el5_10 installed
php53-gd.x86_64 5.3.3-22.el5_10 installed
php53-imap.x86_64 5.3.3-22.el5_10 installed
php53-intl.x86_64 5.3.3-22.el5_10 installed
php53-ldap.x86_64 5.3.3-22.el5_10 installed
php53-mbstring.x86_64 5.3.3-22.el5_10 installed
php53-mysql.x86_64 5.3.3-22.el5_10 installed
php53-odbc.x86_64 5.3.3-22.el5_10 installed
php53-pdo.x86_64 5.3.3-22.el5_10 installed
php53-pgsql.x86_64 5.3.3-22.el5_10 installed
php53-process.x86_64 5.3.3-22.el5_10 installed
php53-pspell.x86_64 5.3.3-22.el5_10 installed
php53-snmp.x86_64 5.3.3-22.el5_10 installed
php53-soap.x86_64 5.3.3-22.el5_10 installed
php53-xml.x86_64 5.3.3-22.el5_10 installed
php53-xmlrpc.x86_64 5.3.3-22.el5_10 installed
Hi,
I’m tried to install LAMP on RHEL5.8(32 bit) by following the steps.
Getting the below error if I execute the below command.
——————————————————————-
[root@server1 ~]# yum –enablerepo=remi,remi-test install httpd mysql mysql-server php php-common
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Could not retrieve mirrorlist http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=i386 error was
[Errno 4] IOError:
Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again
———————————————————————————-
Hi Ravi saive,
kindly advise about the php,mysql and apache on CentOS 6.3, i already installed those are in the CentOS, and everything’s fine, event the php and mysql, they known each others, i mean those were connectted with the php script connecting the database, but unfortunatelly there are any scripts in my source could not run on the web base, it can only connect the database, but when i used the code to list the record in the database it didn’t me that codes, so could you please advise or send me the email?
Excuse me, i forget to traduce, Hi John, I need to enable gd library in Oracle linux server, I have php 5.5.8 and mysql 5.6.15 apache 2.2.3, I can use this repository?
Yes, you can use the same repository to enable gd library.
only php 5.3
=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
php-gd x86_64 5.3.3-27.el6_5 updates 107 k
php-mbstring x86_64 5.3.3-27.el6_5 updates 455 k
php-mcrypt x86_64 5.3.3-3.el6 epel 19 k
php-mysql x86_64 5.3.3-27.el6_5 updates 81 k
php-pdo x86_64 5.3.3-27.el6_5 updates 75 k
php-pear noarch 1:1.9.4-4.el6 base 393 k
php-pecl-apc x86_64 3.1.9-2.el6 base 96 k
php-pecl-memcache x86_64 3.0.5-4.el6 base 60 k
php-pecl-memcached x86_64 1.0.0-1.el6 epel 28 k
php-pecl-mongo x86_64 1.4.4-1.el6 epel 123 k
php-pgsql x86_64 5.3.3-27.el6_5 updates 70 k
php-xml x86_64 5.3.3-27.el6_5 updates 103 k
Installing for dependencies:
libmcrypt x86_64 2.5.8-9.el6 epel 96 k
libmemcached x86_64 0.31-1.1.el6 base 80 k
postgresql-libs x86_64 8.4.18-1.el6_4 base 201 k
Transaction Summary
I have a doubt in Cron jobs. Can we execute a Cron job before system shutdown? I want to execute a Cronjob/script in fedora 18 before it shuts down. Kindly reply me….
php5.5: php-pecl-memcached in php-common ??
i cudn’t enable mbstring on my php tried all the methods..please to help ! i have installed = apache – 2.2.25 , php 5.3.27,mysql 5.5.34.
Its a strugge to enable any extension here.
Just do yum install php-mbstring to enable it and after installing make sure to restart Apache.
Hi ,
How can install Multi Php on server cpanel ?
tanks and regards
Yes you can install PHP from source in specific directory.
I’m not sure the php-pecl-apc package should be installed. the new opcache is included in php 5.5
Hi,
First, thank you so much for this great tutorial. I only have some questions here :)
I already remove my old version of php,mysql and apache before install and doing this procedure but when I checked the version of my newly installed php,mysql and apache I found out that my php version is still not the same with this tutorial have.
MY current PHP version: (update from 5.2.1 but not the with the tutorial)
—PHP 5.4.21 (cli) (built: Oct 27 2013 12:42:05)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
—MY Current Apache Version: (Still the same)
Server version: Apache/2.2.3
Server built:Oct 16 2013 12:18:29
—My Current MYSQL Version:(updated)
Server version:5.5.34 MySQL Community Server (GPL) by Remi
Protocol version:10
Hope we can fix this issue :)
Thanks again!
I think your OS needs an upgrade to install latest versions.
Thanks for the reply, My CentOS version is 5.9 and I think this version is indicated on this tutorial?
I also tried 6.4 but I don’t feel this vesion ;) so I’m staying with the old 5.9 :)
Just to share, I’m upgrading because I want to setup a new drupal website server.
MY current drupal site contains this versions:
CentOS 5.8
PHP 5.3.3
MySQL 14.12 Distib 5.0.9
Server Version: 5.0.95
Apache 2.2.3
Drupal 7.14
my plan is
Going to 5.9 ( not 6.x )
Drupal 7.23
and your PHP,MYSQL and Apache version
do you think I need to upgrade these versions just to run a new drupal site or just leave it?
I also read some articles saying that the version of php 5.3.3 is a buggy version.. and they recommend to upgrade to 5.3.27 version but that article is way back last year..
i know this is Off topic but I’m hopping for your suggestions :)
Thanks!
No need of up-gradation of OS and packages, you can deploy latest version of Drupal on the current configuration of your server.
And one more request to you have php 5.3.27 compiled version? :)
Hi Ravi,
I’m running RHEL 6.3 and followed your recipe for upgrading PHP and MySQL.
I’m getting the same issue as others above with the following when trying to install ‘mysql-server’ package:
Error: Package: mysql-server-5.5.34-1.el6.remi.x86_64 (remi)
Requires: libz.so.1(ZLIB_1.2.0)(64bit)
It appears that the ‘libz.so’ already installed is newer than 1.2.0:
yum whatprovides *libz.so*
zlib-1.2.3-27.el6.x86_64 : The zlib compression and decompression library
Repo : installed
Matched from:
Filename : /lib64/libz.so.1.2.3
Other : libz.so.1()(64bit)
Filename : /lib64/libz.so.1
zlib-devel-1.2.3-27.el6.x86_64 : Header files and libraries for Zlib development
Repo : installed
Matched from:
Filename : /usr/lib64/libz.so
Will removing this package as you recommend mean the required one is installed (downgraded) as a dependency?
I really don’t wish to start a wild goose-chase tracking down dependencies and downgraded versions…
Thanks for any help!
– Richard
Need to upgrade PHP to 5.4 or above. Server don’t have internet connection. How do I do it? Thanks a lot..
Centos with Apache ENV.
Not possible, you must connected to web to install packages.
i got this error:-
Error: Package: mysql-server-5.5.34-1.el6.remi.i686 (remi)
Requires: perl-DBI
Error: Package: mysql-server-5.5.34-1.el6.remi.i686 (remi)
Requires: perl-DBD-MySQL
Error: Package: mysql-server-5.5.34-1.el6.remi.i686 (remi)
Requires: perl(DBI)
Error: Package: mysql-server-5.5.34-1.el6.remi.i686 (remi)
Requires: libz.so.1(ZLIB_1.2.0)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
[secpod@localhost httpd-2.2.9]$ chkconfig –levels 235 mysqld on
error reading information on service mysqld: No such file or directory
Which version of OS you using? remove that perl-DBI package with yum remove perl-DBI and try the command again.
I’m using rhel 6-base and I tried this
yum remove perl-DBI
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
INFO:rhsm-app.repolib:repos updated: 0
Setting up Remove Process
No Match for argument: perl-DBI
No Packages marked for removal
Hi Ravi,
I need to install phpmyadmin. Currently I am having-
# mysql -V
mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (i386) using readline 5.1
#httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Feb 7 2012 09:50:15
# php -v
PHP 5.5.4 (cli) (built: Sep 19 2013 14:43:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
When I run
# yum –enablerepo=remi,remi-test install httpd mysql mysql-server php php-common
I am getting-
Error: Package: mysql-server-5.5.34-1.el6.remi.i686 (remi)
Requires: libz.so.1(ZLIB_1.2.0)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
Can you suggest me what could be the reason or how shall I install phpmyadmin?
First remove the old packages and then try to install new one with same command
Hi Ravi,
Could you please help me on how do I uninstall/remove all those packages (httpd, php, mysql) & install fresh ones.
Thanks.
Dear Imran
To remove complete lamp environment from the system, please use yum command as shown below.
Thank you very much. I’ve followed the guide and my server work perfectly.
I have installed mysql and mysql-server on fedora 19 successfully but when I am trying to
start service /etc/init.d/mysqld start its showing
/etc/init.d/mysqld: command not found
why its happening could you please let me know
In latest Fedora release, they’ve introduced systemctl to enable, start and stop services. Like this way.
Ravi,
Thanks for the great info. Installed all on my Centos 5.8 box. My php is I-386 version.
A few small problems…
First, I’m getting this error in PhpMyAdmin:
Your PHP MySQL library version mysqlnd 5.0.11-dev – 20120503 – $Id: 40933630edef551dfaca71298a83fad8d03d62d4 $ differs from your MySQL server version 5.5.33. This may cause unpredictable behavior.
Next, I need to enable the cURL extension.
Any help would be greatly appreciated .
Hey,
I’m getting
•Apache/2.2.15 (CentOS) <– 6.4
•Database-Client Version: libmysql – mysqlnd 5.0.11-dev – 20120503 – $Id: 40933630edef551dfaca71298a83fad8d03d62d4 $
•PHP-Extension: mysqli
on phpMyAdmin 4.0.5 but I don't know if it is the right version from 03.05.2012?
It seems to be very old?
I used this tutorial and your phpmyadmin tutorial?
https://www.tecmint.com/install-phpmyadmin-for-apache-or-nginx-on-rhelcentos-6-3-5-8-fedora-17-12/
Hi,
Very useful article. Followed the steps and installed without any issues.
Just want to know If we need to install the individual packages of this Apache, Mysql and Php for those who do not have Internet connection. Just assume for a standalone workstation.
Could you please guide how to download the individual packages and configure them in centos.
Thanks..
Hi Bala…
Follow the below procedure to download all pkgs and install them into stand alone machine.
– First install yum-downloadonly pkg
# yum install yum-downloadonly -y
– Next create a dir for repsective pkgs Ex: /PHP-5.5.0-Modules
Now just fire the below command
# yum –enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo –downloadonly –downloaddir=/PHP-5.5.0-Modules
Thats it… All pkgs will get downlaod here and u can install them into anywhere u want.
Thank you very much for the tutorial… very good work… My problem is, I want to set up phpmyadmin 4.0.5 but version 2.3.11 is established. please help
On Which version of OS you trying to install it?
I went through everything twice and when i dial up the server in a browser it doesn’t show the page, “this page cant be displayed”
using Centos 6.4 on xen center VM
Hey, nice tutorial. I’m running Fedoa 17, 64 bit.
I tried installing PHP 5.5 with this tutorial but it seems to install php 5.4
I checked the contents of the directory where it is pulling from and it seems 5.5 is not listed.
Any ideas?
I think in Fedora 17, 5.5 version not supported. If you looking for updated version of PHP, then you need to upgrade your system.
great tutorial except for one thing, and not your fault. I have CentOS 6.4 on a 64 bit system and when I installed the REMI repository from http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm, it contained mysql 5.1.6 not 5.5 and php 5.3.3. As for the process, it went seamlessly … just not the results I was expecting. Thought I’d mention it for anyone else with a 64 bit system. Or maybe I did something wrong, wouldn’t be the first time.
Did you added both Remi and Epel repositories? Can you post the output of the said command. So, we could find out why it showing 5.1.6 instead of 5.5.
I don’t know what I did wrong but I did a fresh install of CentOS on a different machine and followed your instructions again and this time it worked. I did notice that there were some errors regarding PHP not being able to initialize modules and also an error about the libc libraries are not 100% compatible. Would that have something to do with the MySQL plugin libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64.rpm not being the latest version?
Don’t need to worry about much. I think there are no updates for said version.
Thx guys, this article help me alot.
Cent OS 6.4
Hello, I have centos 6.3 (64bit)
I am getting this error, could you help me.
Loaded plugins: security
base | 1.9 kB 00:00
base/primary | 2.2 MB 00:00
base 6339/6339
epel/metalink | 12 kB 00:00
epel | 4.2 kB 00:00
epel/primary_db | 5.4 MB 00:08
extras | 1.3 kB 00:00
extras/primary | 6.6 kB 00:00
extras 17/17
openlogic | 1.3 kB 00:00
openlogic/primary | 272 kB 00:00
openlogic 20/20
updates | 1.3 kB 00:00
updates/primary | 497 kB 00:00
updates 1170/1170
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package httpd.x86_64 0:2.2.15-15.el6.centos.1 will be installed
–> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos.1 for package: httpd-2.2.15-15.el6.centos.1.x86_64
–> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-15.el6.centos.1.x86_64
–> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
–> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
—> Package mysql.x86_64 0:5.5.32-1.el6.remi will be installed
–> Processing Dependency: real-mysql-libs(x86-64) = 5.5.32-1.el6.remi for package: mysql-5.5.32-1.el6.remi.x86_64
—> Package mysql-server.x86_64 0:5.5.32-1.el6.remi will be installed
–> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.5.32-1.el6.remi.x86_64
–> Processing Dependency: libz.so.1(ZLIB_1.2.0)(64bit) for package: mysql-server-5.5.32-1.el6.remi.x86_64
—> Package php.x86_64 0:5.5.1-1.el6.remi will be installed
–> Processing Dependency: php-cli(x86-64) = 5.5.1-1.el6.remi for package: php-5.5.1-1.el6.remi.x86_64
—> Package php-common.x86_64 0:5.5.1-1.el6.remi will be installed
–> Processing Dependency: php-pecl-jsonc(x86-64) for package: php-common-5.5.1-1.el6.remi.x86_64
–> Running transaction check
—> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
—> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
—> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
—> Package httpd-tools.x86_64 0:2.2.15-15.el6.centos.1 will be installed
—> Package mysql-libs.x86_64 0:5.5.32-1.el6.remi will be installed
—> Package mysql-server.x86_64 0:5.5.32-1.el6.remi will be installed
–> Processing Dependency: libz.so.1(ZLIB_1.2.0)(64bit) for package: mysql-server-5.5.32-1.el6.remi.x86_64
—> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
–> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
–> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
—> Package php-cli.x86_64 0:5.5.1-1.el6.remi will be installed
—> Package php-pecl-jsonc.x86_64 0:1.3.1-2.el6.remi.1 will be installed
–> Processing Dependency: /usr/bin/pecl for package: php-pecl-jsonc-1.3.1-2.el6.remi.1.x86_64
–> Processing Dependency: /usr/bin/pecl for package: php-pecl-jsonc-1.3.1-2.el6.remi.1.x86_64
–> Running transaction check
—> Package compat-mysql51.x86_64 0:5.1.54-1.el6.remi will be installed
—> Package mysql-server.x86_64 0:5.5.32-1.el6.remi will be installed
–> Processing Dependency: libz.so.1(ZLIB_1.2.0)(64bit) for package: mysql-server-5.5.32-1.el6.remi.x86_64
—> Package php-pear.noarch 1:1.9.4-20.el6.remi will be installed
–> Processing Dependency: php-xml for package: 1:php-pear-1.9.4-20.el6.remi.noarch
–> Processing Dependency: php-posix for package: 1:php-pear-1.9.4-20.el6.remi.noarch
–> Running transaction check
—> Package mysql-server.x86_64 0:5.5.32-1.el6.remi will be installed
–> Processing Dependency: libz.so.1(ZLIB_1.2.0)(64bit) for package: mysql-server-5.5.32-1.el6.remi.x86_64
—> Package php-process.x86_64 0:5.5.1-1.el6.remi will be installed
—> Package php-xml.x86_64 0:5.5.1-1.el6.remi will be installed
–> Finished Dependency Resolution
Error: Package: mysql-server-5.5.32-1.el6.remi.x86_64 (remi)
Requires: libz.so.1(ZLIB_1.2.0)(64bit)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
Just a quick correction: if are having problems with mysqli, please use the following command:
yum –enablerepo=remi,remi-test install php-mysql
Do not forget to use the remi repo, other wise it will install an old version (php .5.1).
I did this for CentOS 5.X.
Thank you very much for the information/tutorial… very good work…
Hello!
Can you help me? I couldn’t installa My sql On RHEL 5.8 X86_64
Loaded plugins: katello, security
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package mysql.x86_64 0:5.5.32-1.el5.remi set to be updated
–> Processing Dependency: real-mysql-libs = 5.5.32-1.el5.remi for package: mysql
—> Package mysql-server.x86_64 0:5.5.32-1.el5.remi set to be updated
–> Processing Dependency: perl-DBI for package: mysql-server
–> Processing Dependency: perl-DBD-MySQL for package: mysql-server
–> Processing Dependency: perl(DBI) for package: mysql-server
–> Running transaction check
—> Package mysql-libs.x86_64 0:5.5.32-1.el5.remi set to be updated
—> Package mysql-server.x86_64 0:5.5.32-1.el5.remi set to be updated
–> Processing Dependency: perl-DBI for package: mysql-server
–> Processing Dependency: perl-DBD-MySQL for package: mysql-server
–> Processing Dependency: perl(DBI) for package: mysql-server
–> Finished Dependency Resolution
mysql-server-5.5.32-1.el5.remi.x86_64 from remi has depsolving problems
–> Missing Dependency: perl-DBD-MySQL is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
mysql-server-5.5.32-1.el5.remi.x86_64 from remi has depsolving problems
–> Missing Dependency: perl(DBI) is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
mysql-server-5.5.32-1.el5.remi.x86_64 from remi has depsolving problems
–> Missing Dependency: perl-DBI is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
Error: Missing Dependency: perl(DBI) is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
Error: Missing Dependency: perl-DBI is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
Error: Missing Dependency: perl-DBD-MySQL is needed by package mysql-server-5.5.32-1.el5.remi.x86_64 (remi)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.
To get rid of such dependency errors, remove the Perl-DB package.
And then try to install again, hope it will work.
Hello Ravi, first of all i hat a lot of help through this great how to.
But as stated a comment above i also have the issue of MySQL Daemon failed to start.
Where exactly can i find the my.conf file to check if configuration is correct.
I fixed the problem, but cant seem to get the FTP working, It givis me error that i do not have the right permissions.
Thanks for your post..
I got an error while i start the mysql…
“MySQL Daemon failed to start.
Starting mysqld: [FAILED]”
Can you explain how can i start mysql…
Please check your my.cnf file, may be something wrong with your configuration.
Hi, why does it install php 5.5?
because the repo installs whatever newest release available..
@raj, have you tried…
Ever heard of MariaDB????
Yes! Why such question?
Hi here i got the info abt how to install…can u please post something like how it work…The details are below.
I have install install linux,apache,mysql and php. But now i can’t know how its work together. Means how php website is conecting to mysql database and how it host on apache web server.
Hi Ravi…
Update on this..
If you want to understand deeply about how PHP, MySQL and Apache works. Please follow the below article.
http://wiki.answers.com/Q/How_does_Apache_MySQL_and_PHP_work_together
how to proper remove PHP 5.4.12 ….
yum remove ?????
Yes, use yum remove command to remove completely a package from the system.
What should I do in order to install both in different locations but not in default directories like if I want to install under /apps?
And If I want to have two different versions of apache for testing purpose before deleting older one in different directories then will there be any difference in installation procedure?
Yes! use yum to install first version of Apache in default location and compile the second version using source.
Thanks. My doubt is should I delete older version and install latest version or is there any update option for both apache and PHP. If so pls let me know.
Yes! you must delete older versions before compiling new versions. Till now there are no official updates from repositories.
I want to upgrade Apache from 2.4.3 to 2.4.4 and PHP from 5.4.6 to 5.4.14 in RHEL. Can I get steps to accomplish this.
Thanks
Yes! I will soon provide you steps on how to do it. Keep visiting.:)
Thanks Ravi, I am on standby
Hi Ravi,
Any update on this.
Only way to upgrade from older version to newer version using source code. You need to compile and install to get the latest Apache 2.4. Wait for few more days, latest Apache will be available from official repositories.
Need help in solving “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”.
OS RedHat Linux 6 Ent. 64bit x86
Php is not beeing parsed. What can i do? using Centos 6.2
I installed virtualmin, then i followed the steps on this page.
php-cli works fine do
for some reason, i find the following lines in httpd.conf
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
after removing, php works fine.
[kotesh@machine8 Jantakhoj]$ httpd -t
Syntax OK
Error: mysql55-libs conflicts with mysql-libs-5.1.67-1.el6_3.x86_64
Error: Package: php54w-mysql-5.4.13-1.w6.x86_64 (@webtatic)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Removing: mysql55-libs-5.5.29-1.w6.x86_64 (@webtatic)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Updated By: mysql55-libs-5.5.30-1.ius.el5.x86_64 (ius)
Not found
Available: mysql55-libs-5.5.28-1.w6.x86_64 (webtatic)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
Frist, remove the conflicting package with yum like this:
And then try to install again.
I want to access to of my projects simultaneously in the same machine .How can I setup virtual hosts or is their any other ways to that.
You can create as many as virtual hosts same way as shown below. Just add the following lines to your httpd.conf file.
I am getting [FAILED] when I restart my httpd. I want to run two projects on my local machine I dont know whether it can be done using by virtual hosts are not.
Can you post the output of the following command.
The requested URL /conf/myadmin was not found on this server.
Apache Server at 82.165.24.94 Port 80
PHP 5.4.12 (cli) (built: Feb 21 2013 20:17:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
my each step is right but not proper open my phpmyadmin..what the solution
Error: mysql55-libs conflicts with mysql-libs-5.1.67-1.el6_3.x86_64
Worked for me. Thanks.
yum –enablerepo=remi,remi-test install httpd mysql mysql-server php php-common
gives error as
http://rpms.famillecollet.com/enterprise/5.50/remi/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: remi. Please verify its path and try again
Can you tell me which version of OS you using?
CentOS 6.4 – 64 Bit
This Happened To Me As Well. The Problem Is That The First URL In Step #1 Was Coming Up With A “Not Found” Error. If You Load The URL Into A Browser, It Was Redirecting Me To A Mirror That Wasn’t Available.
URL: http://download.fedoraproject.org/pub/epel/6/
Redirected Me To: http://rhn.brown.edu/pub/epel/6/
And I Got This:
Server not found
Firefox can’t find the server at rhn.brown.edu.
If You, However, Type In That Download URL Again, It Will Redirect You Someplace Else. That One Resolved And So I Was Able To Find The File By Following The Links Down. In My Case, It Ended Up Being This:
http://www.gtlib.gatech.edu/pub/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
Once I Had That, Everything Worked Correctly For Me.
-Rick
first of all thanks for the tutorial.
the linke for the libmcrypt is dead :
Error Downloading Packages:
libmcrypt-2.5.7-5.el5.i386: failure: libmcrypt-2.5.7-5.el5.i386.rpm from epel: [Errno 256] No more mirrors to try.
please fix it.
Thanks
Thanks so much! This was incredibly helpful.
I am glad it worked for you….
i wont to start apache but …
[root@hotel526 ~]# /etc/init.d/httpd start
Starting httpd: Syntax error on line 206 of /var/www/vhosts/shikolajme.com/conf/13605257930.90124700_httpd.include:
Wrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper cannot be accessed: (2)No such file or directory
[FAILED]
I think you messed up your PHP installation with Plesk under your CentOS system. To fix such errors do this.
If you don’t have wrappers installed, then install using yum command as show.
That’s it. let me know.
The easiest method to update PHP from older version 5.1.x to 5.3.x & the method is called “NASHOT’s Method”.
================== START ===============================
NASHOT’s Method:
Step 1) Go to GUI mode(X-Windows preferably Gnome desktop) & then “Add/Remove Software section(Package Manager).
Step 2) Click on Search TAB & enter the search string as php & set the radio button to “Installed Packages” & Hit the Search Button.
Step 3) Search result will show existing php modules with Ticked check-boxes at the beginning. It’s something like this:
[/] php-5.1.x…..
[/] php-common-5.1.x……
[/] php-cli-5.1.x……
[/] php-ldap-5.1.x……
Etc…Etc…
Step 4) Now Un-Tick the Check-Boxes from all resulted lines & then Click on Apply Button. This will remove existing PHP version Modules.
Step 5) Inside the “Package Manager” click on Search Tab & enter the search string as php53 & set the radio button to “All Packages” & Hit Search Button.
Step 6) Search shows many Result lines related to new PHP version 5.3.x with Un-Ticked Check-Box before each line.
Step 7) Now Tick the Check-Boxes from all resulted lines & then Click on Apply Button.
Now “Package Manager” will begins to check for Dependancy Modules for Selected PHP Modules & Downloads the new PHP 5.3.x package modules & then installs Automatically.
Now Restart your system & check the version of the installed PHP Version by using “php -v” command & result should be PHP 5.3.x
Please NOTE: If your installation halts at “Checking Dependancy”, then check for selection of “PHP53-odbc64-5.3.x…..”. Actually there are 2 odbc packages & each meant for 32bit & 64bit version of OS. So select only ONE odbc package which is compatible with your OS.
=================== END ==============================
Really great post! Very helpful.
Hello,
Very nice post…
for my sql on phpinfo page, i am getting an
Client API version 5.1.66
First replace old php version using.
Then install latest version as described in the article.
you guys are life savers, good stuff. it worked on the first go
how to install Apache web server in fedaro13..
i have an tar file..
Why you want to install via tar file. just run the following command to install Apache.
short_tag php5 configuration
Help Me.
Set the following variable in your php.ini file, If you don’t have access to the php.ini, you can add it to .htaccess file.
Restart your Apache server.
I follow the steps then.
i can’t connect to mysql with php
Ok. Thakyou
What error you getting, can you post here, did you restart the MySQL service.
It’s not explicitly stated in the guide above you have to do this. But you have to start the mysql server.
Do this:
chkconfig –levels 235 httpd on
so that mysql server starts on restart.
then either use:
service mysqld start
or
/etc/init.d/mysqld start
phpMyAdmin – Error
The mysqli extension is missing. Please check your PHP configuration.
Help me please.
Please install extension like.
# yum –enablerepo=remi,remi-test install php-mysql
This worked for me.
I am trying to install wine in redhat 5.4 – 64 bit from last week but i can’t install please help me with step by step installation procedure.
Hey Ravi,
I am new to linux, Thanks for the steps i followed the steps but while checking the phpinfo i am getting php code of the file,
Linux version – Redhat enterprise linux 5.4
While checking with the command php -v its giving me 5.2.17 version not the installed one, do i need to uninstall previous version first?
Please let me know if you need any other information to help me
Please remove the older version of PHP, and then follow the commands again and let me know.
Very helpful!
Thanks
well i am using cent os 6.3 32 bit there is a problem when iam trying to install the php module
Error: Package: mysql-server-5.1.61-4.el6.i686 (tejas-barot-wine)
Requires: mysql = 5.1.61-4.el6
Installed: mysql-5.5.29-1.el6.remi.i686 (@remi)
mysql = 5.5.29-1.el6.remi
Available: mysql-5.1.61-4.el6.i686 (tejas-barot-wine)
mysql = 5.1.61-4.el6
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
what i wl do ?
Remove old version of mysql using:
and then follow the steps again..
indeed Impressive repository and post KB to convert fresh linux distro into productive web server in few minutes !
It rocks flawless.
Thanks Ravi.
Great tip, it’s was very useful today during a CentOS 6 config :)
Thanks.
Thank you so much for creating this tutorial. I am having to install various content management systems on a RedHat 6 server for testing. After installing PHP, mysql and Apache before starting the install of the systems, discovered that one of them needed php mbstring enabled. I found other search results but I realized a reinstall of PHP was needed and this tutorial efficiently helped me exactly do that.
Your site is now going to be among those I look directly for help and look at daily with my other tech resources.
Thanks,
James
Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
showing an error while connecting mysql
edit the /etc/my.cnf
change the ‘/tmp/mysql.sock’ become ‘/var/lib/mysql/mysql.sock’
it’s work for me :)
/etc/init.d/mysqld start not a directory…wat to do
which Linux version you using? have you installed MySQL and restarted?
FYI – it isn’t mentioned because it is assumed a fresh install, but it also works with an upgrade. You just need to remember to run “mysql_upgrade” from the command line after the upgrade to fix the privileges and performance_schema.
Thanks very much. Easy to follow, no hassles. Upgraded my Virtualmin box this morning and no problems.
thanks a lot
Thanks very much
what is the root password of mysql?
@Gary
If it is fresh MySQL installation, then password would be blank.. or you can set password using following command.
Or to change MySQL password use.
Thanks so much everything ok.
thanks agains.