Closed kubami closed 1 year ago
Currently issue is being investigated, there are some challenges with user permissions in accessing wp-cli.
@kubami
If you are running interactively via WebSSH, then you need to first update the wp-config.php file with database connection details. The reason is that database connection details are wired into wp-config.php file from the Application Settings and those are accessible only by the main thread that starts the container.
Look for this block of code in wp-config.php file
$connectstr_dbhost = getenv('DATABASE_HOST');
$connectstr_dbname = getenv('DATABASE_NAME');
$connectstr_dbusername = getenv('DATABASE_USERNAME');
$connectstr_dbpassword = getenv('DATABASE_PASSWORD');
Comment it out and add a new block with actual database connection details.
//$connectstr_dbhost = getenv('DATABASE_HOST');
//$connectstr_dbname = getenv('DATABASE_NAME');
//$connectstr_dbusername = getenv('DATABASE_USERNAME');
//$connectstr_dbpassword = getenv('DATABASE_PASSWORD');
$connectstr_dbhost = 'servername.mysql.database.azure.com';
$connectstr_dbname = 'database_name';
$connectstr_dbusername = 'db_username';
$connectstr_dbpassword = 'db_password';
Now try to run the below sample wp-cli commands from WebSSH console.
wp help --path=/home/site/wwwroot --allow-root
wp plugin list --path=/home/site/wwwroot --allow-root
Note: You can retrieve database connection details from your App Service dashboard in Azure Portal. (Configuration -> Application Settings -> Advanced edit)
@kubami - Can you confirm if your issue is resolved and can close this GH issue.
@kubami WP-CLI is now fully enabled in production. You can now access and use it from SSH console of your SCM site.
Please refer to the following document for more details: https://github.com/Azure/wordpress-linux-appservice/blob/main/WordPress/how_to_use_wpcli_tool.md
I see wpcli is installed in the service but I cannot seem to make it work.
I presume it has something to do with the env variables for the db connection not being present in the shell I am in?
I open the ssh connection through Web App -> App Service plan -> Development Tools -> SSH.