Jump to content

Recommended Posts

Posted

Добрый день.

Пытаюсь запустить на Кинетике микро-сайт. Не получается настроить выполнение php-скриптa. Может кто сталкивался.

Что делал:

Установил nginx, php8.

root@Keenetic:/opt/var/log$ opkg list-installed | grep php8
php8 - 8.0.13-1
php8-cgi - 8.0.13-1
php8-cli - 8.0.13-1
php8-fastcgi - 8.0.13-1
php8-fpm - 8.0.13-1
php8-mod-curl - 8.0.13-1
php8-mod-dom - 8.0.13-1
php8-mod-iconv - 8.0.13-1
php8-mod-mbstring - 8.0.13-1
php8-mod-session - 8.0.13-1
php8-mod-simplexml - 8.0.13-1
php8-mod-xml - 8.0.13-1
php8-mod-zip - 8.0.13-1
Поправил конфигурационный файл nginx:

...

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  /opt/var/log/nginx/host.access.log;

        location / {
            root   /opt/share/nginx/html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
        #    fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/opt/var/run/php8-fpm.sock;
            fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  /opt/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
...

Настроил права и запустил php8-fpm

root@Keenetic:/opt/var/run$ ls -l
-rw-r--r--    1 root     root             4 Dec 10 08:00 dropbear.pid
-rw-r--r--    1 root     root             5 Dec 17 15:40 nginx.pid
-rw-r--r--    1 root     root             4 Dec 17 15:40 php8-fpm.pid
srw-rw----    1 nobody   nobody           0 Dec 17 15:40 php8-fpm.sock

В каталоге /opt/share/nginx/html создал файл info.php:

root@Keenetic:/opt/share/nginx/html$ cat info.php
<?php phpinfo(); ?>
При обращении браузером на http://192.168.2.1:8080 открывается тестовая страница nginx.

Если открыть http://192.168.2.1:8080/info.php - получаю сообщение "No input file specified."

При этом в логе nginx вижу записи:

2021/12/17 15:40:37 [error] 8656#0: *1 FastCGI sent in stderr: "Unable to open primary script: /opt/share/nginx/html/info.php (No such file or directory)" while reading response header from upstream, client: 192.168.2.xx, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/opt/var/run/php8-fpm.sock:", host: "192.168.2.1:8080"

Проверил доступность файла /opt/share/nginx/html/info.php из под пользователя nobody - доступно, файл открывается на чтение.

Помогите дельным советом.

 

Posted

Сайт, вернее html-страница, корректно открывается в локалке. Проблема возникает именно при запуске php-скрипта. Есть же обращение к php8-fpm. Только он в свою очередь уже скрипт не может выполнить. Как будто не обозначена эта директория в логически доступных для сервиса. 

Posted

Эм... В первом сообщении написал что установил nginx через opkg: opkg install nginx.

Тут, похоже, дело в сборке php8. Где-то нужно прописать "доверенный хом". На "больших" линуксах это в настройках сервиса делается. А в Кинетике... вопрос. 

Posted
13 минуты назад, kai78 сказал:

Где-то нужно прописать "доверенный хом".

Я бы не стал так скоро переходить от догадок к утверждениям. Посмотрите прежний пример настройки, наверняка какой-то мелочи не хватает.

Posted

Проблему решил. Первоначальное предположение подтвердилось. Дело было в настройках PHP.

В файле /opt/etc/php.ini параметр doc_root имел значение doc_root = "/opt/share/www". Изменил его на doc_root = "/opt/share/nginx/html"  и всё заработало.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking "I accept" or continuing to browse the site, you authorize their use in accordance with the Privacy Policy.