Moving a PHP Laradock project to Mac M1 - php

I need to be able to develop an old Laradock project on my new M1. So far, I have nearly everything up and running. The one holdout that I have is HHVM. HHVM doesn't support M1 in any way, so I need to move the project away from it. I get this when attempting to start docker with HHVM:
failed to solve: executor failed running [/bin/sh -c apt-get update -y && apt-get install -y software-properties-common wget && wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add - && add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" && apt-get update -y && apt-get install -y hhvm && apt-get clean && rm -rf /var/lib/apt/lists/*]: exit code: 100
I suspect I need to replace HHVM's functionality with PHP-FPM. I'm a little stumped on where to go with it, though. I was not the one that initially built this program, and PHP isn't my forte. I have a hard time finding anything online about this issue, though I'd imagine people have to have encountered it since M1 has come along.
If I comment out HHVM in laradock, docker-compose.yml then I can get everything else to build - I also get 500s when attempting to access the project.
I'm not sure where to even go with this issue.

Related

W3 Total Cache (and Wordpress) not recognizing memcached after installation

Ok, so I'm trying to enable the memcached mode of the W3 Total Cache on my Wordpress site to get better performance compared to the disk mode I have at the moment.
The memcached option in the Page Cache Method: drop-down menu of the W3TC settings page was greyed out and disabled since memcached was not installed in my machine. Thus I followed instructions from this website and this question and ran the following commands:
apt-get -y update && \
apt-get install -y memcached && \
service memcached start
apt-get install -y git nano vim netcat && \
apt-get install -y libmemcached-dev libmemcached11 git build-essential && \
apt-get install -y pkg-config zlib1g-dev && \
git clone https://github.com/php-memcached-dev/php-memcached && \
(cd php-memcached && \
git checkout php7 && \
git pull && \
phpize && \
./configure --with-php-config=php-config && \
make && \
make install)
memcached is successfully installed and say echo "stats settings" | netcat localhost 11211 works perfectly, but the problem persists and the phpinfo() page doesn't have a section for memcached. This is obviously because my Wordpress does NOT yet recognize memcached as a possible method for caching stuff.
So, what I'm asking is how can I make my Wordpress understand that memcached is a possible caching method?? :) Am I missing any configuration step?
I'm using PhP 7.2.28 and Wordpress 5.3.2 on Debian GNU/Linux 10.
Do you have PHP-FPM installed? I've run into issues where I've forgotten to restart it after installing something new.
Check what version of php you are currently using by running the following command,
sudo php -v
The chances are memchached is not installed on the version of php you are using.
In your case, you need to try the following,
sudo apt install php7.2-memcached
And reboot server.

Install mongodb driver in docker with dockerfile

I have a mongodb docker container. I need another docker container which will have php and apache installed. I want to run a php script from this container and send some data to the mongodb container to save the data in mongodb database. So i need to install mongodb driver in the php-apache container.
To do that, i have created following dockerfile:
FROM php:7.3-apache
COPY src/ /var/www/html
RUN apt-get update
RUN apt-get install openssl libssl-dev libcurl4-openssl-dev
RUN pecl install mongodb
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN echo "extension=mongodb.so" > /usr/local/etc/php/php.ini
EXPOSE 80
It first builds php-apache docker image. Then it should install mongodb driver.
But when i run the following command
docker build -t my-mongo .
At one point it shows following message and stops the execution:
Need to get 2213 kB of archives.
After this operation, 9593 kB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c apt-get install openssl libssl-dev libcurl4-openssl-dev' returned a non-zero code: 1
What went wrong here? Is there anything wrong in the dockerfile ?
What went wrong here? Is there anything wrong in the dockerfile ?
There are at least three things wrong with your Dockerfile IMO.
The first one is not in direct relation to your problem, but you are creating way too many layers (one for each RUN command) for something as simple as adding a driver to your image. You should put all this in a single layer (i.e. a single RUN command) and cleanup after yourself at the end to keep the layer footprint small.
Now the core of your real problem. As you can see in your output, apt-get is launched in interactive mode and asks for a confirmation. The docker build process can't handle that and therefore aborts the command causing the build to fail. To overcome this, apt-get has a -y option to answer 'yes' to all prompts by default.
The last one is in the line where you add the mongo driver to php.ini: you are redirecting echo output to your file with a single gt; sign (>), hence you are replacing the full content of the file you just copied. You must use a double gt; sign (>>) for content to be appended.
The following Dockerfile should fix the problems above (tested without the copy of sources + cp of your own php.ini file since I don't have them)
FROM php:7.3-apache
COPY src/ /var/www/html
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl libssl-dev libcurl4-openssl-dev \
&& pecl install mongodb \
&& cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
&& echo "extension=mongodb.so" >> /usr/local/etc/php/php.ini \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 80
Some explanation:
The && notation allows to run all commands one after the other in a single docker RUN command resulting in a single intermediate container, thus a single layer.
-y --no-install-recommends options to apt-get ask apt to not go interactive (answer yes everywhere) and to install only needed packages, not the recommended ones.
The two last instruction apt-get cleann && rm -rf /var/lib/apt/lists/* remove all caches made by running apt so that the layer stays as small as possible. (see apt-get chapter in docker best practice)
put this at the beginning of your Docker file, it is important to have it before installing all other extensions, otherwise it fails.
FROM php:7.3-apache
RUN apt-get update -y && apt-get upgrade \
&& pecl install mongodb && docker-php-ext-enable mongodb
That's all what I needed to get mongodb running FROM php:7.3-cli-buster Probably it will work for other versions - fpm, apache etc as well.

Docker image does not work on AWS Fargate but it does in EC2

I'm changing infrastructure on AWS and I want to use Docker (ECS) with Fargate. My Docker image is based on Ubuntu and I install all I need in it. I'm using Laravel 5.6 on NGINX running PHP 7.2. My Docker container works on my local machine and if I run ECS with EC2, however when I change to Fargate it returns NGINX 500 error. I did some tests and I know PHP is running, only when I install my Laravel app the error happens.
Since I cannot access Fargate machine I don't know how to debug. I tryied to connect NGINX with Loggly however it requires rsyslog and since I'm using Docker it cannot access Ubuntu's core. When I install and try to run it returns:
rsyslogd: imklog: cannot open kernel log (/proc/kmsg): Operation not permitted
Here is my Dockerfile:
FROM ubuntu:latest
ENV BACKEND_PATH=/code/Backend
ENV FRONTEND_PATH=/code/Frontend
## Update
RUN apt-get update -y
## Upgrade
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:certbot/certbot
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get dist-upgrade -y
RUN apt-get autoremove -y
RUN apt-get update -y
## Nano
RUN apt-get install -y nano
## Timezone
RUN echo "America/Sao_Paulo" > /etc/timezone && \
apt-get install -y tzdata && \
rm /etc/localtime && \
ln -snf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
apt-get clean
## Git
RUN apt-get install -y git
## NGINX
RUN apt-get install -y nginx
COPY ./nginx/app/sites-available /etc/nginx/sites-available
COPY ./nginx/app/sites-available /etc/nginx/sites-enabled
COPY ./nginx/sites /etc/nginx/sites
COPY ./nginx/ssl /ssl
## PHP
RUN apt-get install -y php-cli php-fpm php-curl php-mbstring
COPY ./php/php.ini /usr/local/etc/php
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install libs
RUN apt-get install -y php-zip php-mysql php-gd pngquant gifsicle jpegoptim libicu-dev g++ php-intl php-xml
## Crontab
RUN apt-get install -y cron
COPY crontab newcrontab
RUN crontab newcrontab
RUN rm newcrontab
## Supervisor
RUN apt-get install -y supervisor
COPY ./supervisord /etc/supervisor/conf.d
## Certbot
RUN apt-get install -y python-certbot-nginx
## Install apps
COPY ./code/Backend /code/Backend
COPY ./code/Frontend/dist /code/Frontend/dist
RUN cd ${BACKEND_PATH} && chmod +x composer.phar && ./composer.phar self-update && php composer.phar install
RUN chmod -Rf 777 ${BACKEND_PATH}/storage
RUN chmod -Rf 777 ${BACKEND_PATH}/resources
RUN php ${BACKEND_PATH}/artisan config:clear
RUN php ${BACKEND_PATH}/artisan passport:keys
## Run!
EXPOSE 80 443
RUN service php7.2-fpm start
CMD ["/usr/bin/supervisord"]
I think this error has something to do with permissions but without error message it's almost impossible to know what's going on... Does anyone have any ideia how I may find this out?
I figured it out. Really stupid mistake actually. When I created Fargate configurations I used a Security Group without permissions to access some AWS components so the application was unable to boot.
Check out this answer on ServerFault: https://serverfault.com/questions/691048/kernel-log-stays-empty-rsyslogd-imklog-cannot-open-kernel-log-proc-kmsg
Try running the Fargate task with the --privileged flag. You can set this flag in the AWS console per-container in the task definition. It's in the SECURITY section near the end of the container definition. Here's the full reference for container definitions.

facing error while install imagemagick Ubuntu 14.04

I am new to use ubuntu, to install imagemagick I have run below command
sudo apt-get update
but it showing error
I have executed below commands as well but not able to install
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
https://gist.github.com/rodleviton/74e22e952bd6e7e5bee1
Google has dropped the support for 32-bit version for chrome on Linux and that is the reason you are seeing that error.
Edit /etc/apt/sources.list.d/google-chrome.list - You would need sudo
Replace the existing line with deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
Run sudo apt-get update now.
And what is the error you are seeing when you are trying to install imagemagick?

pecl install ampq failed

I want to create RabbitMQ clients and workers in PHP on my Ubuntu machine. These is the whole list of steps that I followed:
apt-get install aptitude
aptitude install libtool
aptitude install pkg-config
cd /tmp
rm -rf rabbitmq-c
git clone -b v0.5.2 git://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c
autoreconf -i && ./configure && make && make install
pecl install amqp-1.4.0
I took these steps from this thread. But when I run the last command, I get this error message:
No releases available for package "pecl.php.net/apmq"
So, what is wrong with that?
PS. PHP version is 5.6.4.

Categories