Skip to content

Instantly share code, notes, and snippets.

@shearluck
Forked from mikestecker/lamp-setup.md
Last active August 29, 2015 14:06
Show Gist options
  • Save shearluck/1c677f07d2c54595cd01 to your computer and use it in GitHub Desktop.
Save shearluck/1c677f07d2c54595cd01 to your computer and use it in GitHub Desktop.

Install Apache/PHP 5.5.9 on Fedora 20/19, CentOS/RHEL 6.5/5.10

This guide shows howto install Apache HTTP Server (httpd) with PHP 5.5.9 and following modules on Fedora 20/19/18/17, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.10 and Red Hat (RHEL) 6.5/6.4/6.3/6.2/6.1/6/5.10 systems.

  1. Change root user

su -
## OR ##
sudo -i
  1. Install Remi repository

Fedora

## Remi Dependency on Fedora 20 / 19 / 18 / 17 ##
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

## Fedora 20 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-20.rpm

## Fedora 19 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-19.rpm

## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm

## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm


## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

## CentOS 5 and Red Hat (RHEL) 5 ## 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
  1. Install Apache (httpd) Web server and PHP 5.5.9

Fedora 20/19

yum --enablerepo=remi install httpd php php-common

Fedora 18/17

yum --enablerepo=remi,remi-test install httpd php php-common

CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

yum --enablerepo=remi,remi-php55 install httpd php php-common
  1. Install PHP 5.5.9 modules

Select what you need: APC, CLI, PEAR, PDO, MySQL, PostgreSQL, MongoDB, SQLite, Memcache, Memcached, GD, MBString, MCrypt, XML More info about PHP APC from PHP APC Configuration and Usage Tips and Tricks.

Fedora 20/19

yum --enablerepo=remi install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

Fedora 18/17

yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

yum --enablerepo=remi,remi-php55 install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
  1. Start Apache HTTP server (httpd) and autostart Apache HTTP server (httpd) on boot

/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update

## Fedora ##
systemctl enable httpd.service

## CentOS / RHEL ##
chkconfig --levels 235 httpd on
  1. Create test PHP page to check that Apache, PHP and PHP modules are working

Add following content to /var/www/html/test.php file.

<?php
    phpinfo();
  1. Check created page with browser

Access following address, with your browser. http://localhost/test.php


Enable Remote Connection to Apache HTTP Server (httpd) –> Open Web server Port (80) on Iptables Firewall (as root user again)

  1. CentOS/Red Hat (RHEL)

  2. Edit /etc/sysconfig/iptables file: nano -w /etc/sysconfig/iptables

  3. Add following INPUT rule: -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  4. Restart Iptables Firewall: service iptables restart ## OR ## /etc/init.d/iptables restart

  5. Fedora

  6. Add New Rule to Firewalld: firewall-cmd --permanent --zone=public --add-service=http ## OR ## firewall-cmd --permanent --zone=public --add --port=80/tcp

  7. Restart Iptables systemctl restart iptables.service

  8. Test remote connection Access following address, with your browser. http://your.domain/test.php


Install MySQL 5.5 using Yum

yum --enablerepo=remi install mysql mysql-server

After installing MysQL server packages, start the service and execute following command for applying initial security. Execute below command and follow the instructions.

service mysqld start

Execute mysql_secure_installation script and follow the wizard. It will prompt for root password. To get temporary root password check ‘/root/.mysql_secret’ file

/usr/bin/mysql_secure_installation

Autostart MySQL on boot

chkconfig mysqld on

Now you have successfully installed MySQL. Login to MySQL using root access and try to create a dummy database. The root user password can be found in /root/.mysql_secret.

mysql -u root -p

Create a dummy database using following command.

mysql> create database dummydb;
Query OK, 1 row affected (0.01 sec)

Install phpMyAdmin

phpMyAdmin is a free open source web interface tool, used to manage your MySQL databases. By default phpMyAdmin is not found in CentOS official repositories. So let us install it using EPEL repository.

To install EPEL repository, follow the below link:

Now install phpMyAdmin

yum install phpmyadmin -y

Configure phpMyAdmin Edit the phpmyadmin.conf file.

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

Find and comment the whole / section as shown below:

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

#<Directory /usr/share/phpMyAdmin/>
#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     Require local
#   </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>
[...]

Open “config.inc.php” file and change from “cookie” to “http” to change the authentication in phpMyAdmin:

cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php 
vi /usr/share/phpMyAdmin/config.inc.php

Change cookie to http.

[...] 
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

Restart the Apache service:

service httpd restart

Now you can access the phpmyadmin console by navigating to http://server-ip-address/phpmyadmin/ from your browser.

Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “centos”.

Now you will able to manage your MariaDB databases from phpMyAdmin web interface.


Install Redis cache on CentOS and Redhat

wget http://download.redis.io/releases/redis-2.8.6.tar.gz
tar -zxvf redis-2.8.6.tar.gz
cd redis-2.8.6
make

Once you installed it without any error move two Redis files into the /usr/local/bin/ directory...

cd src
cp redis-server /usr/local/bin/
cp redis-cli /usr/local/bin/

Now time to move default init script and configuration file's.

cd utils/
cp redis_init_script /etc/init.d/redis
cd ..
cp redis.conf /etc/

After that edit the redis.conf file and make certain changes.

vi /etc/redis.conf
  • Set daemonize yes
  • Set bind to loop back ip address[127.0.0.1]
  • Set logfile /var/log/redis.log default set to /dev/null
  • Set pidfile /var/run/redis.pid
  • Set LogLevel to Debug to debug issue
  • Set the number of databases on a per connection basis. The default value is 0
  • Set maxmemory as per requirement.

Now download install and configure phpredis

git clone git://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure
make && make install

Edit create redis.ini into the /etc/php.d/ directory. Add extensions redis.so in file.

extension=redis.so

Redis installation is completed

Restart Apache

service httpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment