Laravel and mamp - php

I have a fresh install of laravel. I setup the host to point to the public directory through mamp. Nothing serves however after restarting the local server.
I replicated all of this on windows through WAMP and laravel serves correctly. Redoing my steps on mac, the page just spins until the browser times it out.
Nothing fancy is happening, just trying to get the core laravel landing page to serve on a fresh laravel 5.4 install through mamp.
I went so far as to add a vhosts entry in the /Applications/MAMP/conf/apache/extra file. Restarted the servers and still no dice.
Any suggestions or nudges in the right direction would be super helpful. I just dont know what could be the difference at this point. I can do it successfully on windows...
Nothing happens in the logs. Browser just spins until it times out I'm guessing. Nothing serves, not even a timeout error.
ls -l reveals:
-rw-r--r-- 1 kstanley staff 1050 Feb 3 16:49 package.json
-rw-r--r-- 1 kstanley staff 1055 Feb 3 16:49 phpunit.xml
drwxr-xr-x 10 kstanley staff 340 Feb 26 09:23 public
-rw-r--r-- 1 kstanley staff 2906 Feb 3 16:49 readme.md
drwxr-xr-x 6 kstanley staff 204 Feb 26 09:23 resources
drwxr-xr-x 6 kstanley staff 204 Feb 26 09:18 routes
-rw-r--r-- 1 kstanley staff 563 Feb 3 16:49 server.php
drwxr-xr-x 6 kstanley staff 204 Feb 26 09:23 storage
drwxr-xr-x 7 kstanley staff 238 Feb 26 09:23 tests
drwxr-xr-x 33 kstanley staff 1122 Feb 26 09:23 vendor

Ok this was a non issue with laravel. The issue was mamp. None of my other hosts worked either. After doing a hard reboot of my computer and restarting mamp, everything worked. This is not the first time this has happened with mamp.

Remember always to set 777 permisions to storage folder chmod -R 777 storage.
It is common to get a blank screen or a "Log error" while the main error is just a permission one.

Related

webhook php file work from terminal but not from bitbucket

I'm using bitbucket to host my git repository, the repo holds a test website at the moment, I have created a bitbucket webhook, so when I push to the bitbucket repo, the changes show up as live on the digitalOcean VPS, in other words.. when bitbucket receives a push, it calls the webhook php file, and that php file has a shell script that pulls from github..
the hook file
Hook path : /var/www/html/hook.php
the site folder
Site path : /var/www/html/webhooks/
the hook.php file looks like so
<?php
echo "________PHP_AUTO_PULL________";
$output = shell_exec('git -C ./webhooks/ pull https://userName:password#bitbucket.org/userName/repo.git master');
echo "<pre>$output</pre>";
?>
when I do this in terminal
php hook.php
it does the job normally, and it pulls..
but the problem is, webhooks only shows this reply
________PHP_AUTO_PULL________
indicating that it does no pull, yes I have checked, no pull occured, how to make the hook execute the file normally?
permissions and owners are provided in these listings
listing for /var/www/html/
drwxrwxr-x 3 www-data www-data 4096 Mar 28 09:21 ./
drwxrwxr-x 3 www-data www-data 4096 Mar 3 16:49 ../
-rwxrwxrwx 1 www-data root 200 Mar 28 09:05 hook.php*
-rw-rw-r-- 1 www-data www-data 20 Mar 3 16:49 info.php
drwxr-xr-x 3 root root 4096 Mar 28 09:03 webhooks/
listing for /var/www/html/webhooks/
drwxr-xr-x 3 root root 4096 Mar 28 09:03 ./
drwxrwxr-x 3 www-data www-data 4096 Mar 28 09:21 ../
-rw-r--r-- 1 root root 295 Mar 27 15:13 content.html
drwxr-xr-x 8 root root 4096 Mar 28 09:03 .git/
-rw-r--r-- 1 root root 444 Mar 27 15:13 index.html
-rw-r--r-- 1 root root 963 Mar 27 15:13 menu_1.html
-rw-r--r-- 1 root root 13 Mar 28 09:03 number.txt
my webserver is nginx
any idea why it works from terminal, but bitbucket can't have it to work?
I have managed to solve it, using :
echo shell_exec("/usr/bin/git pull https://userName:password#bitbucket.org/userName/repo.git master 2>&1");
the 2>&1 part was helping me to see errors about permissions of folders, I used
chown -R www-data .git/
and it's working fine.

Docker application upload on AWS elastic beanstalk fails

I am using docker images for running web-app on PHP and MongoDB. Docker container is running perfectly on my local machine (Windows10) but it is not updating on AWS Elastic Beanstalk. I have made a zipped file consist of run.sh, Dockerfile, and Dockerrun.aws.json which can be found from here.
On AWS Elastic Beanstalk I am using single docker container and instance type is Linux Docker Version 1.11.2 . after deploying I am getting following error:
It looks like your run.sh needs to be executable, based on this inspection of the files:
ls
total 16K
drwxr-xr-x 7 adam 238 Jan 11 11:04 .
drwxr-xr-x+ 139 adam 4.7K Jan 11 11:04 ..
drwxr-xr-x 12 adam 408 Jan 11 11:04 .git
-rw-r--r-- 1 adam 1.9K Jan 11 11:04 Dockerfile
-rw-r--r-- 1 adam 248 Jan 11 11:04 Dockerrun.aws.json
-rw-r--r-- 1 adam 544 Jan 11 11:04 index.php
-rw-r--r-- 1 adam 72 Jan 11 11:04 run.sh
It's possible that you have other issues, but running chmod +x run.sh before you recreate the zip file should fix that specific problem.

Yii2 - Exception (Invalid Configuration) 'yii\base\InvalidConfigException' with message 'The directory is not writable by the Web process

When I access the site at domain.com/web, I'm displayed this error. I changed the directory permissions and they are listed below. Any solution?
PHP User Error – yii\base\ErrorException
Exception (Invalid Configuration) 'yii\base\InvalidConfigException' with message 'The directory is not writable by the Web process: /var/www/.../site1/web/assets'
in /var/www/.../site1/vendor/yiisoft/yii2/web/AssetManager.php:168
Permissions:-
root#...:/var/www/.../site1# ls -l web
total 48
drwxrwxr-x 9 root root 4096 Mar 20 15:56 assets
drwxr-xr-x 2 root root 4096 Mar 20 15:50 css
root#...:/var/www/.../site1/assets# ls -l
total 8
-rw-r--r-- 1 root root 958 Mar 20 17:24 AppAsset.php
-rw-r--r-- 1 root root 628 Mar 20 17:24 error_log
Even after running this command:-
chmod -R 777 .
total 8
-rwxrwxrwx 1 root root 958 Mar 20 17:24 AppAsset.php
-rwxrwxrwx 1 root root 628 Mar 20 17:24 error_log
I'm still getting same error.
I had same issue few days back.
If this was working earlier and suddenly got this error and stopped working than just restart your PC and check again. Else do the following.
In order to make a directory writable by the webserver you have to set the directory's owner or group to Apache's owner or group and enable the write permission for it. Usually, we set the directory to belong to the Apache group and enable the write permission for the group.
This worked for me.
chgrp apache /path/to/yourdir
chmod g+w /path/to/yourdir
See below:
-rw-r--r-- 1 root root 958 Mar 20 17:24 AppAsset.php
-rw-r--r-- 1 root root 628 Mar 20 17:24 error_log
Try setting all the files within that folder to 777 as well.

Adding apache to a user group file upload permission

I have a php script uploading files to a certain folder, currently they are uploading as a 'psacln' group, so that I can delete the files via FTP. This was all working fine when PHP was running as FastCGI, I had to change PHP to run as Apache Module in order to get a php extension to work. But now I can't delete files via PHP script because permission is denied. I assume because now the group 'Apache' is trying to delete the file that belongs to 'psacln'. How do I allow apache to delete those files?
EDIT: ls -alF
drwxr-xr-x 2 fugitiveink psacln 4096 Nov 13 14:05 92/
drwxr-xr-x 2 fugitiveink psacln 4096 Nov 13 06:57 93/
drwxr-xr-x 2 fugitiveink psacln 4096 Nov 13 14:12 95/
drwxr-xr-x 2 fugitiveink psacln 4096 Dec 21 18:56 96/
drwxr-xr-x 2 fugitiveink psacln 4096 Dec 21 08:30 97/
drwxr-xr-x 2 fugitiveink psacln 4096 Nov 13 14:26 98/
drwxr-xr-x 2 fugitiveink psacln 4096 Nov 13 14:28 99/
I assume that you have shell and root access to this system. If so, you can try adding the apache user (typically apache or www-data) to the /etc/group file.
The proper way to do this is to use usermod, though I typically just edit the file directly.
In short if your apache user is apache, try:
sudo usermod apache --append --groups psacln
This basically gives the apache user access to any files & directories that are owned by the psacln group.
If this doesn't work, post an example of your directory with the file permissions (ls -alF) and we can work from that.
EDIT:
To directly edit the groups file using nano (substitute with whichever editor you're comfortable with):
sudo nano /etc/groups
and find the psacln group and add the apache user:
psacln:x:130:apache
Note that the gid (130) will undoubtedly be different.
Set the permissions on the upload directory to 777 (wrx for all users). Can you still upload new files? If you can, you should be able to delete files.

fopen() - permission denied - despite having correct permissions (as far as I can tell)

Recently moved server and trying to get everything set up. My memcache class writes logs, something I need for development.
edit: server running Ubuntu 12.04.
the webroot is
/var/www/public_html
the log file is in /var/www/logs/
Here are the directory permissions
-rw-r--r-- 1 root root 1415 Sep 6 11:53 default
drwxrwxr-x 2 root webmasters 4096 Sep 6 12:48 logs
drwxrwxr-x 8 root webmasters 4096 Sep 6 12:32 public_html
Here are the permissions from /var/www/logs
-rw-rw-r-- 1 root webmasters 116103 Sep 6 13:02 access.log
-rw-rw-r-- 1 root webmasters 16094 Sep 6 12:48 error.log
-rw-rw-r-- 1 root webmasters 0 Sep 6 12:48 memcache.log
-rw-rw-r-- 1 root webmasters 9861 Sep 6 13:02 php_log.log
The file being browser to is /var/www/public_html/index.php
-rw-rw-r-- 1 root webmasters 5660 Sep 6 01:51 /var/www/public_html/index.php
Index includes /var/www/public_html/includes/cache.php
-rw-rw-r-- 1 root webmasters 4602 Sep 6 12:47 /var/www/public_html/includes/cache.php
Group members:
grep 'webmasters' /etc/group
webmasters:x:1002:sftp_chris,www-data
I have even tried changing /logs and /memcache.log to chmod 777.
Not really understanding why this is happening, as you can see php is writing its log file to /logs/php.log without issue.
Any ideas? I'm absolutely baffled.
I thought maybe it had something to do with php-suhosin but couldn't find anything there.
the function:
function write_to_log($string){
$file = '/var/www/memcache.log';
$fh = fopen($file, 'a');
$contents = #fread($fh, filesize($file));
$stringData = $contents."[".date('H.i:s d-m-y')."] ".$string;
fwrite($fh, $stringData);
fclose($fh);
}
You write to /var/www/memcache.log, not /var/www/logs/memcache.log for which you show permissions.
(why do you read the log before writing to it?)

Categories