Google App Engine local WordPress install error with MAMP - wordpress

I'm trying to set-up WordPress to run on Google App Engine.
I'm following the docs over here with MAMP as my local dev environment. The app runs okay through the GAE Launcher, but when I browse the localhost:PORT, I get:
Error establishing a database connection
I've tried changing the define('DB_HOST','localhost'); value to localhost:3306 (my MAMP MySQL port), 127.0.0.1, and even the socket address (:/Applications/MAMP/tmp/mysql/mysql.sock) - but I can't get past the database connection error.
I'm wondering if I have misinterpreted the instructions. I originally thought that the database name, username and password were just placeholders that one was supposed to customize, both in Step 3 (create database and user) and 4 (edit config file). But, hoping I could run it remotely on App Engine, I looked at their sample SQL they use to set up the database and they're using the generic terms (wp_user, wp_password) in their SQL stored in Cloud Storage. Does anyone know what is the correct procedure?
I'm seriously stuck. Can someone help?

Try the following:
Remove the ** from DB_NAME, DB_USER and DB_PASSWORD, i.e. use:
define('DB_NAME', 'wordpress_db');
/** MySQL database username */
define('DB_USER', 'wp_user');
/** MySQL database password */
define('DB_PASSWORD', 'wp_password');
When you create your user in MySQL, make sure you use the #localhost terminology as shown.
If all else fails, start with WordPress 3.5.1.

I found a better way of creating a database by following this video by Google Developers.
If you use MAMP, go to terminal and type
/Applications/MAMP/Library/bin/mysql --host=ipaddressOfCloudSQL -uroot -ppassword
Once you login, you can follow the rest of the instructions as follows.

I don't know if you still have this issue, but this is an issue of where the app SDK is looking for the file MYSQL sockets file (mysql.sock). I'm not sure where whether you can configure this somehow, but this worked for me since the default folder that the SDK looks for the file is /tmp:
cd /tmp
ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
If you simply link the MAMP sockets files to the one that google's app engine expects locally, it works. :)

Related

Restoring WordPress site only from htdocs's webstie folder

I had a wordpress site hosted on localhost using xampp.
Due to unexpected problems only what I've got from my old XAMPP files is htdocs's folder of mentioned site. Is there a way to restore the old website only from this file only?
WordPress content is stored in the database. If you don't have your MySQL database exported (.sql file extension) from phpMyAdmin (web) or mysqldump (CLI), you'll have files without content, and likely a lot of PHP errors. The database also has the configuration for which theme to use, which plug-in(s) to enable, your Dashboard login (and users), etc.
If you have command line access to your MySQL database, you can use the following command to get a copy of your database:
mysqldump --add-drop-table -u USERNAME -p DBNAME > DBNAME.sql
This assumes the hostname is "localhost", but you can specify the hostname with -h HOSTNAME.
--add-drop-table is not required, but helpful if you're wanting to start clean with a database import. Keep in mind that it will delete the table in its entirety, so if you've already got a live site using the same database and table prefix, you're wiping out that live site.
-p will prompt you for the password once connected to the MySQL server. If successful, there won't be any output as the database is exported into the filename you provided.
You can name the output file anything you want, but it's a good idea to keep it the same name of your database, or even SITE_database.sql (i.e.: mysite.com_database.sql).
However, if you have the export of your MySQL database, you can import it with the following command:
mysql -u USER -p DBNAME < DBNAME.sql
Similarly, you'll be prompted for the password, and if no errors on the command prompt, the import should have been successful. With your site content and MySQL database restored, your site should appear as it was, content and all.

Issue with connection FTP wordpress on appengine

I am starting with Appengine on GCP and recently had installed Wordpress. But when i tried to install plugins o some themes, i see a window:
Connection Information To perform the requested action, WordPress
needs to access your web server. Please enter your FTP credentials to
proceed. If you do not remember your credentials, you should contact
your web host.
I saw the post with the same issue and I add to the file php.ini:
google_app_engine.disable_readonly_filesystem = 1
and tried to deploy the app again, but doesn't work.
Does someone have wordpress on Appengine in Standard environment running without troubles ?
Best approach is to run Wordpress locally and then deploy to appengine. After lot of trials and failures, I have made these notes for my own reference, and hope these help you too. Here you can run the wordpress site on a separate service on appengine and have multiple services to run different wordpress sites. This way you need only one instance of CloudSQL which is cost effective
On GAE:
Your project ID (myGcpProjectID).
Create SQL Instance if not already exists (instance name: projectwideSQLInstance)
Do not have to create a new instance for wordpress, unless you need security and
don’t mind increased cost.
Create database (name: wordpressDatabase)
Create user and assign a pwd (user: wordpressDBUser ; user: wordpressDBUserPassword)
On your local machine:
Install Composer from https://getcomposer.org/
Run following commands in CloudShell SDK inside your work folder
composer require google/cloud-tools
vendor\bin\wp-gae create
**Answer the series of questions **
Region of SQL instance to be same as from GAE
dir: wordpressforgae (or any other name, this is just your local folder)
project_id: myGcpProjectID
sql_instance: projectwideSQLInstance
db_name: wordpressDatabase
db_user: wordpressDBUser
db_pwd: wordpressDBUserPassword
same user for local? Y
All required wordpress files will be downloaded into the folder wordpressforgae.
Open MySQL Workbench and create a schema with name wordpressDatabase (same as db_name above) on your local server
Download latest version of wordpress and extract contents to a folder named localwp
Install XAMPP (Only Apache server and PHP, Deselect all other options).
Delete the contents inside the htdocs inside XAMPP folder and Copy the contents from localwp (extracted from downloaded Wordpress.zip file).
Run wordpress using a browser with localhost in address line. It will ask you for database details. Answer as below: (Make sure these values match with what you added to CloudSQL instance in the beginning)
Server: yourlocalhost
Database name: wordpressDatabase
User: wordpressDBUser
Password: wordpressDBUserPassword
Necessary fields are added to the database and it will ask you to Enter site details along with site admin name and pwd. Enter site details here. Once everything is done and site is created, check the same by opening “localhost” in another browser, which should show a basic WP website with your site title etc. Now close both browsers.
Now delete the contents of htdocs folder inside xampp
Copy the contents from folder "wordpressforgae" (downloaded with command wp-gae create) and paste inside the htdocs folder of xampp.
Check wp-config.php to ensure these
if ($onGae) {
/** The name of the Cloud SQL database for WordPress */
define('DB_NAME', wordpressDatabase);
/** Production login info */
define('DB_HOST', ':/cloudsql/ myGcpProjectID:project_region:projectwideSQLInstance');
define('DB_USER', wordpressDBUser);
define('DB_PASSWORD', wordpressDBUserPassword);
} else {
/** The name of the local database for WordPress */
define('DB_NAME', wordpressDatabase);
/** Local environment MySQL login info */
define('DB_HOST', 'localhost');
define('DB_USER', wordpressDBUser);
define('DB_PASSWORD', wordpressDBUserPassword);
}
Now open the wordpress admin in browser with address localhost/wp-admin. Make all changes including adding/removing themes, uploading images, creating pages or anything else. Check website on another browser as you are making changes.
Uploading site to GAE:
First time, use this command to upload
gcloud app deploy app.yaml cron.yaml
If you like to create the website on a different service than default inside your Appengine add this line to app.yaml
runtime: php72
service: wordpress (can be a different name for each site)
For any subsequent minor changes made to site locally, same can be reflected on GAE by simply exporting the database from local to GAE Cloudinstance using MySQL Workbench.
Only If major changes are made to design, like new theme, add images from local machine etc deploy to GAE using
gcloud app deploy app.yaml cron.yaml
It is better to clear the bucket using this before each deploy (Make sure you have enabled delete rights using IAM - Add Role "Storage Admin" for the email ID you are using on CloudShell login to your GCP account)
gsutil -m rm gs://staging.myGcpProjectID.appspot.com/**
If you have different domains/subdomains you want to direct to each of these sites, you may do the same by adding domains to your appengine and configure dispatch.yaml file to redirect each domain/subdomain to corresponding service on appengine

Local By Flywheel - Error establishing a database connection

I was working on a website for a client a week ago and I came back to make further edits, but whenever I want to access the website, it reads:
Error establishing a database connection
I checked my wp-config file and everything is untouched; I did not touch one single line of code here when setting up my new Wordpress project in Local by Flywheel.
All my other local websites work except for this one. I've provided an image of my workspace just to make it more clear.
Looking at this image, the MySQL Version is a little bit off. The version should in fact be 5.6.37, but instead it's reading an older version of MySQL.
I did try closing and reopening Local by Flywheel, but it had no effect.
Any help appreciated. Thank you!
Right click on the site name and click on “Reveal in Finder” in Local by Flywheel.
Compress the folder containing all your site in a *.ZIP file (normally there must be at least the “app” and “logs” folder, sometimes “conf”).
In Local by Flywheel, import the site manually in FILE / IMPORT SITE, choose the Zip of your site
Normally, it reinstalls the site and recreates the Database … for me it’s work (on Windows and on Mac)
Are you able to compare your wp-config.php file in the broken site to a site that is using the same MySQL server?
I know you said that the file is untouched, but check again that all of the define parameters are correct.
Next I would suggest logging into your MySQL server using the credentials you have listed in the wp-config.php file and ensure you are able to access your database.

Edit file permissions using SFTP to Google Cloud Engine Wordpress website

My goal is to update 1 file on my Wordpress website on Google Cloud Engine using Filezilla to transfer it.
I am successfully logged into my files using SFTP. I'm on a Mac. I have my vm instance name from Google Cloud Engine but cannot find how to create a password.
I think if I can figure out how to create a ding dang password my next step is to type this in terminal:
sudo chwown "vm-name" /var/www/html
Any direction is much appreciated. My website has been down since yesterday b/c I messed with https plugin. I'm a designer and got in way over my head. Learned more than bargained for so far.
To run any linux command inside your instance you need to:
Generate a private/public key pair using Puttygen.
You need to add the content of your public key to GCP as in below answer.
How can i setup remote project with PhpStorm with Google Compute Engine running LEMP?
You need to open Putty.
In the Session menu enter yourusername#instance_external_ip as a hostname using connection type SSH
In the menu Connection/SSH/Auth browse and select your private key(the one generated at step 1).
Click Open. A new terminal window will open. You will be abel to navigate inside your linux instance and do whatever sudo commands you wish.
Good luck

Creating a MAMP Local Copy of a Drupal 6 Website

We're currently rebranding a client of ours and it's come the time to take the new brand to their website.
I've not much experience with Drupal other than the theming (I've themed a Drupal website in the past but not very familiar with the software's inner workings).
As this website is live, it's obviously not feasible for me to make any changes to the live environment, so I have downloaded the source files of the website to a local webserver (MAMP).
I also have a MySQL dump of the database.
I'm not sure what files need to be changed inside Drupal to allow access to the MAMP webserver. Could somebody point me in the right direction here?
How would I connect the database to the website, which files need modification?
I think the client is running Drupal 6.
Update:
I've installed the database and linked it up using the below line:
$db_url = 'mysql://root#localhost/databasename';
I've hidden databasename for anonymity.
As it's MAMP, the database has no password. When I load up the website I get an error that install.php is not found. It's not there because the website is already 'installed'.
I've also updated the $base_url to read:
$base_url = 'http://localhost:8888/foldername';
You only need to modify one file, 'sites/default/settings.php'; you'll just need to change the database connection string in there to match your new database settings. There may be a couple of other settings in there you need to tweak depending on the set up of the site (for example the $base_url or $cookie_domain).
Other than that everything in your installation should be relatively path-ed so there shouldn't be any need to make more changes.
i was facing same problem after couple of hours try i got solution : we have to check the DB (tick on list of databases in local host) [ observe this after DB list : Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server. so enable only the db you want to use] this will redirect to http://localhost:8888/foldername/install.php successfully :D :D

Resources