How to Install nginx and PHP on CentOS7

February 6, 2017

Install nginx and PHP on CentOS7

These are some notes from installing nginx on CentOS7

Install some prerequisites

sudo yum -y groupinstall "Development tools"
sudo yum -y install mlocate
sudo yum -y install iptables-services
sudo yum -y install php-mysql php-dom
sudo yum -y install wget
sudo service php-fpm restart

Install GeoIP

cd /tmp
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar -zxvf GeoIP.tar.gz
cd GeoIP
cd GeoIP-1.4.8/
make
./configure
make
sudo make install

Install PCRE

mkdir -p ~/src; cd ~/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar -zxf pcre-8.40.tar.gz
cd pcre-8.40/
./configure
make
sudo make install
cd ..

Install zlib

mkdir -p ~/src; cd ~/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
sudo make install
cd ..

Install openSSL

mkdir -p ~/src; cd ~/src
wget http://www.openssl.org/source/openssl-1.0.2f.tar.gz
tar -zxf openssl-1.0.2f.tar.gz
cd openssl-1.0.2f
./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic
make
make install_sw
sudo make install_sw
cd ..

Install nginx from ~/src

cd ~/src
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar zxf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure --prefix=/opt/nginx  --user=nginx  --group=nginx  --without-http_browser_module  --with-debug  --with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11 --with-http_ssl_module --with-stream  --without-http_charset_module  --http-log-path=/var/log/nginx/access.log  --http-client-body-temp-path=/var/tmp/nginx    /client/  --http-proxy-temp-path=/var/tmp/nginx/proxy/  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/  --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi/  --http-scgi-temp-path=/var/tmp/nginx/scgi/  --with-http_stub_status_module  --with-http_sub_module  --without-mail_pop3_module  --without-mail_imap_module      --without-mail_smtp_module  --with-http_geoip_module  --without-http_ssi_module  --without-http_autoindex_module  --with-google_perftools_module
sudo make install
sudo ln -s /opt/nginx/sbin/nginx /usr/sbin/nginx
sudo nginx
useradd nginx
sudo useradd nginx
mkdir -p /var/tmp/nginx/client/
sudo chown -R nginx:nginx /var/tmp/nginx/client/
sudo nginx
curl 127.0.0.1