How do you specify a human-readable localhost url (i.e. localhost/loremipsum) for a local web app using Docker Desktop for Windows? - wordpress

I'm just starting out with Docker for the first time as a replacement for XAMPP. All I'm doing is hosting a local instance of WordPress (and an associated MySQL database) on my (Win 11) laptop to use as a personal journal. I installed Docker Desktop and followed these instructions to create a compose file to install and run my WordPress instance. It worked fine, and when the image(?) is running, I can view my WordPress instance at localhost in a browser.
Before doing that, I tried out the docker tutorial, and I noticed that it forwarded to localhost/tutorial. I'd like to replicate that. How can I get my WordPress instance to map to something like localhost/example instead of just localhost?

Docker does not have routing based on path, this is up to your web server to configure different paths for root page (or root directory as WP calls it). That said it is basically a common change on wordpress URL Site URL if you want to as well the files location.
Here is the docs from WP on how to do it https://wordpress.org/support/article/giving-wordpress-its-own-directory/#method-ii-with-url-change. I'm going to rewrite just the steps that will change since you are using docker-compose that you created following the wordpress development environment article
1 - Create the new location for the core WordPress files to be stored (we will use /example in our examples). (On your Windows 11 create a new folder named example under ./wordpress)
2 - In WordPress address (URL): set the address of your main WordPress core files. Example: http://localhost/example
3 - In Site address (URL): set root directory’s URL. Example: http://localhost/example
8 - Open your root directory’s ./wordpress/index.php file in a text editor
9 - Change the following and save the file. Change the line that says: require __DIR__ . '/wp-blog-header.php'; to the following, using your directory name for the WordPress core files require __DIR__ . '/example/wp-blog-header.php';
10 - Login to the new location. It might now be http://localhost/example/wp-admin
Step 3 is optional, in case you want to change your site address as well. The rest of the steps are the same from the WP documentation, please follow that.
Now you can access WP or you site using http://localhost/example

Related

why can I see wordpress site directories & files in browser?

I installed WP locally on XAMPP.
When I manually type my project root in a browser I start seeing this. But when I run the project through VScode Live server I start seeing all files and directories of my site see here.
Why does this happen? Is it because I run the project locally? Or is it because the root is followed by :5050 port number?
My theme style.css is empty.
My theme index.php contains only starting html !+tab attributes (see here)
The first image looks like to be served by apache which loads mod_php which "executes" the php code of every .php file and serve the result as html.
The second image looks like an application running on port 5000 (which might not be apache) and NOT using a module to "execute" .php file so it just shows the content of the folder.

problem on moving Wordpress website from Localhost to Server

I ve created my wordpress website on local, then I hosted it using ovh and filezilla
I followed these steps
upload source files under www fileZilla
import my database on ovh
update wp-config
The problem is when i launch my site it still get css files from localhost nd showing this error
Failed to load resource: net::ERR_CONNECTION_REFUSED
You cannot import a WordPress database and have it just work because there are plenty of hard links (including hostname, in your case localhost) in it.
There are several ways to change the URL in the database. My favorite way is to use wp-cli ( https://wp-cli.org/ ) on the command line. Once installed and having the wp command inside your PATH, you can change (cd) to your WP installation's root directory (where the wp-config.php file is located) and run the following command:
wp search-replace 'http://localhost' 'https://your-new-domain.com' --export=my_wp_export.sql
Replace your-new-domain.com by whatever you're using on your ovh host. Be careful when selecting http or https depending on whether you have a valid SSL certificate in place and your hosting is correctly set up for HTTPS, or not.
You now have an SQL file where each localhost URL is replaced by your-new-domain.com. Next, upload and import the my_wp_export.sql file - everything should work.

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

Running wordpress site different local host

I have recently taken my first programming project and it is with word press, I have never used it before as I have only done hard coding HTML/CSS before. My client has given me all of the files of her site, how do I run this on wordpress. I have installed wordpress and can run the test123 site but when I do the same thing on the local server with the info she gave me then I get a "Error establishing a database connection". This is surprising because all of the file folders in the info she gave me is the same as the test site (obv the content is different). She was doing it on a mac and I am on windows but I assume that hsouldn't matter. How can I fix this so I can see the site on wordpress and make the required changes that she wanted.
Thanks!
I tried changing the config file but that just gives me the setup again and not the site she has already made :(
First, create a folder into your htdocs folder with name test123
now put all the directory which one provide you by client in to test123 folder like wp-admin , wp-content ....etc
after then in new tab run this path
http://localhost/phpmyadmin/
Create a database with name something test , then import the database which one provide to you by your client , after import go to table name wp-options and change the site url http://localhost/test123 same for admin URL
Now back to your files and open wp-config.php file from your test123 folder root directory , change database name which one you recently created "test"
username set to "root" and password "blank" hostname should be "localhost"
now run path in to URL http://localhost/test123
after this if you want to login http://localhost/test123/wp-admin
then first you need to change user password with md5 strings from database wp-user table
the site will work on localhost
Here some change for wordpress project on host to other host .
in your sql file change host name example
to change
http://localhost
after change to your config file details.
installation WordPress in wamp server
first, start wamp server
click to start all services when it will work the icon will be colored green
Go to C:\wamp\www and paste WordPress folder there. You can rename the WordPress folder to anything you want for example test123
Now open a web browser and go to:
http://localhost/test123/
it will ask you for database connection error
now open the phpmyadmin as showing into create
a database and import the database
then go to you Wordpress folder test123 and find the wp-config.php file and replace your username with "root" database name you created , and password blank . now run http://localhost/test123/ once again
if not work then please come to chat box room.

Could I host a website under an old one?

I have a website has already hosted on EasyCgi (suppose that it's called website1).
I have to host another one (website2). So I created a folder called "website2" under the website1 root folder. then I FTP all the content of website2 to the "website2" folder.
After that, I tried to request the URL: and nothing happen...
Just an error page display that contains:
Any help appreciated.
You need to create separate vhost in your hosting management console - it will create separate directory & link it to separate domain name.
If it has no such feature - you are out of luck.

Resources