/usr/bin/env: �php\r’: No such file or directory - php

I have a problem during Propel ORM configuration.
I prepared environment on my Vagrant with PHP 7.1 following this provision file:
# Install software
add-apt-repository ppa:ondrej/php
apt update
apt install python-software-properties
apt update
apt install -y apache2
apt install -y php
apt install -y php-mcrypt
apt install -y php-mysql
apt install -y php-curl
apt install -y php-cli
apt install -y php-xml
apt install -y libapache2-mod-php
apt install -y mc
# install composer, configure Apache and create database
service apache2 restart
/etc/init.d/mysql restart
Currently I want to install Propel ORM. I added Propel to composer, installed, and now I type (by SSH in Vagrant)
/var/www/application/Vendors/bin/propel init but unfortunately I get error:
/usr/bin/env: �php\r’: No such file or directory
What can I do to resolve it?
EDIT:
File that I run (not edited, installed via Composer):
#!/usr/bin/env sh
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../propel/propel/bin" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/propel" "$#"

I don't use propel but had the same problem with phpunit.
The problem is often that the vendor/propel/propel/bin/propel, or in my case the vendor/phpunit/phpunit/phpunit file you try to execute is Windows encoded and not Unix encoded. It happens when you do composer install/update on Windows but run your code in a vagrant box.
You have multiple ways of getting rid of the CRLF:
dos2unix command (sudo apt-get install dos2unix)
use your prefered text editor (Sublime, PHPStorm, they can both do that)
get rid of vendor and run composer install/update from your vagrant box
Remember that the problem is not the vendor/bin/propel file but the vendor/propel/propel/bin/propel file.
Hope this help!

Related

exec: "php-fpm": executable file not found in $PATH: unknown

Getting below error while running docker-compose up -d for laravel Project.
ERROR: for groshop_laravel-env_1 Cannot start service laravel-env: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "php-fpm": executable file not found in $PATH: unknown
ERROR: for laravel-env Cannot start service laravel-env: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "php-fpm": executable file not found in $PATH: unknown
ERROR: Encountered errors while bringing up the project.
My dockerFile looks like
FROM centos:7
# Install some must-haves
RUN yum -y install vim wget sendmail
RUN yum -y install libtool make automake autoconf nasm libpng-static
RUN yum -y install git
RUN git --version
# Install PHP 7.1 on CentOS
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN yum install yum-utils
RUN yum install epel-release
RUN yum-config-manager --enable remi-php73
RUN yum --enablerepo=remi-php73 -y install php php-bcmath php-cli php-common php-gd php-intl php-ldap php-mbstring \
php-mysqlnd php-pear php-soap php-xml php-xmlrpc php-zip
RUN php -v
# Prepare PHP environment
COPY config/php/php-fpm.conf /etc/php-fpm.conf
COPY config/php/www.conf /etc/php-fpm.d/www.conf
COPY config/php/php.ini /usr/local/etc/php/php.ini
COPY config/php/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/bin/composer
RUN composer --version
# Install Node.js
RUN curl -sL https://rpm.nodesource.com/setup_7.x | bash -
RUN yum -y install nodejs
RUN yum list installed nodejs
RUN node -v
# Final update and clean up
RUN yum -y update --skip-broken
RUN yum clean all
# Define work directory
WORKDIR /var/www/laravel-boilerplate
# Expose ports
EXPOSE 9000
# CMD ["php-fpm", "-F", "-O"]
CMD ["php-fpm", "-F"]
Also i have php files under config. have tried CMD line with changes but no luck.
Any idea?
Also one other observation i looked at is, i couldnt see those php-fpm.* files under /etc but only supervisord.conf file with below content.
[supervisord] nodaemon=true
[program:php-fpm] command=/usr/sbin/php-fpm -F -R user = root
autostart = true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0
I cannot spot the php-fpm package being installed.
RUN yum --enablerepo=remi-php73 -y install php php-bcmath php-cli php-common php-gd php-intl php-ldap php-mbstring \
php-mysqlnd php-pear php-soap php-xml php-xmlrpc php-zip php-fpm

How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?

I am running the Wordpress multisite click to deploy on the compute engine.
Operating system
Debian 9.8
Package contents
Apache 2.4.25
Google-Fluentd 1.6.9
MySQL-Client 5.7.26
MySQL-Server 5.7.26
PHP 7.0.33
Stackdriver-Agent 5.5.2
WP-CLI 2.2.0
WordPress 5.1.1
phpMyAdmin 4.6.6
I would like to upgrade PHP to 7.3
You can use a third-party repository to install php7.3
apt-get install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install php7.3
You may follow this instructions on how to update your php version from 7.0 to 7.3.
For Debian:
$ sudo apt install apt-transport-https lsb-release
$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg # Download the signing key
$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list.
$ sudo apt update
$ sudo apt-get install php7.3
To check the current version after the installation:
$ php -v
For Ubuntu:
$ sudo add-apt-repository ppa:ondrej/php # Press enter to confirm.
$ sudo apt-get update
$ sudo apt-get install php7.3
If you encounter the error below during installation, you may execute the command "$ sudo rm /var/lib/dpkg/lock" then try installing the php7.3 again.
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
Hope this information helps.
After updating your php version, the other thing you should do is:
update MYSQL and get WordPress to to recognize the new version
sudo apt-get update
sudo apt-get install php7.3-mysql
sudo a2enmod php7.3
sudo a2dismod php7.0
sudo systemctl restart apache2
This comprehensive instruction works just fine https://www.jiyuulife.net/update-php-version-for-wordpress-on-debian-9/
In the commands, replace the instruction's PHP version (7.4.5) with the latest release (7.4.11 as of October 2020).
In my case, after the update WordPress alerted me about missing (PHP) extensions that some plugins needed. I added them separately as per the instruction, restarted Apache and everything panned out perfectly fine.
Magic!
Thanks Tang for the great instruction.

How to install php musesum version with apache and mysql

I'm having trouble with installing old php 5.3.29 on ubuntu 16.04
Recently I found this useful source on how to install old unsupported php versions which are available only in php museum
sudo apt-get install apache2
sudo apt-get install make
# php museum version installation
sudo apt-get update
sudo apt-get install gcc libmysqlclient-dev libxml2-dev
wget --trust-server-names http://museum.php.net/php5/php-5.3.29.tar.bz2
tar xjf php-5.3.29.tar.bz2
cd php-5.3.29
./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql
sudo make install
Now I need to connect apache2 and php 5.3.29 but how ?? (how to configure Apache to use php from custom directory)
All the articles I found talk about how to switch php version use update-alternatives --config php. That command ignores my php5.3 installed in the custom folder by make command.
I even tried to symlink php executable file to /usr/bin
ln -s /home/ubuntu/php-5.3.29/installdir/bin/php /usr/bin/php5.3.29
and again no luck with update-alternatives command run
Hmm found another way (adding ppa repo) solution for this issue here:
https://everton.rocks/conteudo/multiple-php-versions-apache
# add this 2 lines to /etc/apt/sources.list
deb http://ppa.launchpad.net/sergey-dryabzhinsky/php53/ubuntu xenial main
deb-src http://ppa.launchpad.net/sergey-dryabzhinsky/php53/ubuntu xenial main
sudo apt update
sudo apt install php53-apache2
sudo a2dismod php7.0
sudo a2enmod php53
sudo service apache2 restart

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?

Categories