The Nautilus application development team is planning to launch a new PHP-based application, which they want to deploy on Nautilus infra in Stratos DC. The development team had a meeting with the production support team and they have shared some requirements regarding the infrastructure. Below are the requirements they shared:
a. Install nginx on app server 3 , configure it to use port 8098 and its document root should be /var/www/html.
b. Install php-fpm version 7.2 on app server 3, it should listen on port 9000.
c. Configure php-fpm and nginx to work together.
d. Once configured correctly, you can test the website using curl http://stapp03:8098/index.php command from jump host.
==========
I have tried few time but can not pass this mission.
Could you please help to review for me. Thank you.
=========
vi /etc/nginx/nginx.conf
location ~ \.php$ {
try_files $uri = 404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /
{
index index.php index.html index.htm;
}
sed -i “/^user = apache*/c\user = nginx” /etc/php-fpm.d/www.conf
sed -i “/^group = apache*/c\group = nginx” /etc/php-fpm.d/www.conf
[root@stapp03 ~]# cat /etc/php-fpm.d/www.conf | grep -v ^‘;’
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
[root@stapp03 ~]# php-fpm -v
PHP 7.2.24 (fpm-fcgi) (built: Oct 22 2019 08:28:36)
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
systemctl enable nginx
systemctl start nginx
systemctl status nginx
[root@stapp03 ~]# curl localhost:8098
502 Bad Gateway
502 Bad Gateway
nginx/1.14.1
Error:
2024/03/31 07:31:25 [crit] 2702#0: *3 connect() to unix:/run/php-fpm/www.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: _, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/run/php-fpm/www.sock:”, host: “localhost:8098”