My smarty template is not displaying - php

I am using Php Smarty on Linux.
I have a line in my Php file:
$phpsmart->display("pagetemplate.tpl");
This line is supposed to display pagetemplate.tpl. It doesn't.

Enable errors, or check your logs. The most likely thing is that you haven't set up writeable directories needed by smarty.
I just installed smarty with composer:
$ composer.phar require smarty/smarty
And tried the demo:
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./templates_c/wrt56681191371d80_85949214 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
I then created that 'template_c' folder, and made it writeable by the web server.
( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./cache/wrt566812bd6f7b08_17223124 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
I then created the 'cache' folder, and made it writeable by the web server.
The demo then worked.
See the quick install.

It doesn't display a tpl file even after changing the file permissions and ownership of a file.
for people who are having problem like this.
1) chmod -R 755 /var/www -> This will give read write permission to the owner and other for the group( the owner belongs to), and others the permission in read and execute. and this is assigned recursively so all your files and directories inside www will also be having the same permissions
2) chown -R apache:apache /var/www ->This will give make apache owner of www and including files. This is also applied recursively.
3)your website owner needs write permission to template_c file so check using ls -altr to see whether it has given the write permission, if write is like 755(rwxr-xr-x) and still not working change it to 777 (remember chmod). also check the cache folder..
4) If still it's not working may be selinux is protecting write access to your template_c file. so for this you need the following command
setsebool -P httpd_unified=1 -> This will disable selilnux for apache httpd.
Enjoy!

Related

move_uploaded file:failed to open stream: Permission denied in /srv/http/upload.php

I am trying to run a server on ArchLinux, I have apache and PHP running normally, but i can't upload a file with PHP. I have seen many questions of this sort on Stackoverflow and I seem to have used all the suggestions I found, but I still get a
failed to open stream: Permission denied in /srv/http/upload.php
error.
To be precise
Warning: move_uploaded_file(): Unable to move '/tmp/phpZvJK1l' to '/home/administrator/SCRIPTS/tr/solution.cpp' in /srv/http/upload.php on line 20
I set the permissions for /tmp/, /home/administrator/SCRIPTS/tr and /srv/http to 777 (I know thats not right, but I am working locally right now and I want to get it working somehow).
Also I set all the owner of these directories to http (that is the user running PHP), but the thing still doesnt work.
Some PHP configurations do not allow file access outside the users docroot directory, so you may not have access to /tmp from within PHP. Try uploading your file(s) to a temp directory within your /home/administrator directory - preferably to a directory that isn't accessible to web browsers (a sibling directory to your docroot).
give permission to the /tmp dir :
sudo chmod 777 /tmp
As an Arch user I have the same issue when I work on web projects.
I'll recommend you to see this part of the Arch Wiki
User directories are available by default through http://localhost/~yourusername/ and show the contents of ~/public_html (this can be changed in /etc/httpd/conf/extra/httpd-userdir.conf).
So do to so you have to create the ~/public_html directory then
You must make sure that your home directory permissions are set properly so that Apache can get there. Your home directory and ~/public_html must be executable for others ("rest of the world"):
$ chmod o+x ~
$ chmod o+x ~/public_html
$ chmod -R o+r ~/public_html
After that you don't need to put your file under /srv/http/ you can now use ~/public_html as development directory.

Laravel: "Failed to open stream' in storage/views

I had my Laravel 3 application running on a different server. I wrapped it up and sent it to my new server. Unpacked it, and while I am trying to display the Laravel application on the new server, I receive this error:
Unhandled Exception Message:
file_put_contents(/var/www/customer_area/storage/views/13f378cf44cd9253eb03394b5a7fd914):
failed to open stream: Permission denied
Location:
/var/www/customer_area/laravel/blade.php on line 63
I have already read through this question several times where others have solved a similar problem by changing permissions on 'storage/directories' to '775'. I even changed permissions on the entire 'var/www' directory to '777', and I still have the error.
Something that I noticed is that there is no '13f378cf44cd9253eb03394b5a7fd914' in the storage/views folder. There are five other files in the folder, but not that one.
Assuming you are running apache on linux, look into recursive chgrp www-data and chown www-data on the folders
Just modify file/folder permissions
Assuming you are in root folder, run one of these commands
chmod -R 0777 storage // for L3
chmod -R 0777 app/storage // for L4

Warning: require(file): failed to open stream

I've changed development machines and have moved across one of my projects. However, when I try to run one of the files in this project, I get the following error message:
Warning: require(/var/www/libraries/facebook.php): failed to open stream: Permission denied in /var/www/logout.php on line 11 Fatal error: require(): Failed opening required '/var/www/libraries/facebook.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/logout.php on line 11
Anyone know why this would be happening?
It might be that I have the permissions set incorrectly. What should the file and folder permissions be?
All files are currently set to -rw-r--r-- and folders are set to drwx------, is that right?
Sometimes when things get moved paths can change. The error indicates that the file '/var/www/libraries/facebook.php' could not be found. Make sure that the file exists in that location.
Sometimes the web server runs with different credentials than the user. Try setting the directories to drwxr-x---, and the files to -rw-r--r--. If that doesn't work, then try changing the directories to drwxr-xr-x.
You are getting a Permission denied error which means that your libraries folder can only be accessed by the root user. Try to execute the script as a root user or give read permissions to the folder.
## use only for files ##
chmod 0444 /var/www/*
chmod 0444 /var/www/*.php
TO set directories in read-only mode, enter:
## use only for dirs ##
chmod 0544 /var/www/
chmod 0444 /path/to/your/dir/
You say the permissions are drwx------. Try changing to the /var/www/libraries directory in the shell as a non-root user. If you get an error there, the web server will also. You might need 755 permissions so the server can traverse to that directory. Just be careful what else is in that folder since it could be readable by the whole world.

chmod() operation not permitted - FatFree framework

I have been developing an app in FatFree framework and now I am trying to deploy it on a server. Everything seems to be fine when I am running it on localhost.
However, when I have deployed it on the server and trying to access it, it gives me a strange error which is -
Internal Server Error
chmod(): Operation not permitted
#0 /var/www/webapp/inc/main.php:62 Template::serve('front_page.php')
#1 /var/www/index.php:65 F3::run()
I have given 777 permissions to the webapp folder so chmod() should be allowed. The above suggests that there is an error while serving the template file front_page.php.
How can I fix this?
For this you have to give the permissions recursively using -R for your "webapp" folder
Siddharth alludes to the correct answer in the comments:
F3 compiles templates to a temp/ dir before serving. This temp dir needs to a) exist and b) have appropriate permissions.
To achieve this, go the dir where your template file exists and run:
mkdir temp/
chown www-data temp
Check intermediary directories permissions It's a common gotcha.
You can add write permissions for web-server to your [fatfree-web-root-dir]. Not safe!
chmod o+w fatfree-web-root-dir # Then web-server can create "temp" folder.
An other way: You must create "temp" directory with web-server owner:
mkdir fatfree-web-root-dir/temp
chown www-data:www-data fatfree-web-root-dir/temp
# www-data - in Debian for example

Changing permissions via chmod at runtime errors with "Operation not permitted"

When I use chmod() to change permissions at run time, it gives me the below message:
Warning: chmod() [function.chmod]: Operation not permitted in /home/loud/public_html/readalbum.php
How can I remove this error and make the chmod function work?
$ sudo chmod ...
You need to either be the owner of the file or be the superuser, i.e., user root. If you own the directory but not the file, you can copy the file, rm the original, then mv it back, and then you will be able to chown it.
The easy way to temporarily be root is to run the command via sudo. ($ man 8 sudo)
In order to perform chmod, you need to be owner of the file you are trying to modify, or the root user.
This is a tricky question.
There a set of problems about file permissions. If you can do this at the command line
$ sudo chown myaccount /path/to/file
then you have a standard permissions problem. Make sure you own the file and have permission to modify the directory.
If you cannnot get permissions, then you have probably mounted a FAT-32 filesystem. If you ls -l the file, and you find it is owned by root and a member of the "plugdev" group, then you are certain its the issue. FAT-32 permissions are set at the time of mounting, using the line of /etc/fstab file. You can set the uid/gid of all the files like this:
UUID=C14C-CE25 /big vfat utf8,umask=007,uid=1000,gid=1000 0 1
Also, note that the FAT-32 won't take symbolic links.
Wrote the whole thing up at http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/
You, or most likely your sysadmin, will need to login as root and run the chown command:
http://www.computerhope.com/unix/uchown.htm
Through this command you will become the owner of the file.
Or, you can be a member of a group that owns this file and then you can use chmod.
But, talk with your sysadmin.

Categories