Skip to content

Instantly share code, notes, and snippets.

@zhiephie
Last active May 3, 2020 10:39
Show Gist options
  • Save zhiephie/c1286d6f4a6b0b2faa331118612d62e3 to your computer and use it in GitHub Desktop.
Save zhiephie/c1286d6f4a6b0b2faa331118612d62e3 to your computer and use it in GitHub Desktop.
Installing nginx, php7-fpm with opcache, memcached, phpredis and xdebug extension on Centos 7

run ./setup.sh

Install Nginx

# yum repository  
$ vim /etc/yum.repos.d/nginx.repo
  [nginx]
  name=nginx repo
  baseurl=http://nginx.org/packages/centos/7/$basearch/
  gpgcheck=0
  enabled=1
# install nginx
$ sudo yum update && install nginx -y
# enable nginx
$ sudo systemctl enable nginx
# start nginx
$ sudo service nginx start

Install PHP 7 & Zend Opcache

$ sudo yum install php70u-fpm php70u-opcache php70u-cli php70u-xml php70u-fpm-nginx php70u-devel php70u-gd php70u-mysqlnd php70u-mbstring php70u-common php70u-pdo php70u-json php70u-intl php70u-mcrypt

Install Memcached

$ sudo yum groupinstall -y "Development Tools"
$ sudo yum install -y libmemcached-devel
$ git clone https://github.com/php-memcached-dev/php-memcached
$ cd php-memcached
$ git checkout -b php7 origin/php7
$ phpize
$ ./configure --with-php-config=php-config
$ sudo make && make install
$ vim /etc/php.d/mod-external.ini
$. echo " extension=memcached.so" >> /etc/php.d/mod-external.ini

Install Redis

$ git clone https://github.com/phpredis/phpredis.git
$ cd phpredis
$ git checkout php7
$ phpize
$ ./configure
$ sudo make && make install
$ echo " extension=redis.so" >> /etc/php.d/mod-external.ini

Install Xdebug

$ wget -c "http://xdebug.org/files/xdebug-2.4.0.tgz"
$ tar -xf xdebug-2.4.0.tgz
$ cd xdebug-2.4.0
$ phpize
$ ./configure
$ sudo make && make install
$ echo "zend_extension=xdebug.so" >> /etc/php.d/mod-external.ini
#!/bin/bash
el5_download_install(){
wget -O /tmp/release.rpm ${1}
yum -y localinstall /tmp/release.rpm
rm -f /tmp/release.rpm
}
centos_install_epel(){
# CentOS has epel release in the extras repo
yum -y install epel-release
import_epel_key
}
rhel_install_epel(){
case ${RELEASE} in
5*) el5_download_install https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm;;
6*) yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm;;
7*) yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm;;
esac
import_epel_key
}
import_epel_key(){
case ${RELEASE} in
5*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL;;
6*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6;;
7*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7;;
esac
}
centos_install_ius(){
case ${RELEASE} in
5*) el5_download_install https://centos5.iuscommunity.org/ius-release.rpm;;
6*) yum -y install https://centos6.iuscommunity.org/ius-release.rpm;;
7*) yum -y install https://centos7.iuscommunity.org/ius-release.rpm;;
esac
import_ius_key
}
rhel_install_ius(){
case ${RELEASE} in
5*) el5_download_install https://rhel5.iuscommunity.org/ius-release.rpm;;
6*) yum -y install https://rhel6.iuscommunity.org/ius-release.rpm;;
7*) yum -y install https://rhel7.iuscommunity.org/ius-release.rpm;;
esac
import_ius_key
}
import_ius_key(){
rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
}
if [[ -e /etc/redhat-release ]]; then
RELEASE_RPM=$(rpm -qf /etc/redhat-release)
RELEASE=$(rpm -q --qf '%{VERSION}' ${RELEASE_RPM})
case ${RELEASE_RPM} in
centos*)
echo "detected CentOS ${RELEASE}"
centos_install_epel
centos_install_ius
;;
redhat*)
echo "detected RHEL ${RELEASE}"
rhel_install_epel
rhel_install_ius
;;
*)
echo "unknown EL clone"
exit 1
;;
esac
else
echo "not an EL distro"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment