Cannot properly read files on the local server
Posted
by
Andrew Bestic
on Server Fault
See other posts from Server Fault
or by Andrew Bestic
Published on 2012-03-25T11:13:47Z
Indexed on
2012/03/25
11:32 UTC
Read the original article
Hit count: 316
I'm running a RedHat 6.2 Amazon EC2 instance using stock Apache and IUS PHP53u+MySQL (+mbstring, +mysqli, +mcrypt), and phpMyAdmin from git. All configuration is near-vanilla, assuming the described installation procedure.
I've been trying to import SQL files into the database using phpMyAdmin to read them from a directory on my server. phpMyAdmin lists the files fine in the drop down, but returns a "File could not be read" error when actually trying to import. Furthermore, when trying to execute file_get_contents(); on the file, it also returns a "failed to open stream: Permission denied" error.
In fact, when my brother was attempting to import the SQL files using MySQL "SOURCE" as an authenticated MySQL user with ALL PRIVILEGES, he was getting an error reading the file. It seems that we are unable to read/import these files with ANY method other than root under SSH (although I can't say I've tried every possible method). I have never had this issue under regular CentOS (5, 6, 6.2) installations with the same LAMP stack configuration.
Some things I've tried after searching Google and StackExchange:
- CHMOD 0777 both directory and files,
- CHOWN root, apache (only two users I can think of that PHP would use),
- Importing SQL files with total size under both upload_max_filesize and post_max_size,
- PHP open_basedir commented out, or = "/var/www" (my sites are using Apache VirtualHosts within that directory, and all the SQL files are deep within that directory),
- PHP safe mode is OFF (it was never ON)
At the moment I have solved this issue with the smaller files by using the FILE UPLOAD method directly to phpMyAdmin, but this will not be suitable for uploading my 200+ MiB SQL files as I don't have a stable Internet connection.
Any light you could shed on this situation would be greatly appreciated. I'm fair with Linux, and for the things that do stump me, Google usually has an answer. Not this time, though!
© Server Fault or respective owner