php 7 with ubuntu 14.04 and nginx

How can I get this working?

I have php 7 installed php -v PHP 7.1.4-1+deb.sury.org~trusty+1 (cli) (built: Apr 11 2017 22:45:20) ( NTS ) Copyright (c) 1997-2017 The PHP Group

https://www.virtualmin.com/documentation/web/nginx -says virtaulmin will pick highest available version but still i get php 5.5.9 output in phpinfo ()

https://93.170.77.37/cron/php

I even tried to remove php5 and purge everything. Still does not matter. Server still using php 5. What am I doing wrong?

Thank you for any help!

Status: 
Closed (fixed)

Comments

Howdy -- if you go into System Settings -> Re-Check Config, what PHP versions does it detect there?

The following PHP versions are available : 5.5.9 (/usr/bin/php5), 7.0.20 (/usr/bin/php-cgi7.0), 7.1.4 (/usr/bin/php7.1)

PHP-FPM support is available on this system.

PHP versions have changed to 5, 7.0, 7.1 since last check. Regenerating any missing php.ini files.

Did you perhaps install PHP 7 after creating the virtual server that's running the older version?

That could be that case. You cannot change php on the already running vm?

Adding a new PHP version to the server doesn't change the PHP version being used for existing domains (we'd be afraid that it could cause some web apps to break).

However, it's no problem to manually change it.

To change the PHP version for a given domain, go into Server Configurations -> PHP Versions, and there you can tweak the PHP version.

When I go there I get:

Website options cannot be edited, as no Apache virtual host for fitradio.sk port 80 was found!

Ok, that's a problem. If you go to Limits and Validation -> Validate Virtual Servers and validate this domain, what error does it report?

posilnovanie.sk BIND DNS domain : This domain has email enabled, but none of the MX records point to it. Either the MX records should be corrected, or the email feature disabled if mail is hosted externally. Webalizer reporting : No webserver log found for virtual host posilnovanie.sk Log file rotation : No webserver log found for virtual host posilnovanie.sk Nginx SSL website : The Nginx virtual host is not accepting connections on IP address 93.170.77.41 and port 443 Nginx website : The Nginx virtual host root directory is , but Virtualmin expects it to be /home/posilnovanie/public_html

for another domain which is there using nginx too when I check php versions it says the same, but validation says everything is ok... well it cannot find apache cos we are using nginx ??? Logically?

Ok, it looks like there are some Nginx configuration issues for posilnovanie.sk. Can you post the Nginx config for that domain to this bug report? It should be in a file under /etc/nginx/sites-enabled.

Thank you for your reply. Here is the config content for posilnovanie.sk

server {
        listen 93.170.77.41;
        server_name posilnovanie.sk;
        return 301 https://posilnovanie.sk$request_uri;
        }
server {
        listen 93.170.77.41;
        server_name www.posilnovanie.sk;
        return 301 https://posilnovanie.sk$request_uri;
        }
server {
        server_name posilnovanie.sk www.posilnovanie.sk;
        listen 93.170.77.41;
        root /home/posilnovanie/public_html;
        index index.html index.htm index.php;
        access_log /var/log/virtualmin/posilnovanie.sk_access_log;
        error_log /var/log/virtualmin/posilnovanie.sk_error_log;
        fastcgi_param GATEWAY_INTERFACE CGI/1.1;
        fastcgi_param SERVER_SOFTWARE nginx;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param SCRIPT_FILENAME /home/posilnovanie/public_html$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param REQUEST_URI $request_uri;
        fastcgi_param DOCUMENT_URI $document_uri;
        fastcgi_param DOCUMENT_ROOT /home/posilnovanie/public_html;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param REMOTE_ADDR $remote_addr;
        fastcgi_param REMOTE_PORT $remote_port;
        fastcgi_param SERVER_ADDR $server_addr;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param HTTPS $https;
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/php-nginx/148922278710184.sock/socket;
        }

        location / {
        try_files $uri $uri/ /index.php;
        }
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
        expires           15d;
        }
        listen 93.170.77.41:443 ssl;
        ssl_certificate /home/posilnovanie/ssl.cert;
        ssl_certificate_key /home/posilnovanie/ssl.key;
        rewrite http://www.posilnovanie.sk https://posilnovanie.sk permanent;
        rewrite http://posilnovanie.sk https://posilnovanie.sk permanent;
        rewrite_log off;
}
Category: Support request » Bug report

Those two additional server blocks are the problem :

server {
        listen 93.170.77.41;
        server_name posilnovanie.sk;
        return 301 https://posilnovanie.sk$request_uri;
        }
server {
        listen 93.170.77.41;
        server_name www.posilnovanie.sk;
        return 301 https://posilnovanie.sk$request_uri;
        }

You should remove them.

Thank you, Jamie for looking into this. But if I remove it, what is the proper way to set redirects?

I'm not extremely familiar with the Nginx config, but to be compatible with Virtualmin they would all need to be in the one server block.

Jamie, this way redirects does not work. We get "Too many redirects this way". I also checked several other resources and they all say, like, you need to use separate server blocks for redirect.

Actually, in Virtualmin itself, under Services > Configure Nginx Website. There is URL rewriting menu. I put there redirects from http to https and it does nothing :) Maybe I used wrong syntax, I do not know.

I used

http://posilnovanie.sk > https://posilnovanie.sk

I tried it with one server block in config.

Another option instead of having multiple server blocks is to use a directive like :

if ($scheme != "https") {
    rewrite ^ https://$host$uri permanent;
}

inside your one server block.

Redirect worked :) ty! do you think we can now anyhow change php version w/o reinstalling the VM?

Any chance we can get access to your system to see what's going wrong here?

is it possible that u would connect to my pc via teamviewer and I would connect u via ssh to server so u can check?

Teamviewer can be difficult to schedule, would it be possible to connect directly to SSH?

For security, we can provide an SSH key if you don't wish to share a password.

thats what I get when I try to install support module.

================

root@server:/# apt-get install webmin-virtualmin-support Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic linux-headers-4.4.0-66 linux-headers-4.4.0-66-generic linux-image-4.4.0-64-generic linux-image-4.4.0-66-generic linux-image-extra-4.4.0-64-generic linux-image-extra-4.4.0-66-generic Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: webmin-virtualmin-support 0 upgraded, 1 newly installed, 0 to remove and 36 not upgraded. Need to get 21.0 kB of archives. After this operation, 61.9 MB of additional disk space will be used. WARNING: The following packages cannot be authenticated! webmin-virtualmin-support Install these packages without verification? [y/N] y Err http://software.virtualmin.com/ubuntu/ virtualmin-universal/main webmin-virtualmin-support all 1.6 401 Unauthorized [IP: 163.172.162.254 80] E: Failed to fetch http://software.virtualmin.com/ubuntu/dists/virtualmin-universal/main/bi... 401 Unauthorized [IP: 163.172.162.254 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Jamie, do you happen to have your SSH public key?

Yes, here it is :

ssh-dss AAAAB3NzaC1kc3MAAACBALPtrQgus8wMeTrxiQREVKNGK1b8S9MLcsVngXsaNL2IpzHzajjDxEhkxARlpREFdvhPB9XEMa8IYVRmScyYaAMoespibzq1A24kcBQ3iLDrgoTb/UiRxv7c84WhQud1YpbteKpcpfG582wste+3FqkzvQ6pbNcI0Kkuruhb0s+HAAAAFQDDRVRFXdmNFNR+N3D/XwkIAb7hhQAAAIB0GN+AIuA9OonKbJpgoKz3TKhWNf6DAm39y8Zb//zMaK8/Lc1FMpOsNI/R4Y6LPvCJeAyDXuf/5OT3+613xu70bSSUi2g4UXA6RM/PlSUhdEH4XmG8SoB9abaIObU2AkH84Dkf25qVlSRAL/5aU/R7InXk7jJYFD+cz7vau/4jKAAAAIA1keU19UdRAzUKpbHFotBso8UnQzurcoFWNq8YtjkV9x32sjHuatab+mSXvjjSV9VDZ1Ru+6h5q/Vf6tr4yUuAYIo9s9LGA/MQgOVl7k+Dsn6N9UCta8/yoDXPMBbYQoiUJ2sOQ0pCaPeYXH6WTbB9edgxRow8WFQjGW26t6cF5Q== dsa-key-20031024

key added to system, you can access it

Thanks, logging in now.

Ok, I see the issue - with multiple PHP versions installed, Virtualmin Nginx support is very inflexible when it comes to allowing you to select a different version. We will work on fixing this ... stay tuned.

so will you fix it or is it just that you will support it in future?

well the main thing which I would need is: I can have php 7 on all websites except for 1 so maybe it would solve something?

I will fix this, but it will take a couple of day's work at least.

Ok, a fix to support changing the PHP version for Nginx has been implemented, and will be included in the 2.3 release of the Nginx plugin.

Status: Active » Fixed

when will it be avaialbe for update?

Ok great thanks for support hope it will work

Guys, few days after one of the sites (fitradio.sk) stopped with Gateway error 502. 1. we did not change anything before. 2. php error log shows this: Can't exec "/usr/bin/php5-cgi": No such file or directory at /usr/bin/php-loop.pl line 24. 3. nginx error log does not catch anything.

I have added access key back so that you can check please.

nvm. I fixed this by switching from php-cgi to php-fpm execution.

how does it look like with the new update?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.