php


PHP rename() permission denied via Apache (SELinux related)


I have a simple script that outputs Permission denied warning in the browser:
rename('/opt/web/test.tmp', '/opt/web/test.tmp1')
Script path is /opt/web/test_rename.php
/opt/, /opt/web/ and /opt/web/test_rename.php are 777 and have apache owner / group.
httpd process owner is apache
test.tmp is 777 and have apache owner as well
It works fine with cli.
What else could I do to make it work via apache?
The problem was with SELinux. It can block php rename function.
I've found the answer here: http://forums.fedoraforum.org/archive/index.php/t-111081.html
On the Fedora Core 3 Linux distribution, you may get a "failed to open stream: Permission denied in ..." message. In fact changing the permission of the directory will not work (even if you set to 0777).
It is because of the new SELinux kernel that allow apache user to write only in /tmp dir (I think). In order to solve the problem you must to disable the SELinux (at least for apache service) to allow the server to write in other directories. To do that, run the system-config-securitylevel app and disable the SE to apache service. Reboot your system and continue your work.

Related Links

Check the value exist in codeigniter
yii2 Access control is not working
Auth module for Kohana
Is Symfony3 as maintainable and powerful as Symfony2 regarding of functionality and comunity
php - phpMailer Cron add's an email to the queue while it shouldn't
Is it possible to add laravel paginate() function in select?
export pdf from phpreport in server cannot show
Wordpress password how to compare user password to wordpress user table password?
PHP curl and Apache fcgid conflict
How to get feature dates according to given date PHP
Code not deleteing all record from multiple tables
get column names from stored procedure for displaying in html table using php
How to keep your tests small while using data providers?
Event calendar not showing February
How do I install sqlite on Laravel 5 for WAMP?
what is the preg_match condition to ensure the first digit is a number 7?

Categories

HOME
user-interface
lambda
mpdf
freeradius
shinyapps
facebook-messenger
swi-prolog
compilation
haproxy
subdomain
plpgsql
hdfs
embedded-resource
biztalk
google-webmaster-tools
mosquitto
repair
scheduler
responsive-design
tup
cqrs
clish
stimulsoft
user-defined-types
tomcat8
asciimath
pickle
scheduled-tasks
error-logging
fluent-migrator
acl
pubxml
high-availability
fusion
john-the-ripper
plantuml
private-key
overwrite
ms-media-foundation
spring-rabbitmq
nppexec
sspi
resampling
get-event-store
vb.net-to-c#
ol3-google-maps
uiautomatorviewer
gnome-terminal
alertify
yui3
xcode6.4
system.web.optimization
carmen
mathml
dojo-build
jemdoc
verisign
flipclock
flask-security
pack
grinder
boost-proto
srv-record
bjam
auto-generate
gluon-desktop
modern.ie
swagger-maven-plugin
embeddedwebserver
alwayson
actionpack
sql-processor
sunos
fasterxml
hp-idol-ondemand
password-recovery
dnsjava
xml-signature
dmake
storing-data
mobile-country-code
visual-c++-2012
lumia-imaging-sdk
category-theory
network-printers
incognito-mode
flipboard
progress-db
django-facebook
coalesce
form-for
objective-c-runtime
insertion
spiral
xmlwriter
office-app
lynx
autosize
nsfont
wiktionary
winsxs
photo-management
digiflow
active-record-query
resharper-5.0
eventaggregator

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App