This is my first setup web server & dns server, I’m using:
- nginx
- php7.4 (shivammathur/php/[email protected])
And I’ve problem while setup my local app to run multiple app:
- yii 1 (/Users/ademugnirusmana/Project/www/wms) => www.wms.local
- laravel 7 (/Users/ademugnirusmana/Project/www/middleware) => www.middleware.local
- codeigniter 3 (/Users/ademugnirusmana/Project/www/reporting) => www.reporting.local
When I try using command php -S localhost:8080
inside directory of yii project, everthing work well, but when I call the domain in the browser (www.wms.local
), there is an error "File not found"
Here my config nginx (sample for yii):
server {
listen 80;
server_name www.wms.local;
root /Users/ademugnirusmana/Projects/www/wms;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
}
Here config host
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
#127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.wms.local
#127.0.0.1 www.reporting.local
#127.0.0.1 www.middleware.local
Here the fpm config "usr/local/etc/php/7.4/php-fpm.d/www.conf"
listen = 127.0.0.1:9000
Here the fpm "ps aux| grep nginx"
ademugnirusmana 16744 0.0 0.0 34130864 468 s000 S+ 11:24am 0:00.01 tail -f /usr/local/var/log/nginx/error.log
nobody 15649 0.0 0.0 34161744 1396 ?? S 11:18am 0:00.01 nginx: worker process
root 9749 0.0 0.0 34161536 1544 ?? Ss 10:24am 0:00.01 nginx: master process nginx
ademugnirusmana 17616 0.0 0.0 34141260 916 s001 S+ 11:35am 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox --exclude-dir=.venv --exclude-dir=venv nginx
Here the permission of the directory (sample yii)
drwxr-xr-x 18 nobody nobody 576 25 Nov 10:52 /Users/ademugnirusmana/Projects/www/wms
Here the log from "nginx"
2024/11/25 11:29:34 [crit] 15649#0: *52 stat() "/Users/ademugnirusmana/Projects/www/wms/" failed (13: Permission denied), client: 127.0.0.1, server: www.wms.local, request: "GET / HTTP/1.1", host: "www.wms.local"
2024/11/25 11:29:34 [error] 15649#0: *52 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: www.wms.local, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.wms.local"
Here the log from "fpm"
[25-Nov-2024 11:40:35] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[25-Nov-2024 11:40:35] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[25-Nov-2024 11:40:35] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[25-Nov-2024 11:40:35] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[25-Nov-2024 11:40:35] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[25-Nov-2024 11:40:35] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[25-Nov-2024 11:40:35] ERROR: FPM initialization failed
[25-Nov-2024 11:40:35] ERROR: FPM initialization failed
Can someone help me where I’ve done wrong with the config or anything to fix?
Additional Notes:
I’ve setup on mac Monterey 12.7.6 (Intel Chipset)
2
Answers
It seems that your php-fpm is unable to start since something is already using port 9000. Either switch to a different port or free port 9000 and try again.
You can use netstat to find out which process is using port 9000:
Also, make sure that your project is in
/Users/ademugnirusmana/Projects/www/wms
and maybe enclose it in quotes and add a trailing slash.The nginx config that you pasted above is not the one invoked when running
php -S localhost:8080
, because that commands connects to port 8080 and your nginx config is set to listen on port 80.Change permissions for the other users and group for /Users/ademugnirusmana/Projects/www/ location.
chmod -R go+r /Users/ademugnirusmana/Projects/www/