How can i get the access.log from the openshift platform - php

I built a app ,and i choose the php language.I see that openshift platform use the Apache Server.
now i want to check the access.log? how can i find it?
thx!

The easiest way would just be to just run rhc tail YOUR_APP_NAME from the command line tools.
To view the logs on the remote server:
rhc ssh YOUR_APP_NAME # ssh into your app
cd $OPENSHIFT_LOG_DIR # change to the log directory
tail -f php.log

Related

exec() rsync command doesn't work with Laravel8

Hope someone can shed some light on this one, it's driving me nuts. I have a backup web app written in php, this creates an rsync which is run on a remote server and stores the files in a local folder. This function works using the php exec function.
We are migrating this to within a laravel8 app and the identical call to the same rsync and to the same local storage directory fails. The error is a 255.
If i use the same rsync command from command line it works the same as it does in our original app.
A bit more...
The Laravel instance is using Horizon to perform this so i have this in the handle() function of a process file in the jobs folder.
Of note I have a dev version of this laravel app and with this it works correctly and syncs with the remote folder.
My rsync command is using an id_rsa file for the apache user - www-data (the app is not available to the outside world). the folders have the correct permissions and owners (www-data and 755 for directories and 644 for files).
an example (modified version) of the rsync command:
rsync -rLDvcs -e "ssh -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /var/www/.ssh/id_rsa" --no-perms --no-group --no-owner --progress --exclude-from '/var/www/backup/exclude.txt' --delete --backup --backup-dir=/hdd/mnt/incs/deleted_files/the-project/ theproject#188.102.210.41:/home/theproject/files/ /hdd/mnt/incs/theproject/files
the code which calls this is:
$aResult['res'] = exec($rsync . ' 2>&1', $aResult['output'], $aResult['return']);
when run $aResult['return'] has a value of 255 and the process has failed. The docs seem to say this is a failure to connect yet the identical call on another app on the same machine works (as it does if rsync is used in command line)
Any ideas? The php version on this box (the original app and the laravel upgrade) is php8.0 and my dev copy uses php7.4. my dev and this internal box use Ubuntu20.04 and apache2 so besides the php version are pretty identical.
No error is in any logs.
thanks
Craig

Github Pull Webhook with PHP - Apache permissions

I'm setting up my server to listen to a webhook which is currently
shell_exec('git pull 2>&1');
Receiving and executing is working fine, except the to get it to actually replace files I need to give www-data (apache debian) permission to write all the files/folders on my webserver, right?
Currently I'm getting this as a result (no write permissions)
Updating 115da6c..9e82ef0
error: unable to unlink old 'example-path/html.html' (Permission denied)
What are the security implications of giving www-data permission to write files, and is this the right choice or am I doing things all wrong?
Another ways to achieve what you want:
sudo. Configure sudo to run the command passwordless and run shell_exec('sudo git pull 2>&1');.
Create a setuid wrapper that runs git pull and run shell_exec('git_pull_suid_wrapper');.

Tokbox php server is not working in aws

Currently am implementing a video conferencing application using Tokbox . Sample server and web client is working in my local-host .But when i tried to run the PHP tokbox server on AWS EC2 instance .The server is not working properly.
I am using the following run-demo file to start the server in AWS.
export TOKBOX_API_KEY=**********
export TOKBOX_SECRET=**********************
if [ -d "storage" ]
then
rm -rf storage/
fi
php -S ec2-34-240-136-230.eu-west-1.compute.amazonaws.com:8083 -t web web/index.php
I am geting the alerts "Server started" ,Listening on ec2-34-240-136-230.eu-west-1.compute.amazonaws.com:8083" after executing the "run-demo" commands. But when i took the URL http://ec2-34-240-136-230.eu-west-1.compute.amazonaws.com:8083/room/session not getting any json result from server.
You can probably just do:
php -S localhost:8083 -t web web/index.php
To confirm it works, after running the above command, open a new SSH session and run:
curl -v http://localhost:8083/room/session
The issue you're facing is the port is likely being blocked. You will need to expose port 8083 using AWS security groups.

Run iOS Codesign from php page

I try to setup a local website to resign ipa file. but I have an issue with codesign command.
the command works properly when I run it from the shell terminal.
But it shows this error when it run from php: "no identity found".
I run an Apache server with php.
I think the account used to run apache server haven't access to keychain library.
Any idea how to fix this issue?
I finaly found a solution,
my command was :
codesign -f --verbose -s D7F14A3C73E20026ECB384BB7F7FCAEB76EF24B3 --resource-rules Payload/my.app/ResourceRules.plist Payload/my.app
I went to Keychain Acces, and copy my certificate from Session to System.
and it works

Running git pull from a php script

I was trying the Perfect Workflow, with Git, GitHub, and SSH, and i have everything set up, except running the command git pull from php.
When i run exec('git pull') i get:
Could not create directory '/.ssh'. Host key verification failed.
fatal: The remote end hung up unexpectedly
If i run it in the terminal (as root) it works just fine, but i need this hook to work from the Post-Receive URL (Github).
If i do exec('whoami') i get apache.
It's a (dv) from mediatemple with CentOS.
If you want apache (the user) to be able to pull from git, you'll have to create an ssh key for apache, then add that to the read only keys on github.
The flow is something like this (tweak to your needs)
usermod -s /bin/bash apache
su apache
cd ~
ssh-keygen # work through the keygen dance (added a dash)
Upload (tilde here refers to apache's homedir) ~/.ssh/id_rsa.pub to github and give apache access to whichever repos it needs to pull from.
Then you can test on the server by again su'ing to apache and running the git pull
su apache
cd ~/working-copy
git clone my-project
Once that's working you should be able to run a git pull through PHP.

Categories