I'm running nginx 1.14.0 and php-fpm5.6 on Ubuntu 18.04. When I look at my PHP variables with info.php, the PATHINFO variable is empty. I wonder what could be wrong? Nginx then asks me to open/save the index.php it otherwise should be rendering as html after php-fpm/fastcgi executes the php. But I can't seem to configure this block (uncommented) to get php-fpm to work and send back html to nginx.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave 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
Comments
commented Aug 8, 2013
Sometimes it return an empty value on our production server. |
commented Aug 8, 2013
@lindowx ngx_lua simply exposes the Nginx core's standard $remote_addr variable to the Lua land: And the value of $remote_addr can only be empty when the request comes from a unix domain socket if you're using a recent release of ngx_openresty. To trace this further, you can use tools like systemtap and dtrace to probe the ngx_http_variable_remote_addr and ngx_event_accept C functions in the Nginx core. |
commented Aug 12, 2013
Here is my nginx.conf. index.php and my hosts I got the right answer from the first URL, but I got nothing when I tried the second. I've no idea about why. |
commented Aug 12, 2013
@lindowx please provide a minimal but still complete example that can reproduce the issue. In your current sample, I have no idea what your some.module and some_func are. Also, you should define a server {} block for your prod.myserver.com domain (I can only see the server {} block for test.myserver.com). |
commented Aug 22, 2013
There's no server {} block defined as prod.myserver.com. Only one server {} block was configured in my nginx.conf. |
commented Aug 22, 2013
@agentzh |
commented Aug 22, 2013
I've noticed one obvious mistake in your code sample above, that is, you define my_mem_var as a 'local' Lua variable in init_by_lua but you use it later in your set_by_lua, which will not work at all. I've tested the following complete example (derived from your code snippets) and I cannot get empty $remote_addr value even under load generated by ab: And the my_mem_var.lua file is defined as And I'm having the following line in my /etc/hosts: And accessing /t by either localhost or hello always gives the right output: |
commented Sep 8, 2013
@lindowx Any updates on this issue? |
commented Sep 10, 2013
Thx @agentzh, |
commented Nov 7, 2013
Consider it resolved. If you are still seeing this issue, feel free to reopen this. |
There are few major PHP versions out there such as PHP 5.6, PHP 7.0, PHP 7.1 and PHP 7.2. We should always try to use latest version of the software, sometimes we have to stick with an older version due to compatibility issues with the application we are running. If you’re in a such situation, this post will show you how to use multiple PHP versions with Virtualmin and Nginx server.
Why use multiple PHP versions with Virtualmin and Nginx
I was in a such situation recently. I wanted to have WordPress and CPVLab installed on the same VPS. WordPress is compatible with PHP 7.2 but CPVLab isn’t. Only version of PHP CPVLab supported was PHP 5.6. While I could have both WordPress and CPVLab installed with PHP 5.6, that isn’t optimal solution. So I decided to install PHP 7.2 for WordPress and PHP 5.6 for CPVLab.
While my reason to use multiple PHP versions with Virtualmin and Nginx only involves PHP 5.6 and PHP 7.2, I’ll list instructions for all four major PHP versions mentioned earlier. These are the PHP versions with ongoing support at the moment of writing.
And before we begin, I’m going to assume you have built your Ubuntu 16.04 server with Virtualmin and Nginx and have created at least one virtual server to host a website.
Add Ondřej Surý Repo to the server
Ubuntu 16.04 doesn’t offer newer versions of PHP than PHP v7.0.30 yet. We can get around this by adding ondrej/php PPA to the server. No matter which PHP version you’re planning to install, you should start by adding ondrej/php PPA to be able to use multiple PHP versions with Virtualmin and Nginx.Update apt cache
Server is now ready to have multiple versions of PHP running at the same time. Let’s start with PHP 5.6. Note that Virtualmin, by default use latest version of PHP available on the server for new virtual servers. This can be changed within the virtual server settings itself after creation or you can specify a default PHP version for new servers from Virtualmin settings. More on that later on this tutorial.
Install PHP 5.6 and PHP 7.0 with Virtualmin and Nginx
We already have PHP 7.0 running on the server. Let’s install PHP 5.6. Following command will install PHP 5.6 and all essential PHP 5.6 modules.
Install PHP 7.1 and PHP 7.0 with Virtualmin and Nginx
If the version of PHP you want is PHP 7.1, following command should take care of it.
Install PHP 7.2 and PHP 7.0 with Virtualmin and Nginx
And if you want latest version (PHP 7.2) on your server, following command will do the magic.
You can run one or more of above commands and have one or more extra PHP versions running on your server. If you run all three commands above, you’ll have all four version of PHP available to you on the server.
Configure Virtualmin to use a Specific PHP Version
Virtualmin will use latest available version of PHP for new virtual servers. Old virtual servers will not be affected by above commands. If you need a different version of PHP for existing virtual server, you can go to Virtualmin > Domain Name > Server Configuration > PHP Version and select the PHP version you want from the list.
And if you want to change default PHP version for new virtual servers to other than the latest version available on the server, you can change it from Virtualmin > System Settings > Server Templates > Default Settings > PHP Options. A drop down list of available PHP versions will be shown to you.
Select the version you want and click save. Selected PHP version will be used for all newly created servers. Option to change PHP version from virtual server settings will also be available to all newly created servers.
Set Default PHP Version for Command Line
When you have multiple php versions on your server, system will use latest version to process PHP commands. Although you can change this on Virtualmin as shown above, it doesn’t change default PHP version for command line. phpinfo page on your browser might say PHP 5.6 but PHP -v command on Putty might say PHP 7.2. This can lead to conflicts in some cases. Especially if your application need to run cronjobs. Solution will be to change default PHP version for command line to match what your application is running.
This command will display PHP versions available to you with paths,
Following command should change default php version to PHP 7.1.
Change the path to PHP as your needs.