php symfony ERR_CONTENT_DECODING_FAILED on openshift - php

I have a php 5.4 gear on openshift on which I can run my wordpress installation.
However, when I try to deploy my symfony app, I get Content Encoding Error, it seems like the html output is broken (not yet complete). I've tried modifying the .htaccess file as well as enable/disable output buffering and/or output compression setting on the apache's httpd.conf. Here is the output from curl:
$ curl --compress --raw -i http://webfront-interiorpediadev.rhcloud.com
HTTP/1.1 200 OK
Date: Mon, 08 Dec 2014 01:52:30 GMT
Server: Apache/2.2.15 (Red Hat)
X-Pingback: http://webfront-interiorpediadev.rhcloud.com/xmlrpc.php
Cache-Control: no-cache
x-pingback: http://webfront-interiorpediadev.rhcloud.com/xmlrpc.php
vary: Accept-Encoding
content-encoding: gzip
accept-ranges: none
Content-Length: 20
X-Debug-Token: a9e740
X-Debug-Token-Link: /_profiler/a9e740
Content-Type: text/html; charset=UTF-8
Set-Cookie: PHPSESSID=gtarr5ls6tdcejdelrjrffr9p6; path=/
set-cookie: PHPSESSID=jtebjs0ihrdqhvo6f2gicq0rp0; path=/
<!DOCTYPE html>
<!--
I really have no idea why I do not receive the entire html output, Content-Length header output looks suspiciously small, but google search and php/apache documentation says that Content-Length header will not be reliable for gzip output.
I've been debugging this thingy for quite some time now and really run out of idea to tackle it. The app coding is fine, as I have deployed the exact same copy on my localhost during development. Any idea would be highly appreciated.
Here is the phpinfo() output for my apache configuration on openshift:
phpinfo on openshift

The best way to deploy a Symfony app to Openshift is:
Be sure you have a Symfony2 app working well in localhost (dev and prod)
Your proyect have to be using git.
Your .gitignore file is ignoring vendors, cache, bootstrap, logs, composer etc.
You have committed every pending change.
You need an openshift gear using PHP 5.4 and a cartridge of MySql 5.5
You need rhc to be installed and configured
Config your gear to public a branch called release: rhc app-configure --deployment-branch release -a <app-name>
Create a new php file that will give MySQL access to your app:
<?php
# app/config/params.php
if (getEnv("OPENSHIFT_APP_NAME")!='') {
$container->setParameter('database_host', getEnv("OPENSHIFT_MYSQL_DB_HOST"));
$container->setParameter('database_port', getEnv("OPENSHIFT_MYSQL_DB_PORT"));
$container->setParameter('database_name', getEnv("OPENSHIFT_APP_NAME"));
$container->setParameter('database_user', getEnv("OPENSHIFT_MYSQL_DB_USERNAME"));
$container->setParameter('database_password', getEnv("OPENSHIFT_MYSQL_DB_PASSWORD"));
}?>
This will tell the app that if is openshift environment it needs to load different user an database
Import this file (params.php) to your app/config/config.yml file:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: params.php }
...
Commit your changes.
Create a new branch that will push your changes to Openshift: git checkout -b release
Add your remote repository from openshift: git remote add openshift -f <youropenshiftrepository.git>
Merge the differences between both repositories git merge openshift/master -s recursive -X ours
Create a 'deploy' file (the one executed in openshift after you push your app) in your new folder "/.openshift/action-hooks" (Created when you added your openshift repository):
#!/bin/bash
# Symfony deploy
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | php -- --install-dir=$OPENSHIFT_DATA_DIR
else
php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
unset GIT_DIR
cd $OPENSHIFT_REPO_DIR/
php $OPENSHIFT_DATA_DIR/composer.phar install
php $OPENSHIFT_REPO_DIR/app/console cache:clear --env=dev
chmod -R 0777 $OPENSHIFT_REPO_DIR/app/cache
chmod -R 0777 $OPENSHIFT_REPO_DIR/app/logs
rm -r $OPENSHIFT_REPO_DIR/php
ln -s $OPENSHIFT_REPO_DIR/web $OPENSHIFT_REPO_DIR/php
rm -r $OPENSHIFT_REPO_DIR/php
ln -s $OPENSHIFT_REPO_DIR/web $OPENSHIFT_REPO_DIR/php
php $OPENSHIFT_REPO_DIR/app/console doctrine:schema:update --force
Give this file permissions to be executed. In windows: git update-index --chmod=+x .openshift/action_hooks/deploy In Linux and Mac: chmod +x .openshift/action_hooks/deploy
Add your new file to the git project and make the commit.
Push to openshift: git push openshift HEAD
Your console will show you every step it is working on.
Come back to your master branch. git checkout master
Then you can keep working normaly on your project, commit your changes and move to release branch to deploy your new changes: git checkout release git merge master git push openshift HEAD git checkout master
And that's how I work with Symfony and Openshift. (These instructions are a mix from many ways I read and I imporved with some changes. It works very well for every app I've made.

Related

My npm app is serving the files in the directory instead of the index.php contents

I am just trying to deploy an npm app and it's showing me this (screenshot attached) instead of serving index.php on a server.
Here are the logs
root#322cfa653cb1:/app# npx http-serve
npx: installed 21 in 3.141s
Starting up http-serve for ./public
Available on:
http://127.0.0.1:8080
http://172.17.0.2:8080
Hit CTRL-C to stop the server

Varnish admin socket timeout with magento 1 in kubernetes

Outline:
We are trying to connect up varnish-4.1.11 to magento 1 in kubernetes using the nexcess turpentine addon, but the same error is returned each time:
Error determining Varnish version: Varnish admin socket timeout
Failed to load configurator
Application stack:
We have a kubernetes cluster running a magento 1 stack with the following containers:
php-fpm:7.2/nginx:latest
mysql:5.7
redis:latest
nfs-provisioner:latest
nginx:latest (acts as a proxy for varnish to point to)
varnish:4.1.11
kubernetes info:
Networking: cilium:v16.3
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:07:57Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
Varnish config:
NFILES=131072
MEMLOCK=82000
NPROCS="unlimited"
RELOAD_VCL=1
VARNISH_VCL_CONF=/var/www/html/site/var/default.vcl
VARNISH_LISTEN_PORT=6081
VARNISH_ADMIN_LISTEN_PORT=6082
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_MIN_THREADS=5
VARNISH_MAX_THREADS=50
VARNISH_THREAD_TIMEOUT=120
VARNISH_STORAGE="malloc,512M"
VARNISH_TTL=120
DAEMON_OPTS="-F -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-t ${VARNISH_TTL} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}" \
-p esi_syntax=0x2 \
-p cli_buffer=16384
What we've tried so far:
Downgrading to varnish-3.0.7
Pointing magento to varnish's IP directly
Running a generic varnish connection script in PHP
Notes:
Pinging the varnish pod from the nginx/fpm pod works fine
Curling to the varnish ports from the nginx/fpm pod also works fine
The generic connection script noted above works successfully when run from inside the varnish container itself, which very likely indicates a networking issue.
Running the stack locally in docker-compose works fine, which also indicates a networking issue.
I appreciate that this is a very very niche issue, but hopefully someone else has some insight into what could be going wrong.
In case anyone else encounters this or a similar issue, it was due to the linkerd service mesh we have in place not properly passing traffic.
Whilst not an ideal solution, disabling linkerd for the relevant pods resolved the issue.

deploy with deployer fails

I'm having problem with deploying with the use of deployer, this is the first time i'm using any deployment tool. My teacher have made a guide for making it work but, I haven't been able to do a deploy.
So if anyone can tell me what i'm doing wrong please tell me.
here follows all the specs for my computer and my setup:
Computer:
Operating system Windows 10 Home
Manufacturer ASUSTek Computer Inc.
Model E403SA
Processor Intel(R) Pentium(R) CPU N3700 # 1.60GHz 1.60 GHz
RAM 4.0 GB
64-bit operatingsystem, x64 based processor
.ssh/config file:
Host xxxxx
ControlMaster no
Hostname ssh.xxxxx.xx
User xxxxxx_xxx
note that I added ControlMaster no becouse I read that the problem could be with ssh multiplexing but it but I got the same error with and without it...
deploy.php file ( in the root of the project):
<?php
namespace Deployer;
require 'recipe/common.php';
// Project name
set('application', 'blog');
// Project repository
set('repository', 'git#github.com:xxxxxxx/xxxxxxxxxxxxxxxx.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// Shared files/dirs between deploys
set('shared_files', ['config/dbinfo.json']);
set('shared_dirs', []);
// Writable dirs by web server
set('writable_dirs', []);
// Hosts
host('ssh.xxxxxx.xx')
->set('deploy_path', '~/xxxx.xxxxxxxxxxxxx.xxxx.xxxxxxx')
->user('xxxxxx_xxx')
->port(22);
// Tasks
desc('Deploy your project');
task('deploy:custom_webroot', function() {
run("cd {{deploy_path}} && ln -sfn {{release_path}} public_html/xxxxxxxxxxxx");
});
task('deploy', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:writable',
'deploy:clear_paths',
'deploy:symlink',
'deploy:unlock',
'cleanup',
'success'
]);
// [Optional] If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
after('deploy', 'deploy:custom_webroot');
When i try to run dep deploy in the root of the project I get the flowing output:
$ dep deploy
✈︎ Deploying master on ssh.xxxxxx.xx
➤ Executing task deploy:prepare
✔ Executing task deploy:failed
➤ Executing task deploy:unlock
[Deployer\Exception\RuntimeException]
The command "rm -f ~/blog.xxxxxxxxxxx.xxxx.xxxxx/.dep/deploy.lock" failed.
Exit Code: -1 (Unknown error)
Host Name: ssh.xxxxx.xx
================
mm_send_fd: sendmsg(2): Broken pipe
mux_client_request_session: send fds failed
any help would be extremely appreciated!
Try using dep deploy:unlock and then use deploy normally.

Deployer - no tty present and no askpass program specified - How to deploy with Deployer

I have trouble deploying with Deployer 4.0.2 and I am in need for help of somebody more experienced than me in this.
I want to deploy a repository of mine to a Ubuntu 16.04 server.
I am using laravel homestead as a development environment, where I also installed deployer. From there I ssh into my remote server.
I was able to deploy my code with the root user, until I hit a RuntimeExceptionthat aborted my deployment.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
That made me create another user called george, whom I gave superuser rights. I copied my public key from my local machine to a newly generated ~/.ssh/authorized_keys file, that gave me permission to access the server via ssh.
Yet when I run dep deploy with the new user:
server('production', '138.68.99.157')
->user('george')
->identityFile()
->set('deploy_path', '/var/www/test');
I get another RuntimeException:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Now it looks like the new user george cannot access the ~/.ssh/id_rsa.pubkey. So I copy them from the root folder into my home folder and also add the public key in the Github SSH settings.
cp root/.ssh/id_rsa.pub home/george/.ssh/id_rsa.pub
cp root/.ssh/id_rsa home/george/.ssh/id_rsa
Only to get the same error as before.
In the end I had to add github to my list of authorized hosts:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
Only to get the next RuntimeException
[RuntimeException]
sudo: no tty present and no askpass program specified
I managed to comment this code in the deploy.php
// desc('Restart PHP-FPM service');
// task('php-fpm:restart', function () {
// // The user must have rights for restart service
// // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
// run('sudo systemctl restart php-fpm.service');
// });
// after('deploy:symlink', 'php-fpm:restart');
to get the deployment process finally done, and now I ask myself, if the restart of php-fpm is really necessary, for me to continue debugging this deployment tool? Or can I live without it?
And if I need it, can somebody help me understand what I need it for? And maybe as a luxury also provide the solution to the RuntimeException?
Try this:
->identityFile('~/.ssh/id_rsa.pub', '~/.ssh/id_rsa', 'pass phrase')
It works great for me - no need for an askpass program.
It helps to be explicit in my experience.
As for your phpfm restart task .. I haven't seen that before. Shouldn't be needed. :)
EDIT:
That you provide a password is probably a good sign that you ought to refactor your Deployer code a bit if you keep it under source control.
I am loading site specific data from a YAML file - which I am not submitting to source control.
The first bit of my stage.yml :
# Site Configuration
# -------------
prod_1:
host: hostname
user: username
identity_file:
public_key: /home/user/.ssh/key.pub
private_key: /home/user/.ssh/key
password: "password"
stage: production
repository: https://github.com/user/repository.git
deploy_path: /var/www
app:
debug: false
stage: 'prod'
And then, in my deploy.php :
if (!file_exists (__DIR__ . '/deployer/stage/servers.yml')) {
die('Please create "' . __DIR__ . '/deployer/stage/servers.yml" before continuing.' . "\n");
}
serverList(__DIR__ . '/deployer/stage/servers.yml');
set('repository', '{{repository}}');
set('default_stage', 'production');
Notice that, when you use serverList, it replaces your server setup in deploy.php

repository not found on heroku

Originally tried out Heroku (in order to learn how to use it) and deployed an app, tastyall. Eventually went into Heroku to delete everything done in order to start over (what is below). My Heroku dashboard showed no apps before starting what is below.
My blackopp folder on my desktop contains my empty composer.json and idex.php test file which says contains code to say “Hello”.
My question: why can I not get rid of the old app info that seems to be causing confusion? Where is this coming from? I see it says: rename tastyallphp.php => blackopp.php (100%) but can't seem to make sense of this since there should be no ref to "tasty..." anything.
$ cd /Users/xxxx/Desktop/blackopp
$ pwd
/Users/xxxx/Desktop/blackopp
$ git init
Reinitialized existing Git repository in /Users/xxxx/Desktop/blackopp/.git/
$ git add .
$ git commit -m "initial commit"
[master bff3b6c] initial commit
Committer: xxxx
Your name and email address were configured automatically……
1 file changed, 0 insertions(+), 0 deletions(-)
rename tastyallphp.php => blackopp.php (100%)
$ heroku create blackopp
Creating blackopp... done, stack is cedar-14
https://blackopp.herokuapp.com/ | https://git.heroku.com/blackopp.git
$ git push heroku master
remote: ! No such app as tastyallapp.
fatal: repository 'https://git.heroku.com/tastyallapp.git/' not found
I wonder if deleting my entire Heroku account and starting over would be easier but thought to ask my qestion first.
The app name tastyallapp will be coming from the definition of your heroku remote in the repository config. This is what's used to determine the destination when you do git push heroku master.
Starting over would be one option, but if you'd like to try to fix it you can do:
git remote remove heroku
to remove the previous remote from the old app, and then:
heroku git:remote -a blackopp
to add a new remote that matches the current app name.

Categories