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

Change content button on click form [closed]
Using Str_replace to remove info from an outputted invoice
PHP, Conditional “If..Then..Else” to Remove Based on Certain Delimiter
php preg_replace change so it doesn't remove plus sign +
Customise CSS attribute using form field value
How to write mysql query into PDO
AJAX. PHP. CURL. Ajax request to site, with another encoding
Redirecting error messages
dynamically filling <ul></ul> in javascript and php
Title to Variable in Email
How to make a html table appear using ajax and jquery?
Complex ORM in DooPHP
extract date from datatime in php or Cakephp [duplicate]
Php Replace In String Except Between Delimiters
MySQL Timestamp formatting
Youtube API v.3 - PHP - Refresh Token revoked unexpectly

Categories

HOME
rust
ionic2
extjs
powerbi
mod-rewrite
android-studio
azure-functions
matrix
schema.org
barcode-scanner
redmine
scroll
haproxy
ews
website
odata
docker-cloud
google-play-services
ontology
roku
yahoo
lapack
mailmerge
django-rq
pinterest
vertica
android-contacts
exec-maven-plugin
office-ui-fabric
salt-cloud
infrared
adobe-illustrator
pfobject
offline-caching
monitor
argv
osx-lion
serversocket
express-session
redgate
testlink
microkernel
utf
vb.net-to-c#
angular-datatables
moinmoin
kitura
freshdesk
algebra
portability
maatwebsite-excel
gapi
yargs
java-2d
livereload
xcode8-beta4
bbc-micro
jeditable
swiffy
polymerfire
seadragon
django-validation
ibm-was
apple
ngcordova
mobilefirst-server
com0com
physicsjs
quercus
innerhtml
sablecc
n-tier-architecture
tabris
jquery-mobile-flipswitch
lmax
coding-efficiency
mfmessagecomposeview
sqlbindparameter
bittorrent-sync
infinite
mp4parser
blobstorage
multiscaleimage
workflow-manager-1.x
fitch-proofs
navigationcontroller
quartz-core
yuidoc
multidrop-bus
boost-foreach
radscheduler
qt-mobility
tablet-pc
mysqli-multi-query
code-camp
html-generation
webclient.uploaddata

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App