diff --git a/Dockerfile b/Dockerfile index 6dcc61e..ecece1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,19 +4,32 @@ ############################################################ # Set the base image to Ubuntu -FROM centos:latest - -# File Author / Maintainer -MAINTAINER Kaushal Kishore - -# Add the ngix and PHP dependent repository -ADD nginx.repo /etc/yum.repos.d/nginx.repo +FROM centos:7 +ENV nginxversion="1.12.2-1" \ + os="centos" \ + osversion="7" \ + elversion="7_4" # Installing nginx -RUN yum -y install nginx +RUN yum install -y wget openssl sed &&\ + yum -y autoremove &&\ + yum clean all &&\ + wget http://nginx.org/packages/$os/$osversion/x86_64/RPMS/nginx-$nginxversion.el$elversion.ngx.x86_64.rpm &&\ + rpm -iv nginx-$nginxversion.el$elversion.ngx.x86_64.rpm + +# forward request and error logs to docker log collector +RUN ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log # Installing PHP -RUN yum -y --enablerepo=remi,remi-php56 install nginx php-fpm php-common +RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm +RUN yum -y install php56w php56w-cli php56w-common php56w-fpm \ + yum -y autoremove &&\ + yum clean all +# Installing PHP +RUN yum -y install php56w-bcmath php56w-dba php56w-devel php56w-embedded php56w-enchant php56w-gd php56w-imap php56w-interbase php56w-intl php56w-ldap php56w-mbstring php56w-mcrypt php56w-mssql php56w-mysql php56w-odbc php56w-opcache php56w-pdo php56w-pecl-apcu php56w-pecl-apcu-devel php56w-pecl-gearman php56w-pecl-geoip php56w-pecl-igbinary php56w-pecl-igbinary-devel php56w-pecl-imagick php56w-pecl-imagick-devel php56w-pecl-libsodium php56w-pecl-memcache php56w-pecl-memcached php56w-pecl-mongodb php56w-pecl-redis php56w-pecl-xdebug php56w-pgsql php56w-phpdbg php56w-process php56w-pspell php56w-recode php56w-snmp php56w-soap php56w-tidy php56w-xml php56w-xmlrpc \ + yum -y autoremove &&\ + yum clean all # Installing supervisor RUN yum install -y python-setuptools @@ -33,7 +46,7 @@ ADD supervisord.conf /etc/ # Adding the default file ADD index.php /var/www/index.php - +ADD php-fpm.conf /etc/php-fpm.conf # Set the port to 80 EXPOSE 80 diff --git a/default.conf b/default.conf index b60909c..c68728f 100644 --- a/default.conf +++ b/default.conf @@ -1,14 +1,13 @@ server { - listen 80; + listen 80 default_server; root /var/www; index index.html index.htm index.php; - # Make site accessible from http://set-ip-address.xip.io server_name localhost; - access_log /var/log/nginx/localhost.com-access.log; - error_log /var/log/nginx/localhost.com-error.log error; + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log error; charset utf-8; @@ -16,11 +15,6 @@ server { try_files $uri $uri/ /index.html /index.php?$query_string; } - location = /favicon.ico { log_not_found off; access_log off; } - location = /robots.txt { access_log off; log_not_found off; } - - error_page 404 /index.php; - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { diff --git a/nginx.repo b/nginx.repo deleted file mode 100644 index 6a65dce..0000000 --- a/nginx.repo +++ /dev/null @@ -1,25 +0,0 @@ -[nginx] -name=nginx repo -baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ -gpgcheck=0 -enabled=1 - -## Remi Dependency on CentOS 7 and Red Hat (RHEL) 7 ## -rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm - -## CentOS 7 and Red Hat (RHEL) 7 ## -rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm - - -## 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 diff --git a/php-fpm.conf b/php-fpm.conf new file mode 100644 index 0000000..662da3e --- /dev/null +++ b/php-fpm.conf @@ -0,0 +1,25 @@ +; This file was initially adapated from the output of: (on PHP 5.6) +; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default + +[global] + +error_log = /proc/self/fd/2 +daemonize = no + +[www] + +; if we send this to /proc/self/fd/1, it never appears +access.log = /proc/self/fd/2 + +user = apache +group = apache + +listen = [::]:9000 + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +clear_env = no \ No newline at end of file diff --git a/supervisord.conf b/supervisord.conf index 5eb2fb8..abb6f92 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -11,19 +11,22 @@ nodaemon=true ; (start in foreground if true;default false) supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:php5-fpm] -command=/usr/sbin/php-fpm -c /etc/php-fpm.d +command=/usr/sbin/php-fpm -F -c /etc/php-fpm.d numprocs=1 autostart=true autorestart=true - -[program:php5-fpm-log] -command=tail -f /var/log/php5-fpm.log -stdout_events_enabled=true -stderr_events_enabled=true +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 [program:nginx] command=/usr/sbin/nginx numprocs=1 -autostart=true autorestart=true +autorestart=true +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0