Ubuntu Server unable to create directory in PHP - php

I have setup a little Ubuntu Server for developing some web apps.
I have a little script that uses mkdir() to create a directory, but i am getting a permission denied, its a simple command
mkdir($directory);
The error that im getting is
[Tue Jun 21 22:27:25.079075 2016] [:error] [pid 21150] [client 192.168.0.8:55413] PHP Warning: mkdir(): Permission denied in .........
Im also getting permission denied for a few other commands like ftp_get()
When i check the phpinfo() the upload_tmp_dir is set to no value.
I am not very good at server admin so any help would be greatly appreciated.
I setup the server from a tutorial, then setup my virtual host from another tutorial.
Thanks Guys :)

you need to confirm that the user starting the PHP service has permission to write to the directory,if not. you can try command sudo chown -R php_user /which_directory_you_want_to_mkdir, than inout root password and run program again. Good luck.
My English is not very good, sorry

Related

Access Telegram-CLI using php

I want to access the Telegram-CLI using PHP.
I'm compiled Telegram-CLI and loged in to my account, and its works like a charm.
I installed LAMP ([in Linux], Apache, MySQL, PHP) and i tested them works.
I even installed these [following] PHP packages one-by-one using "Composer" and tested the examples but i couldnt make them run...
Also it seems their forum are abandoned to get my questions answer.
php-client for telegram-cli
A wrapper for Telegram-CLI
PHP Wrapper and Drupal module using Telegram CLI
Could somebody tell me how to make one of them work in simple way.
All steps of building Telegram-cli, loging in for first time and run it as deamon has beed completed.
For Example:
This project has been installed on php project root dir using "Composer".
Example.php file has been moved to web server root directory.
But also unning it cause a 500 Internal server error.
The error line is:
$telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');
notices:
The file has been checked and is already there.
And the telegram-cli is running as a daemon on root user.
I added a telegramd group and telegramd user assigned to that group.
I detacted that php commands running under apache user account.
I changed the apache user group to telegramd.
But again nothing...
So, Please help me
Edit:
I changed the httpd.conf user and group parameters to run at the same (telegramd) account
User telegramd
Group telegramd
And i have restarted the apache and checked the username by
exec('whoami');
The Apache is running under "telegramd" user account.
But nothing again..
Edit 2:
error_log file:
[Wed Feb 10 11:02:04.251133 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Warning: stream_socket_client(): unable to connect to unix:///tmp/tg.sck (No such file or directory) in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 48
[Wed Feb 10 11:02:04.251332 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Fatal error: Uncaught exception 'Zyberspace\Telegram\Cli\ClientException' with message 'Could not connect to socket "unix:///tmp/tg.sck"' in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php:51\nStack trace:\n#0 /var/www/html/example.php(10): Zyberspace\Telegram\Cli\RawClient->__construct('unix:///tmp/tg....')\n#1 {main}\n thrown in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 51

Why doesn't my tmp_file_upload file exist? I'm using php 5.6

I'm trying to get website to upload images and I'm getting this error:
[Fri Oct 23 21:42:30.075831 2015] [:error] [pid 18652] [client ::1:64412] PHP Warning:move_uploaded_file(): Unable to move '/private/var/tmp/php0HlxVu' to 'images/photo.jpg' in /Users/ridgefrancis/Sites/examples/ch05/initial/guitarwars/addscore.php on line 32, referer: http://localhost/~ridgefrancis/examples/ch05/initial/guitarwars/addscore.php
I've seen the solution to this question already here:
move_uploaded_file gives "failed to open stream: Permission denied " error after all configurations i did
In my attempt to follow these instructions to fix the problem I ran into another problem,
tmp_file_upload file/folder doesn't exist.
What do I do in a case like this?
Thanks in advance!
I was thinking that my upload was not working because of my tmp_file_upload folder but it wasn't. I searched the internet and found out that ppl suggested it was because of that folder.
This piece of code solved my problem.
sudo chmod -R a+w /PATH/TO/IMAGE/FOLDER
I hope it helps someone in the future with the same issue.

Why I'm getting the PHP Fatal error in following scenario?

I'm using LAMP on my local machine. I'm getting the following error in apache error log and a blank web page in browser when I hit the URL:http://localhost/smart-rebate-web/web/admin/forgot_password.php
Following is the error I got in apache error log:
[Tue Apr 15 17:10:18 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required 'includes/public-application-header.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/smart-rebate-web/web/admin/forgot_password.php on line 2, referer: http://localhost/smart-rebate-web/web/admin/login.php?lout=1
For your reference I'm attaching the image of my project structure titled 'smart-rebate-web' in Netbeans editor.
and following is the sceenshot of abrwser after I hit the URL :
http://localhost/smart-rebate-web/web/admin/forgot_password.php
So can anyone please help me in resolving this issue please? Thanks in advance. If you want any further information or any code I can provide you the same. Following asre the permissons of these files if I print in terminal:
-rw-rw-r-- 1 eywa eywa 1646 Apr 14 13:05 application-header.php
-rw------- 1 eywa eywa 1006 Apr 10 18:06 public-application-header.php
You have permission issue. According to your current file permission, only file owner can read and write that file, others cannot read. When you go on browser, default www-data user tries to read that file. And it is not permitted. Make your file 644 or change file owner to www-data. ``www-data` is the apache user used while you open php files from browser. And more flexible way, use following;
require_once(dirname(__FILE__) . "/includes/public-application-header.php");
Try using
require_once('web/admin/includes/<filename>');

Permission denied on codeigniter

I'm running an Apache server on my PC with Debian 7 (well, actually Crunchbang, but it's the same thing).
I was playing with the CodeIgniter framework, and it was working all right. I completed the first tutorial, the one in which you create your first static page (this one: http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html ), and it worked perfectly.
However, as you can see on the very first step, there's a line that goes like this:
[...]
public function view($page = 'home')
[...]
I changed that line to " $page = 'about' ", to try if it could display the other page instead. That's when Hell opened its doors and released the Kraken.
Then it started to show a 404 error, so I changed the settings back again, but the error kept ocurring. I restarted Apache, restarted my PC (I don't know, sometimes it works) and finally, deleted the codeigniter files from my /var/www/ directory, and copied them again.
Now the error is different: It just displays nothing! A blank page, just that. This is what my apache errorlog says:
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/var/www/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/index.php on line 202
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/var/www/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 202
It sounds like the permissions are set incorrectly on your server.
Check what group Apache runs in (I think Debian by default uses www-data), and make sure you set the group owner and read permissions.
# chown www-data:www-data -R /var/www
# chmod g+r -R /var/www
If the above doesn't work, try setting permissions to 777 just to see if the problem lies elsewhere. I couldn't imagine what else could cause that error, though.

Are there any hidden php right permission using imagejpeg() or in apache & php in general? Getting Unable to open Permission denied

I am getting Unable to open ... for writing: Permission denied when I try and resize an image. The code has worked fine for years but after a resent upgrade (I think ) It has stopped working. I have tried changing the permission on the folder to 777 and disabled selunix. Is there any thing that may have changed in my httpd.con file or php.ini file that will disabled a php script right?
The error message from Apache logs:
[Mon Jun 25 08:59:17 2012] [error] [client 127.0.0.1] PHP Warning: imagejpeg(): Unable to open './cache/150_112.5_be636f82ef8e7e22727c81980df16cd5.jpg' for writing: Permission denied in /var/www/html/resize_function.php on line 62, referer: http://jasonrmoore.info/list.php?dir=./
Nop, this is an unix permission issue.
Please check the permission of the permissions of ./cache folder and inner files.

Categories