Jump to content

Featured Replies

Posted

I am switching servers. I've migrated files and databases to the new server, but am getting the Permission denied error. See below

 

An error occurred (500 Error)

We're sorry, but a temporary technical error has occurred which means we cannot display this site right now.

Permission denied

You can try again by clicking the button below, or try again later.

Try again

I've check permissions and they are 755 to all directories. I've got the correct ownership of the files. I got the correct mysql config information in my config file. What else could be the problem?

Edited by NAWAC

  • NAWAC changed the title to Switching Servers, Permission Denied
  • Community Expert

You will want to ensure that the follow directories are writable:

  • applications

  • datastore

  • plugins (if you're on version 4)

  • uploads and all subfolders of uploads

You will also want to ensure that your conf_gloabl.php is correct for your new MySQL server and that your MySQL user has full rights to everything.

  • Community Expert

Can you also check your server error log and see if there are any recent messages logged in there?

  • Author

I think it's probably a MySQL connection issue. May be access rights to the database or something.

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught IPS\\Db\\Exception: Permission denied in 
/var/www/vhosts/mywebsite.com/system/Db/Db.php:269\nStack trace:\n#0 
/var/www/vhosts/mywebsite.com/system/Db/Db.php(356): IPS\\_Db->_establishConnection()\n#1 
/var/www/vhosts/myswebsite.com/system/Db/Db.php(487): IPS\\_Db->checkConnection()\n#2 
/var/www/vhosts/mywebsite.com/system/Db/Db.php(972): IPS\\_Db->preparedQuery()\n#3 
/var/www/vhosts/mywebsite.com/system/Session/Admin.php(112): IPS\\_Db->replace()\n#4 
[internal function]: IPS\\Session\\_Admin->write()\n#5 [internal function]: session_write_close()\n#6 {main}\n thrown in 
/var/www/vhosts/mywebsite.com/system/Db/Db.php on line 269'

I created a simple test file to connect to mysql using the conf_global.php file

include('conf_global.php');
$con = mysqli_connect($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass'], $INFO['sql_database']);
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else {
	echo "connected";
}
exit;

and I am getting a similar Permission denied error in my test.php file.

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught mysqli_sql_exception: Permission denied in 
/var/www/vhosts/mywebsite.com/test.php:25\nStack trace:\n#0 
/var/www/vhosts/mywebsite.com/test.php(25): mysqli_connect()\n#1 {main}\n thrown in 
/var/www/vhosts/mywebsite.com/test.php on line 25'

I know my conf_global.php file contains the correct information because I can use the same information to log into MySQL at the command prompt without a problem. Some how I can't do it in a PHP script though.

Edited by NAWAC

  • Author

So, after some debugging, come to find out the $INFO['sql_host'] needed to be 127.0.0.1 instead of localhost. Which is weird. First time I've seen that on a Linux system. I've seen it on a local Windows PC, but not a Linux system.

Is there any reason I can't use 127.0.0.1 for the production server, if that's what it's requiring in order to run the script(s)?

Edited by NAWAC

  • Author
 

So, after some debugging, come to find out the $INFO['sql_host'] needed to be 127.0.0.1 instead of localhost. Which is weird. First time I've seen that on a Linux system. I've seen it on a local Windows PC, but not a Linux system.

Is there any reason I can't use 127.0.0.1 for the production server, if that's what it's requiring in order to run the script(s)?

After playing around with it, I was finally able to set sql_host to localhost:3306, note I had to include the port for localhost of :3306 to make localhost to work on this server, which is a Plesk server running Almalinux 9, just in case anybody has the same problem. So, in the conf_global.php file looks like 'sql_host' => 'localhost:3306'

  • Community Expert

You can specify the port with a different variable:

  'sql_host' => 'localhost',
  'sql_port' => 3306,

  • Author
 

You can specify the port with a different variable:

  'sql_host' => 'localhost',
  'sql_port' => 3306,

Thanks! I did not know that.

  • 4 weeks later...

I encountered the same error when migrating a server.

1. Enabled remote access to the database.
2. Added IP address 127.0.0.1 to the list of allowed ones.

Recently Browsing 0

  • No registered users viewing this page.