I am running a Docker. Here is my docker file.
FROM php:5.6-apache
RUN apt-get update && apt-get install -my wget gnupg
RUN apt-key adv \
--keyserver hkp://keyserver.ubuntu.com:80 \
--recv 7F0CEB10
RUN echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
RUN apt-get update
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libmcrypt-dev \
libssl-dev
RUN apt-get install -y libmariadbclient-dev
RUN docker-php-ext-install iconv mcrypt mysqli pdo_mysql mysql zip mbstring
RUN pecl install mongo
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin --filename=composer
RUN sed -i 's/^ServerSignature/#ServerSignature/g' /etc/apache2/conf-enabled/security.conf; \
sed -i 's/^ServerTokens/#ServerTokens/g' /etc/apache2/conf-enabled/security.conf; \
echo "ServerSignature Off" >> /etc/apache2/conf-enabled/security.conf; \
echo "ServerTokens Prod" >> /etc/apache2/conf-enabled/security.conf; \
a2enmod ssl; \
a2enmod headers; \
echo "SSLProtocol ALL -SSLv2 -SSLv3" >> /etc/apache2/apache2.conf
RUN apt-get install -y vim
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip3 install numpy
RUN pip3 install scipy
RUN pip3 install image_match
RUN pip3 install opencv-python
RUN pip3 install pytube
RUN pip3 install ez_setup
RUN pip3 install moviepy
RUN pip3 install requests
RUN pip3 install ffmpeg-python
RUN apt update && apt install -y libsm6 libxext6
RUN apt-get install -y libxrender-dev
RUN apt-get update
COPY config/mongo.ini /usr/local/etc/php/conf.d/
ENV VERSION 8
ENV UPDATE 91
ENV BUILD 14
In one my PHP Page, I want to Run a python script. for e.g.
$command = escapeshellcmd('python integrateFinal.py');
$joutput = shell_exec($command);
$output=json_decode($joutput);
The python script works fine with the command line as 'docker-compose exec web python3 integrateFinal.py'. It works and gives the output but when I run it from PHP page mentioned above It gives me error as permission denied.
So How should I run this PYTHON script?
Related
I need help, I can’t install pdo_mysql, ampq or opcache with docker-php-ext-install. I prepared a docker project on a local PC (Mac OSX). On the local PC after build docker image is the final PHP configuration right. When I deploy the project config to the remote Debian server after building it, I have a completely different PHP version (phpinfo). Missing extensions opcache, pdo_mysql, ampq.
I tried to configure it differently and deleted the docker cache on the server, but it didn’t help.
docker system prune -a
My PHP dockerfile:
FROM php:7.4-fpm
WORKDIR /var/www/symfony
RUN apt-get update \
&& docker-php-ext-install mysqli pdo pdo_mysql \
&& docker-php-ext-enable pdo_mysql
RUN apt update && apt-get udpate \
&& apt install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip libxslt1-dev\
&& docker-php-ext-install intl \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip \
&& docker-php-ext-install xsl
RUN apt-get update \
&& docker-php-ext-install opcache
RUN apt-get update \
&& apt-get install -y \
librabbitmq-dev \
libssh-dev \
&& pecl install amqp \
&& docker-php-ext-enable amqp
RUN apt-get update && \
apt-get install -y libxml2-dev \
&& docker-php-ext-install soap
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x -o node_setup.sh && \
bash node_setup.sh && \
apt-get install -y nodejs && \
npm install npm -g
# Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
RUN apt-get update && apt-get install -y cron
ADD ./crontab /etc/cron.d/crontab
#
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
RUN apt-get update && apt-get install -y supervisor
ADD ./supervisord.conf /etc/supervisor/
# Copy docker entrypoint file
COPY ./entrypoint.sh /entrypoint.sh
# Docker init
RUN ["chmod", "+x", "/entrypoint.sh"]
Not sure if it's a solution to your issue, but let's see.
From https://hub.docker.com/_/php:
If you are having difficulty figuring out which Debian or Alpine packages need to be installed before docker-php-ext-install, then have a look at the install-php-extensions project. This script builds upon the docker-php-ext-* scripts and simplifies the installation of PHP extensions by automatically adding and removing Debian (apt) and Alpine (apk) packages. For example, to install the GD extension you simply have to run install-php-extensions gd. This tool is contributed by community members and is not included in the images, please refer to their Git repository for installation, usage, and issues.
I had similar issues in the past and resolved it by using install-php-extensions. See this comment.
My docker file which is building successfully but in the time of login, getting this error "Uncaught Exception. could not find driver".
Application is using PDO extension for php to connect sql server.
FROM php:7.3-apache
# Env variables
ENV ACCEPT_EULA=y
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install apt-utils libxml2-dev gnupg apt-transport-https \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install git
RUN apt-get update \
&& apt-get -y install git \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
#Install ODBC Driver
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update
# Install sqlsrv
RUN apt-get update
RUN apt-get install -y wget
RUN wget http://ftp.br.debian.org/debian/pool/main/g/glibc/multiarch-support_2.24-11+deb9u4_amd64.deb && \
dpkg -i multiarch-support_2.24-11+deb9u4_amd64.deb
RUN apt-get -y install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv pdo_sqlsrv
# Install webapp extension
RUN apt-get update && \
apt-get install -y \
git libzip-dev libicu-dev\
&& docker-php-ext-install zip
RUN docker-php-ext-install intl mysqli pdo pdo_mysql
RUN a2enmod rewrite
COPY php.ini /usr/local/etc/php
COPY . /var/www/html/
EXPOSE 80/tcp
#EXPOSE 443/tcp
I have also added pdo extension entries for sqlsrv in my php.ini file
extension=pdo_sqlsrv.so
extension=sqlsrv.so
I am trying to build an image in docker but after it compiles, I execute docker-compose up and it exits.
The docker file that I am using contains the next instructions:
FROM circleci/php:7.3-cli-node-browsers
USER root
WORKDIR /var/www/html
RUN apt-get update && apt-get install -y \
libpng-dev \
zlib1g-dev \
zip \
curl \
&& docker-php-ext-install gd \
&& apt-get install -y zip \
&& apt-get install -y unzip \
&& apt-get install -y git \
&& apt install -y libsqlite3-dev zlib1g-dev \
&& docker-php-ext-install bcmath && docker-php-ext-enable bcmath \
&& docker-php-ext-install pcntl \
&& apt-get install -y --no-install-recommends libmagickwand-dev \
&& docker-php-ext-install exif \
&& pecl install imagick \
&& docker-php-ext-enable imagick
RUN pecl install redis && docker-php-ext-enable redis
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/html
COPY / /var/www/html
RUN composer self-update
RUN composer install -n --prefer-dist
RUN npm install
RUN npm run test
RUN chmod -R 777 /var/www/html
RUN chmod -R o+w /var/www/html/storage
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
This a laravel project, with node and Redis. Any ideas why it is not working?
Thank in advance for your help.
Your entrypoint finally call apache, but you even did not install apache in your docker image.
So, you need do next:
Install apache2 in Dockerfile:
RUN apt-get install -y apache2
Correctly launch apache2 in docker-entrypoint.sh:
echo "--> Starting app"
. /etc/apache2/envvars
mkdir -p /var/run/apache2
exec apache2 -D FOREGROUND
I have a PHP-CLI Docker image of Debian Buster and would like to install php-imagick package but with command:
Dockerfile:
RUN apt-get install -y php-imagick
I get an error:
Package php-imagick is not available, but is referred to by another
package. This may mean that the package is missing, has been
obsoleted, or is only available from another source
E: Package 'php-imagick' has no installation candidate
running before:
RUN apt-get update -y && apt-get upgrade -y
did not help.
how come there is no package candidate for php-imagick?
how to install and enable imagick extension for this PHP Docker image?
Dockerfile to replicate issue:
FROM php:7.3-buster
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y php-imagick
build command
docker build --tag testimage .
Unless you have a good reason not to, using the packages from https://deb.sury.org/ is probably a good idea. The following appears to work:
FROM debian:buster-slim
USER root
# Get Debian up-to-date
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y git \
mariadb-client wget curl \
ca-certificates lsb-release apt-transport-https gnupg bsdmainutils
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/php.list \
&& curl https://packages.sury.org/php/apt.gpg | apt-key add - \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y php7.3 php7.3-common php7.3-cli \
php7.3-mysql php7.3-curl php7.3-xml php7.3-mbstring \
php7.3-intl php7.3-redis php7.3-zip \
php7.3-imagick supervisor
I have a docker file that I am basing from the php:5.5.36-apache image, for creating image expressly for development. My Dockerfile installs memcached but I am having no luck getting memcached to start on boot. If I ssh into the container and start memcached manually, it starts just fine.
FROM php:5.5.36-apache
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
default-jdk
RUN apt-get install -y --no-install-recommends autoconf
RUN apt-get install -y --no-install-recommends python python-pip
RUN apt-get update && apt-get install -y libmemcached-dev \
apt-utils re2c g++ memcached \
zlib1g zlib1g-dbg zlib1g-dev zlibc mysql-client php5-mysql \
&& pecl install memcached \
&& docker-php-ext-enable memcached\
&& pecl install memcache \
&& docker-php-ext-enable memcache
RUN docker-php-ext-install pdo pdo_mysql
RUN apt-get install -y gettext
RUN pip install hgapi
RUN a2enmod headers \
&& a2enmod rewrite
COPY ./apache2.conf /etc/apache2/apache2.conf
RUN mkdir /var/www/content
EXPOSE 11211
RUN systemctl enable memcached.service
The base image is based on debian:jessie
This link worked for me for the same issue with php5, apache2 and memcached in a Dockerfile based on ubuntu:
https://github.com/moby/moby/issues/5137
Install supervisor
RUN apt-get install -y supervisor
and config that in Dockerfile:
RUN touch /etc/supervisor/conf.d/supervisord.conf && \
echo "[supervisord]" >> /etc/supervisor/conf.d/supervisord.conf && \
echo "nodaemon=true" >> /etc/supervisor/conf.d/supervisord.conf
RUN touch /etc/supervisor/conf.d/memcached.conf && \
echo "[program:memcache]" >> /etc/supervisor/conf.d/memcached.conf && \
echo "command=/usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -DFOREGROUND" >> /etc/supervisor/conf.d/memcached.conf && \
echo "autostart=true" >> /etc/supervisor/conf.d/memcached.conf && \
echo "autorestart=true" >> /etc/supervisor/conf.d/memcached.conf
RUN touch /etc/supervisor/conf.d/apache2.conf && \
echo "[program:apache2]" >> /etc/supervisor/conf.d/apache2.conf && \
echo 'command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"' >> /etc/supervisor/conf.d/apache2.conf && \
echo "autostart=true" >> /etc/supervisor/conf.d/apache2.conf && \
echo "autorestart=true" >> /etc/supervisor/conf.d/apache2.conf
CMD ["/usr/bin/supervisord"]
This link also explains how to run multiple services in a container:
https://docs.docker.com/engine/admin/multi-service_container/
php:5.5.36-apache has a bash script called apache2-foreground which uses exec to launch apache, that script is called with CMD ["apache2-foreground"] at the end of the Dockerfile. This is the one script that will be executed by Docker on start and the exec command passes execution off to the system.
My solution which my very well be inelegant and I would not suggest doing this with any kind of production server is to copy the apache2-foreground script and start memcached before apache is started. Since this is an image to use as a local development server this meets my needs.
The updated apache2-foreground:
#!/bin/bash
set -e
# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2.pid
/etc/init.d/memcached start
exec apache2 -DFOREGROUND
Then I replaced:
RUN systemctl enable memcached.service
with:
COPY apache2-foreground /usr/local/bin/