Skip to content

Phils Blog and Stuff

TELECOMS. VIRTUALIZATION. IT. CODING. and more…

Menu
  • Home
  • Resources
    • Subnet Mask Cheat Sheet
    • Easy Dmarc+Email
    • MX Tool Box
    • LOAD BALANCING & SRE
  • SHOP
  • SOLUTIONS
  • SERVICES
  • Contact Me
Menu

CentOS 6 LAMP Install (Apache MySQL & PHP) via YUM

Posted on 22/04/201208/03/2023 by Phil

This tutorial will walk you through the process of installing a CentOS 6 LAMP server, LAMP stands for Linux Apache MySQL PHP and is often refereed to as a “LAMP Stack“. CentOS is a popular choice for web servers as it’s based on RHEL (Redhat Linux), this tutorial will use YUM to install the required packages.

This guide assumes you have a working fully updated CentOS 6 system with root access, if not see our CentOS 6 Netinstall tutorial.

CentOS Apache Install via YUM

The first step is to install the Apache web server, RHEL based distributions call this package httpd not Apache. Often admins get this command wrong and type “yum install apache” or “yum install apache2″ – the correct command to install Apache on CentOS is:

yum install httpd

Start Apache on CentOS:

/etc/init.d/httpd start

Add MySQL to start at boot type the following:

chkconfig httpd on

CentOS MySQL install via YUM

Enter the following command to install CentOS MySQL Server and client via YUM:

yum install mysql-server mysql

Start MySQL on CentOS type:

/etc/init.d/mysqld start

Add MySQL to start at boot type the following:

chkconfig mysqld on

CentOS Install PHP php-mysql via YUM

To install PHP and php-mysql (php-mysql is required so that PHP can talk to MySQL) on CentOS 6 type:

yum install php php-mysql

FYI here is the full CentOS LAMP command (this will install Apache, MySQL PHP all in one go):

yum install httpd php php-mysql mysql mysql-server

If you did everything right above you should see the CentOS test page if you browse to http://localhost (or your servers IP if you are on another box). If you don’t see a page below and it simply does not load chances are iptables is blocking httpd traffic you should configure iptables to allow httpd traffic however for now you  may want to disable the CentOS firewall.

CentOS Apache Install Default Page

I would recommend creating a file called index.php in /var/www/html/ and adding the following code to it:

?php phpinfo(); ?

This should give you an output similar to:

CentOS PHP Install - phpinfo output

If you see the above output all is will and you can install your web apps or start building them, if you have any problems and need help please drop me a comment below.

POSTS

  • Home Assistant. Add water meter with PHP+MQTT+YML.
  • Automating your home with Home Assistant. Initial install and config (Hyper-V).
  • The importance of setting up email security correctly.
  • Automate Debian installations with Seed, DHCP and Nginx.
  • A simple link shortener.. Fun little project…

WORD CLOUD

3CX 3CX Phone System Apache Asterisk Cacti CentOS CRM DHCP DNS Email Fail over Failover File System Firewall FreeBSD FreeNAS FXO IAX install IP IP PBX Linux M0n0wall Nottingham Open Source PBX PFSense PHP Router Server SIP snom SSH TrixBox ubuntu VLAN Voice VoIP VPN vyatta WAN Website WiFi yealink ZFS

© 2025 Phils Blog and Stuff | Powered by Superbs Personal Blog theme