I’ve been able to setup (with much help from here
) a local WordPress development setup. Here is the current working lamp.nix file:
{ config, pkgs, lib, ... }:
let
php' = pkgs.php83.buildEnv {
extensions = ({ enabled, all }: enabled ++ (with all; [
xdebug
imagick
]));
extraConfig = ''
memory_limit = 1024M
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.idekey = gdbp
'';
};
webPath = "/var/www";
# webPath = "/mnt/vault/www";
sites = [
"example.org"
];
in
{
networking.hosts = {
"127.0.0.1" = [
"example.org"
];
};
services.mysql.enable = true;
services.mysql.package = pkgs.mariadb;
services.mysql.ensureDatabases = [
"example.org"
];
services.mysql.ensureUsers = [
# NOTE: it is important that `name` matches your `$USER` name, this allows us to avoid password authentication
{ name = "sergio";
ensurePermissions = {
"*.*" = "ALL PRIVILEGES";
};
}
];
services.phpfpm.pools."example.org" = {
user = "sergio";
group = "users";
phpPackage = php';
settings = {
"listen.owner" = config.services.caddy.user;
"listen.group" = config.services.caddy.group;
"pm" = "dynamic";
"pm.max_children" = 5;
"pm.start_servers" = 2;
"pm.min_spare_servers" = 1;
"pm.max_spare_servers" = 5;
"php_admin_value[error_log]" = "stderr";
"php_admin_flag[log_errors]" = true;
"catch_workers_output" = true;
};
};
services.caddy.enable = true;
services.caddy.virtualHosts."https://example.org:443".extraConfig = ''
root * ${webPath}/example.org
php_fastcgi unix/${config.services.phpfpm.pools."example.org".socket}
file_server
'';
# automatically create a directory for each site you will work on with appropriate ownership+permissions
systemd.tmpfiles.rules = [
"d ${webPath}/example.org 0755 sergio users"
];
}
If I change webPath to "/mnt/vault/www" (the NFS server), I get a 403 error. I think it’s from Caddy, though not sure. I can access a test.php file on the server, just not the WordPress front or back end, so it’s kinda/sorta working…
File permissions are the same on both ends and so are the files:
[sergio@samara:/var/www/example.org]$ ls -l
total 244
drwxr-xr-x 3 sergio users 4096 Jun 26 13:07 '$XDG_CACHE_HOME'
-rw-r--r-- 1 sergio users 405 Jun 26 13:07 index.php
-rw-r--r-- 1 sergio users 19915 Jun 26 13:07 license.txt
-rw-r--r-- 1 sergio users 7401 Jun 26 13:07 readme.html
-rw-r--r-- 1 sergio users 207 Jul 2 00:26 test.php
-rw-r--r-- 1 sergio users 7387 Jun 26 13:07 wp-activate.php
drwxr-xr-x 9 sergio users 4096 Jun 26 13:07 wp-admin
-rw-r--r-- 1 sergio users 351 Jun 26 13:07 wp-blog-header.php
-rw-r--r-- 1 sergio users 2323 Jun 26 13:07 wp-comments-post.php
-rw-rw-rw- 1 sergio users 3284 Jun 26 13:59 wp-config.php
-rw-r--r-- 1 sergio users 3012 Jun 26 13:07 wp-config-sample.php
drwxr-xr-x 5 sergio users 4096 Jun 27 20:11 wp-content
-rw-r--r-- 1 sergio users 5638 Jun 26 13:07 wp-cron.php
drwxr-xr-x 30 sergio users 16384 Jun 26 13:07 wp-includes
-rw-r--r-- 1 sergio users 2502 Jun 26 13:07 wp-links-opml.php
-rw-r--r-- 1 sergio users 3927 Jun 26 13:07 wp-load.php
-rw-r--r-- 1 sergio users 50917 Jun 26 13:07 wp-login.php
-rw-r--r-- 1 sergio users 8525 Jun 26 13:07 wp-mail.php
-rw-r--r-- 1 sergio users 28427 Jun 26 13:07 wp-settings.php
-rw-r--r-- 1 sergio users 34385 Jun 26 13:07 wp-signup.php
-rw-r--r-- 1 sergio users 4885 Jun 26 13:07 wp-trackback.php
-rw-r--r-- 1 sergio users 3246 Jun 26 13:07 xmlrpc.php
Not sure where to go from here as I’m just getting started with NixOS. Any ideas/help woudl be very much appreciated.
The logs for the various services should provide you more information.
Usually you can look at them with:
journalctl -u SERVICENAME.service
If you don’t know the service name you can either try to find it with systemctl list-units or look at the global log with plain journalctl. It might require sudo to view certain logs.
When I did that, for phpfpm and cady nothing seemed to change much… I’ll have another go at it when I get to my computer. Thanks.
[sergio@samara:~/.nixos]$ sudo journalctl -f -u phpfpm-example.org.service
Jun 29 11:26:58 samara php-fpm[967]: [NOTICE] Terminating ...
Jun 29 11:26:58 samara systemd[1]: Stopping PHP FastCGI Process Manager service for pool example.org...
Jun 29 11:26:58 samara php-fpm[967]: [NOTICE] exiting, bye-bye!
Jun 29 11:26:58 samara systemd[1]: phpfpm-example.org.service: Deactivated successfully.
Jun 29 11:26:59 samara systemd[1]: Stopped PHP FastCGI Process Manager service for pool example.org.
Jun 29 11:27:01 samara systemd[1]: Starting PHP FastCGI Process Manager service for pool example.org...
Jun 29 11:27:01 samara php-fpm[32404]: [NOTICE] fpm is running, pid 32404
Jun 29 11:27:01 samara php-fpm[32404]: [NOTICE] ready to handle connections
Jun 29 11:27:01 samara php-fpm[32404]: [NOTICE] systemd monitor interval set to 10000ms
Jun 29 11:27:01 samara systemd[1]: Started PHP FastCGI Process Manager service for pool example.org.
Can’t seem to find anything wrong with the configuration or services. Only difference I can think of is one has files accessed through NFS the other locally.
This is what I’m seeing when restarting the services:
systemctl restart caddy.service caddy-api.service phpfpm-nerdpress.localhost.service phpfpm.target phpfpm.slice mysql.service
sudo journalctl -u caddy.service -u mysql.service -u phpfpm-nerdpress.localhost.service -f
Jul 02 16:45:31 samara systemd[1]: Stopping Caddy...
Jul 02 16:45:31 samara systemd[1]: caddy.service: Deactivated successfully.
Jul 02 16:45:31 samara systemd[1]: Stopped Caddy.
Jul 02 16:45:31 samara systemd[1]: caddy.service: Consumed 153ms CPU time, 13.7M memory peak, 0B memory swap peak, received 2.0K IP traffic, sent 2.0K IP traffic.
Jul 02 16:45:31 samara systemd[1]: Starting Caddy...
Jul 02 16:45:31 samara caddy[75606]: {"level":"info","ts":1719963931.9674852,"msg":"using provided configuration","config_file":"/etc/caddy/caddy_config","config_adapter":"caddyfile"}
Jul 02 16:45:31 samara php-fpm[73517]: [NOTICE] Terminating ...
Jul 02 16:45:31 samara systemd[1]: Stopping PHP FastCGI Process Manager service for pool nerdpress.localhost...
Jul 02 16:45:31 samara php-fpm[73517]: [NOTICE] exiting, bye-bye!
Jul 02 16:45:31 samara systemd[1]: Started Caddy.
Jul 02 16:45:31 samara systemd[1]: phpfpm-nerdpress.localhost.service: Deactivated successfully.
Jul 02 16:45:31 samara systemd[1]: Stopped PHP FastCGI Process Manager service for pool nerdpress.localhost.
Jul 02 16:45:32 samara systemd[1]: Starting PHP FastCGI Process Manager service for pool nerdpress.localhost...
Jul 02 16:45:32 samara systemd[1]: phpfpm-nerdpress.localhost.service: Deactivated successfully.
Jul 02 16:45:32 samara systemd[1]: Stopped PHP FastCGI Process Manager service for pool nerdpress.localhost.
Jul 02 16:45:32 samara systemd[1]: Starting PHP FastCGI Process Manager service for pool nerdpress.localhost...
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] /nix/store/k7nxqxkkjqxv6l5wr14jfc4ycjlkdans-mariadb-server-10.11.6/bin/mysqld (initiated by: unknown): Normal shutdown
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: FTS optimize thread exiting.
Jul 02 16:45:32 samara systemd[1]: Stopping MySQL Server...
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: Starting shutdown...
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: Buffer pool(s) dump completed at 240702 16:45:32
Jul 02 16:45:32 samara php-fpm[75649]: [NOTICE] fpm is running, pid 75649
Jul 02 16:45:32 samara php-fpm[75649]: [NOTICE] ready to handle connections
Jul 02 16:45:32 samara php-fpm[75649]: [NOTICE] systemd monitor interval set to 10000ms
Jul 02 16:45:32 samara systemd[1]: Started PHP FastCGI Process Manager service for pool nerdpress.localhost.
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] InnoDB: Shutdown completed; log sequence number 132235077; transaction id 295229
Jul 02 16:45:32 samara mysql-start[73529]: 2024-07-02 16:45:32 0 [Note] /nix/store/k7nxqxkkjqxv6l5wr14jfc4ycjlkdans-mariadb-server-10.11.6/bin/mysqld: Shutdown complete
Jul 02 16:45:32 samara systemd[1]: mysql.service: Deactivated successfully.
Jul 02 16:45:32 samara systemd[1]: Stopped MySQL Server.
Jul 02 16:45:32 samara systemd[1]: Starting MySQL Server...
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] Starting MariaDB 10.11.6-MariaDB source revision fecd78b83785d5ae96f2c6ff340375be803cd299 as process 75660
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Warning] WSREP: Failed to guess base node address. Set it explicitly via wsrep_node_address.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Warning] WSREP: Failed to guess base node address. Set it explicitly via wsrep_node_address.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Warning] WSREP: Guessing address for incoming client connections failed. Try setting wsrep_node_incoming_address explicitly.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] WSREP: Node addr:
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Compressed tables use zlib 1.3.1
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Number of transaction pools: 1
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Using liburing
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Completed initialization of buffer pool
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: End of log at LSN=132235077
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: 128 rollback segments are active.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: log sequence number 132235077; transaction id 295228
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] Plugin 'FEEDBACK' is disabled.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] Server socket created on IP: '0.0.0.0'.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] Server socket created on IP: '::'.
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] /nix/store/k7nxqxkkjqxv6l5wr14jfc4ycjlkdans-mariadb-server-10.11.6/bin/mysqld: ready for connections.
Jul 02 16:45:32 samara mysql-start[75660]: Version: '10.11.6-MariaDB' socket: '/run/mysqld/mysqld.sock' port: 3306 MariaDB Server
Jul 02 16:45:32 samara mysql-start[75660]: 2024-07-02 16:45:32 0 [Note] InnoDB: Buffer pool(s) load completed at 240702 16:45:32
Jul 02 16:45:32 samara systemd[1]: Started MySQL Server.
Issue was having sub-volumes shared in NFS. I moved them all to the same directory and shared them one by one. All set now! Hope this helps somebody. I turned out to be an NFS config issue…
1 Like