Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Invalid configuration #45

Closed
centminmod opened this issue Sep 23, 2017 · 8 comments
Closed

PHP Invalid configuration #45

centminmod opened this issue Sep 23, 2017 · 8 comments

Comments

@centminmod
Copy link

Not sure what I am doing wrong with /root/tools/unitconfigs/phpstart.json

{
     "listeners": {
         "*:8300": {
             "application": "php56domaincom"
         }
     },
     "applications": {
         "php56domaincom": {
             "type": "php",
              "workers": 10,
              "root": "/home/nginx/domains/domain.com/public",
              "user": "nginx",
              "group": "nginx",
              "index": "index.php"
         }
     }
}
curl -X PUT -d @/root/tools/unitconfigs/phpstart.json --unix-socket /var/run/control.unit.sock http://localhost/ 
{
        "error": "Invalid configuration."
}
curl --unix-socket /var/run/control.unit.sock http://localhost/
{
        "listeners": {},
        "applications": {}
}
@igorsysoev
Copy link
Contributor

What is in unit.log ?

@VBart
Copy link
Contributor

VBart commented Sep 23, 2017

More detailed errors in case of invalid configuration will be ready soon.

As of now, since your configuration on my system applies without a problem, there are only two possibilities: there's no nginx user with nginx group on your system or the php module is not found in the configured modules directory.

@VBart
Copy link
Contributor

VBart commented Sep 23, 2017

Well, in your case, it's very likely that the configuration is invalid because of wrong path to the modules directory. As I see from #43, you have unit modules path: "build" configured, but the php module was installed into /opt/unitbuild/ using DESTDIR.

@centminmod
Copy link
Author

thanks, the unit log confirms module path error

tail -100 /var/log/unitd.log 
2017/09/23 06:55:47 [info] 3054#3054 discovery started
2017/09/23 06:55:47 [notice] 3054#3054 no modules matching: "build/*.unit.so" found
2017/09/23 06:55:47 [info] 3055#3055 controller started
2017/09/23 06:55:47 [notice] 3053#3053 process 3054 exited with code 0
2017/09/23 06:55:47 [crit] 3055#3055 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 06:55:47 [info] 3056#3056 router started
2017/09/23 06:55:47 [crit] 3056#3056 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 06:58:20 [notice] 3053#3053 process 3055 exited with code 0
2017/09/23 06:58:20 [notice] 3053#3053 process 3056 exited with code 0
2017/09/23 07:00:58 [info] 3292#3292 discovery started
2017/09/23 07:00:58 [notice] 3292#3292 no modules matching: "build/*.unit.so" found
2017/09/23 07:00:58 [info] 3293#3293 controller started
2017/09/23 07:00:58 [notice] 3291#3291 process 3292 exited with code 0
2017/09/23 07:00:58 [info] 3294#3294 router started
2017/09/23 07:00:58 [crit] 3293#3293 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 07:00:58 [crit] 3294#3294 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 07:24:24 [notice] 3291#3291 process 3293 exited with code 0
2017/09/23 07:24:24 [notice] 3291#3291 process 3294 exited with code 0

@centminmod
Copy link
Author

centminmod commented Sep 23, 2017

thanks with fixed Unit configure setup it's working now

curl -X PUT -d @/root/tools/unitconfigs/phpstart.json --unix-socket /opt/unit/control.unit.sock http://localhost/
curl -X PUT -d @/root/tools/unitconfigs/phpstart.json --unix-socket /opt/unit/control.unit.sock http://localhost/
{
        "success": "Reconfiguration done."
}
curl --unix-socket /opt/unit/control.unit.sock http://localhost/
{
        "listeners": {
                "*:8300": {
                        "application": "php56domaincom"
                }
        },

        "applications": {
                "php56domaincom": {
                        "type": "php",
                        "workers": 10,
                        "root": "/home/nginx/domains/domain.com/public",
                        "user": "nginx",
                        "group": "nginx",
                        "index": "index.php"
                }
        }
}

though I get failed to store current configuration

systemctl status unitd                                                                                           
● unitd.service - NGINX Unit
   Loaded: loaded (/usr/lib/systemd/system/unitd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-09-23 10:19:52 UTC; 15s ago
  Process: 10467 ExecStart=/opt/unit/sbin/unitd (code=exited, status=0/SUCCESS)
 Main PID: 10468 (unitd)
   CGroup: /system.slice/unitd.service
           ├─10468 unit: main [/opt/unit/sbin/unitd]
           ├─10470 unit: controller
           └─10471 unit: router

Sep 23 10:19:52 centos7.localdomain systemd[1]: Starting NGINX Unit...
Sep 23 10:19:52 centos7.localdomain unitd[10467]: 2017/09/23 10:19:52 [info] 10467#10467 unit started
Sep 23 10:19:52 centos7.localdomain systemd[1]: Started NGINX Unit.
Sep 23 10:20:06 centos7.localdomain t/unit/sbin/unitd][10468]: [alert] 10468#10468 failed to store current configuration
tail -20 /var/log/unitd.log   
2017/09/23 10:14:40 [info] 10403#10403 discovery started
2017/09/23 10:14:40 [notice] 10403#10403 module: php 5.6.31 "/opt/unit/modules/php5631.unit.so"
2017/09/23 10:14:40 [notice] 10403#10403 module: python 2.7.5 "/opt/unit/modules/python.unit.so"
2017/09/23 10:14:40 [info] 10404#10404 controller started
2017/09/23 10:14:40 [info] 10405#10405 router started
2017/09/23 10:14:40 [crit] 10404#10404 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 10:14:40 [crit] 10405#10405 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 10:14:40 [notice] 10402#10402 process 10403 exited with code 0
2017/09/23 10:16:18 [alert] 10402#10402 failed to store current configuration
2017/09/23 10:19:52 [notice] 10402#10402 process 10404 exited with code 0
2017/09/23 10:19:52 [notice] 10402#10402 process 10405 exited with code 0
2017/09/23 10:19:52 [info] 10469#10469 discovery started
2017/09/23 10:19:52 [notice] 10469#10469 module: php 5.6.31 "/opt/unit/modules/php5631.unit.so"
2017/09/23 10:19:52 [notice] 10469#10469 module: python 2.7.5 "/opt/unit/modules/python.unit.so"
2017/09/23 10:19:52 [info] 10470#10470 controller started
2017/09/23 10:19:52 [info] 10471#10471 router started
2017/09/23 10:19:52 [crit] 10470#10470 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 10:19:52 [crit] 10471#10471 epoll_ctl(3, 3, 9) failed (2: No such file or directory)
2017/09/23 10:19:52 [notice] 10468#10468 process 10469 exited with code 0
2017/09/23 10:20:06 [alert] 10468#10468 failed to store current configuration

looks like /opt/unit/state directory wasn't created.. manually creating seems to fix it

ls -lah state/
total 4.0K
drwxr-xr-x 2 root root  22 Sep 23 10:28 .
drwxr-xr-x 6 root root  78 Sep 23 10:28 ..
-rw------- 1 root root 217 Sep 23 10:28 conf.json
cat state/conf.json 
{"listeners":{"*:8300":{"application":"php56domaincom"}},"applications":{"php56domaincom":{"type":"php","workers":10,"root":"/home/nginx/domains/domain.com/public","user":"nginx","group":"nginx","index":"index.php"}}}

@VBart
Copy link
Contributor

VBart commented Sep 23, 2017

Igor suggested --prefix=/opt/unit --state=state and that configures /opt/unit/state path as the internal state storage for unit daemon.

In this case, the /opt/unit/state directory need to be created and be writable by the main process.

@VBart
Copy link
Contributor

VBart commented Sep 23, 2017

If you compile unit with the --debug option, you will see more information about what's wrong.

@centminmod
Copy link
Author

thanks @VBart for clarification :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants