Shell Script - Setup PHP 7.3, Apache on centos 7

You can use this script to setup PHP environment with apache server having all required modules for running your project.

 

#!/bin/bash
# Script Purpose: To setup apache Server and PHP enviornement to run the application

yum clean all
rm -rf /var/cache/yum/*
yum install -y \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

#yum install -y https://$(rpm -E '%{?centos:centos}%{!?centos:rhel}%{rhel}').iuscommunity.org/ius-release.rpm
#yum install -y https://repo.ius.io/ius-release-el7.rpm
#yum install -y http://download.fedoraproject.org/pub/epel/epel-release-7-11.noarch.rpm
#yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/epel-release-7-11.noarch.rpm
yum update -y
yum -y install curl wget unzip git vim nano iproute python-setuptools hostname yum-utils which make
yum -y install httpd
yum -y install mod_php73 php73-common php73-cli
yum -y install php73-gd php73-ldap php73-mbstring php73-mysqlnd php73-soap php73-embedded
yum -y install php73-php-bcmath php73-opcache php73-xml php73-process php73-pdo php73-devel php73-json
yum -y install gcc ImageMagick ImageMagick-devel ImageMagick-perl


#Setup Imagick library
cd /tmp
echo "Current working directory is is $(pwd)"
wget https://pecl.php.net/get/imagick-3.4.4.tgz
tar xvf imagick-3.4.4.tgz
cd imagick-3.4.4
echo "Current working directory is $(pwd)"
ech "List of files in current directory is = $(ls)"
echo "Executing ./configure"
phpize
./configure
make
make install
echo extension=imagick.so >> /etc/php.ini


# Install composer
cd /tmp
echo "Current working directory is = $(pwd)"
curl -sS https://getcomposer.org/installer | php
mv /tmp/composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

# Create phpinfo file
echo '<?php phpinfo(); ?>' >> /var/www/html/phpinfo.php

# Configure php.ini
sed -i -e "s/short_open_tag = Off/short_open_tag = On/" /etc/php.ini

 

Tags