WordPress with Gruxi web server
In this example, we will show how to set up Gruxi to serve a WordPress site on Windows or Linux using the PHP processor. This allows you to easily host a WordPress site on your Windows machine with Gruxi, without needing to set up a separate web server or PHP environment.
This example is also useful for developers who want to quickly set up a local WordPress development environment, or for anyone who wants to host a WordPress site on a server using Gruxi. It demonstrates how Gruxi can be used to serve dynamic PHP applications like WordPress with ease.
Check out WordPress's website for more information on WordPress.
The setup
Let's assume you have a WordPress site located in C:\wordpress on Windows or /var/www/wordpress on Linux. You want to set up Gruxi to serve that WordPress site at http://localhost/ for local development.
This requires Gruxi to handle PHP requests and serve the WordPress application correctly. Additionally, since WordPress relies on URL rewriting for pretty permalinks, we will also set up a rewrite function in Gruxi to ensure that the URLs are handled correctly.
Prerequisites:
- Gruxi installed and running on your machine
- WordPress files located in
C:\wordpresson Windows or/var/www/wordpresson Linux - A database set up for WordPress (e.g., MySQL) and the database connection details ready
- PHP installed and configured to work with Gruxi (either via PHP-FPM on Linux or PHP-CGI on Windows)
- A wp-config.php file configured with the correct database connection details and other settings for your WordPress site
TIP
If you expect to host multiple sites (WordPress or otherwise) on the same Gruxi server, it is recommended to set up separate sites in the Gruxi configuration for each one, and point each site to the correct web root and PHP processor configuration. This allows you to easily manage multiple sites with different configurations on the same Gruxi server.
For local development, you can use the localhost hostname or a custom hostname (e.g., mywordpress.local) that points to 127.0.0.1 in your hosts file. For production hosting, you would use the appropriate domain name that points to your Gruxi server.
You can set up Gruxi to serve your WordPress site as follows:
Log in to the Gruxi admin portal and open the configuration.
Add a
Siteand fill out the hostname (e.g.,localhostor just keep the*wildcard if it is the only site).Add the rewrite function
OnlyWebRootIndexForSubdirsto the site, which is useful for WordPress and allows requests to subdirectories that do not exist on the filesystem to be rewritten to the web root. This is important for WordPress's permalink structure to work correctly.Add a
Static File ProcessorPriority 1 underProcessors.- This handles requests for static files (e.g., images, CSS, JavaScript)
- Point the
Web Rootto the directory where your WordPress files are located (e.g.,C:\wordpresson Windows or/var/www/wordpresson Linux).
Add a
PHP ProcessorPriority 2 underProcessors.- Set the
Served Byto the appropriate PHP handler based on your setup (PHP-FPM for Linux or Windows PHP-CGI for Windows). - Set the
Local Web Rootto the directory where your WordPress files are located (e.g.,C:\wordpresson Windows or/var/www/wordpresson Linux). - Configure the PHP handler settings according to your PHP setup (e.g., FastCGI IP and port for PHP-FPM, or managed instance for PHP-CGI on Windows).
More information on setting up PHP processor
For detailed instructions on how to set up the PHP processor for both Windows and Linux, check out our PHP processor documentation, which covers both PHP-FPM and PHP-CGI setups in detail.
- Set the
Set the
Server Software Spoofingfield in the site configuration tonginx. WordPress behaves differently when it detects certain server software in HTTP headers and checks it against hard-coded values in the WordPress code. Setting it to "nginx" ensures that WordPress works correctly with permalinks and other features.
Save that configuration and reload it in the admin portal. You should now be able to access your WordPress site at http://localhost/ (or your chosen hostname) through Gruxi, and all features of WordPress should work correctly, including permalinks and dynamic content.
Do you want to use TLS/SSL during development of a WordPress site on Gruxi?
Gruxi makes it easy to set up TLS/SSL for your sites. You can simply add the hostname you want to use (e.g., mywordpress.local) in the site configuration and Gruxi will automatically generate a self-signed TLS certificate for that hostname (if it is on a binding with TLS enabled). Then you can access your WordPress site securely at https://mywordpress.local/ through Gruxi. This is great for local development, as you can test your WordPress site with HTTPS without needing to set up a separate TLS certificate or web server.
For production TLS/SSL with WordPress on Gruxi
For production hosting of your WordPress site on Gruxi, you can use a custom domain name that points to your Gruxi server, and then set up TLS/SSL for that domain using Gruxi's built-in TLS support. You can use a free TLS certificate from Let's Encrypt or use your own TLS certificate. Gruxi will handle the TLS termination for you. This allows you to serve your WordPress site securely over HTTPS in production with ease.
Read more about Gruxi's TLS support in the TLS documentation.