Nginx Permission Issue with AppArmor
I am encountering issues while running Nginx, specifically a permission error. To troubleshoot, I disabled AppArmor temporarily using apparmor_parser -r
to check if the issue originated from AppArmor. However, I did not find any apparent issues. After restarting my PC, a permission issue surfaced in the home directory .valet
.
Permissions of .valet Directory
ls -la .valet
total 8
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 126 Dec 14 01:56 .
drwx------ 1 abbasmashaddy72 root 730 Dec 14 02:19 ..
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 0 Dec 13 22:46 Certificates
-rw-r--r-- 1 abbasmashaddy72 abbasmashaddy72 177 Dec 14 01:56 config.json
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 42 Dec 13 22:46 Drivers
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 0 Dec 13 22:46 Extensions
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 30 Dec 13 22:46 Log
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 10 Dec 13 22:46 Nginx
drwxr-xr-x 1 abbasmashaddy72 abbasmashaddy72 0 Dec 13 22:46 Sites
lrwxrwxrwx 1 abbasmashaddy72 abbasmashaddy72 41 Dec 14 01:56 valet.sock -> /home/abbasmashaddy72/.valet/valet82.sock
AppArmor Configuration for Nginx Permissions
#include <tunables/global>
/usr/sbin/nginx {
# Allow read access to Nginx log files
/home/abbasmashaddy72/.valet/Nginx/* rw,
/home/abbasmashaddy72/.valet/Nginx/** rw,
# Add any other necessary rules here
/usr/lib/libcrypt.so.1 mr,
/usr/lib64/libcrypt.so.1 mr,
}
sudo apparmor_parser -r /etc/apparmor.d/local/usr.sbin.nginx
Error Message on Nginx Service Status
sudo systemctl status nginx.service
× nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Thu 2023-12-14 01:56:08 IST; 1min 24s ago
Process: 31003 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=127)
CPU: 32ms
Dec 14 01:56:08 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 14 01:56:08 localhost.localdomain nginx[31003]: /usr/sbin/nginx: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: Permission denied
Dec 14 01:56:08 localhost.localdomain systemd[1]: nginx.service: Control process exited, code=exited, status=127/n/a
Dec 14 01:56:08 localhost.localdomain systemd[1]: nginx.service: Failed with result 'exit-code'.
Dec 14 01:56:08 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Checked Main Libraries
sudo ldconfig -p | grep libcrypt
libcryptsetup.so.12 (libc6,x86-64) => /lib64/libcryptsetup.so.12
libcrypto.so.3 (libc6,x86-64, hwcap: "x86-64-v3") => /lib64/glibc-hwcaps/x86-64-v3/libcrypto.so.3.1.4
libcrypto.so.3 (libc6,x86-64) => /lib64/libcrypto.so.3
libcrypt.so.1 (libc6,x86-64) => /lib64/libcrypt.so.1
libcrypt.so.1 (libc6) => /lib/libcrypt.so.1
libcrypt.so (libc6,x86-64) => /lib64/libcrypt.so
ls -la /lib
lrwxrwxrwx 1 root root 7 Dec 11 00:19 /lib -> usr/lib
ls -la /lib64
lrwxrwxrwx 1 root root 9 Dec 11 00:19 /lib64 -> usr/lib64
Checked Local Libraries
ls -la /usr/lib
lrwxrwxrwx 1 root root 17 Oct 9 12:05 libcrypt.so.1 -> libcrypt.so.1.1.0
-rwxr-xr-x 1 root root 214452 Oct 9 12:05 libcrypt.so.1.1.0