How to Use ".wp-config.php.swp" to Create wp-config file

Tessando used Ask the Experts™
I've got a client who's running Bitnami Wordpress using AWS Lightsail.

When I go to the page, it's completely white. I thought this was pretty unusual behavior so I did some Google-Fu and found a known permissions issues that has to do with Group and Ownership.

This requires adjusting the ownership of the wp-config.php file, a normal file that should be located at the root of Wordpress.

It's not.

Which is frustrating.

When I locate it using this command: locate wp-config.php

I find it in a swap file form: e.g.



How can I take that ".wp-config.php.swp" and move it to "~/apps/wordpress/htdocs", which is where index.php is for some reason and where I expected to find the "wp-config.php" file.

Thanks for your help.


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Ah mod_pagespeed. The source of many a problem.

If you have a .wp-config.php.swp this is an editor swap file which might or might not be useful.

This file is a binary version of your file in a format only the original editor program can understand.

You can attempt recovery of your wp-config.php file like this.

# cd to the exact directory where this file lives, as some editors dislike absolute paths during recovery
cd .../

# edit the file using the exact editor used before (likely vi) + follow recovery instructions.
# Likely this will be typing R + ENTER
vi wp-config.php

# If you followed the recovery instructions + now see the actual file contents, exit the editor by typing...

# You'll now have a copy of your wp-config.php file in some state, which will be better than nothing

Open in new window

Note: It's super rare for vi to die, unless to OOM Killer kills it or the machine reboots while vi is running.

In either case, you should still be able to see your wp-config.php file in the correct location.

If this is true, then you will remove the .swp file completely, as saving it may destroy the wp-config.php file your site is currently using.
TessandoIT Administrator


Thanks David. I love that VI trick and I am able to open multiple config files on the Clients server with VI, so we're good there.

What I can't seem to do is find the dang thing.

What do the commas mean in the results of this locate statement?


Open in new window

In other words, when I go to "/opt/bitnami/apache2/var/cache/mod_pagespeed/v2/" I cannot get to http, even as "sudo". I just haven't encountered those commas before.

Fractional CTO
Distinguished Expert 2018
Ah... This is a cache file (/opt/bitnami/apache2/var/cache/...) so this file might show up when you do a locate + likely will be gone by the time you arrive.

Tip: If wp-config.php.swp shows up in your cache directory, this likely points to someone hacking your site.

Here's how this works.

1) People craft a URL which can access the wp-config.php.swp file.

2) This is likely a security flaw in bitnami packaging.

3) #2 allows *.swp files to actually be served by Apache (shudder... truly apocalyptic...), so if you happen to be editing wp-config.php + the hacker catches this file when it exists, the #2 security flaw actually provides this file to the hacker.

Note: This is why you see the file in your cache directory. If bitnami security was sensible, you should never see a .swp file being served.

BTW: Apache by default serves .swp files also... A serious security problem...

4) If you do updatedb + locate again, likely the file will be gone now out of the locate database.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start Today