Redhat / Centos LAMP Setup Guide

If you're setting up a RedHat or Centos server from a VPS server without a control panel, setting up a LAMP (Linux, Apache, MySQL and PHP) can be a nuisance. Here is a basic setup guide for bringing your Linux server for LAMP development environment.

RedHat / Centos 7

# yum install php mysql mysql-server php-pecl php-mysql php-pear 
php-pdo php-gd php-mbstring php-mcrypt php-xml httpd gd mariadb
mariadb-server

# systemctl start httpd.service
# systemctl enable httpd.service
# systemctl start mariadb.service
# systemctl enable mariadb.service
# /usr/bin/mysql_secure_installation

// Edit Apache Configuration Files.
# vi /etc/httpd/conf.d/phpMyAdmin.conf
# vi /etc/phpMyAdmin/config.inc.php

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

RedHat / Centos 6

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

# cd /etc/yum.repos.d
// edit remi.repo, enable=1

# yum update
# yum install php mysql mysql-server php-pecl php-mysql php-pear 
php-pdo php-gd php-mbstring php-mcrypt php-xml httpd gd php-gd

# service mysqld start
# /usr/bin/mysqladmin -u root password 'new-password'
// Edit /root/.my.cnf
[client]
user=root
password=new-password
host=127.0.0.1
-- End of edit.

# chmod 600 /root/.my.cnf

// Create a file, /usr/local/bin/watchdog.sh
#! /bin/sh

for p in httpd mysqld
do
    /usr/bin/pgrep $p >/dev/null
    if [ $? -ne 0 ]
    then
        echo "$p is not running."
        /sbin/service $p restart
    fi
done
-- End of Edit.

Check system date and time zone.
# date
Thu Apr  7 11:35:34 CDT 2011
// Remove /etc/localtime, and make a soft link to desired time zone.
# ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

# chmod +x /usr/local/bin/watchdog.sh

# chkconfig httpd on
# chkconfig mysqld on

// Edit /etc/httpd/conf/httpd.conf
// Create Virtual hosts.

# crontab -e
0 0 * * * /usr/sbin/ntpdate clock.redhat.com
*/10 * * * * /usr/local/bin/watchdog.sh

// Edit /etc/php.ini
// Uncomment date.timezone
date.timezone = "US/Central"

Comments

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.