More on WordPress

Learn what more you can explore if you try WordPress locally.

We'll cover the following

localhost domain alternative

If you specify the exposed port as 8001 for WordPress, then it will be launched from the localhost domain on port 8001. However, that can be impractical when you’re developing several sites:

  • Your browser may cache files from one site and show them on another.
  • WordPress stores the domain in its database, so you might want to use something similar to the production name.

Optionally, you can configure other domains for development use in your hosts file. This is located at:

  • /etc/hosts on Linux and macOS
  • C:\Windows\System32\drivers\etc\hosts on Windows (administrator permissions are required to view and edit it).

Add a line to the bottom of the hosts file, e.g.,    dev.wordpress

And save it. The changes are applied immediately on Linux and macOS, but Windows users must run nbtstat -R or reboot.

From then on, you can use http://dev.wordpress rather than http://localhost. Both resolve to the loopback address

The hosts file allows you to override DNS (Domain Name System) information. You can block ad networks and spyware by putting in front of the name of the domain you want to block.

This file can also help when you want to test a development server that you are about to deploy. Add the machine’s IP address and domain name in the hosts file. Now when you access it using its domain name, you will be taken to that server.

Administration panel permissions

WordPress allows you to install, edit, and delete theme and plugin files directly from its administration panels. This is permitted on Windows, but Linux and macOS users must grant access rights to the project’s wp-content folder by entering the following command on the host:

chmod 777 ./wp-content -R

This command grants every user the right to access, read, write, and execute the files in the wp-content folder. The argument -R recursively applies this to every file in that directory.

If you do not grant access rights:

  • WordPress and users testing your site will not be able to change code in the wp-content directory (that could be a good thing).
  • You must manually download plugins and themes from or elsewhere. Extract the ZIP file to an appropriate wp-content subdirectory before enabling it in the administration panels.
  • Some plugins, such as caching systems, will not operate.