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

Concrete example from standard nginx.conf? #147

Open
roukmoute opened this issue Dec 18, 2022 · 6 comments
Open

Concrete example from standard nginx.conf? #147

roukmoute opened this issue Dec 18, 2022 · 6 comments

Comments

@roukmoute
Copy link

roukmoute commented Dec 18, 2022

Is it possible to convert an example from standard nginx.conf like this?

server {
    server_name domain.tld www.domain.tld;
    root /var/www/project/public;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

    location ~ \.php$ {
        return 404;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}
@roukmoute roukmoute changed the title Concrete example from standard ngnix.conf? Concrete example from standard nginx.conf? Dec 18, 2022
@joanhey
Copy link
Contributor

joanhey commented Dec 18, 2022

Looks like you are using a Front Controller (index.php).

Here are some examples:
https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/PHP/php-ngx/deploy

There a lot of ways to do it.

I'll create an example for a Front Controller (when I have free time)

@roukmoute
Copy link
Author

It is a Front Controller that is used to take any "route" and redirect it to index.php, and currently I don't know how to do it.

For example, how concatenate index.php with its optionnal GET arguments?

I know the repository you sent me, but this is perfect example of non applicable because all routes is hard coded.

@rryqszq4
Copy link
Owner

rryqszq4 commented Dec 23, 2022

@roukmoute It's route anything.

server {
    listen 80;
    server_name localhost;
    access_log logs/cp-stats-web.access.log ;
    root /home/mbxps/mbxps/develop/quanzhao/production/cp-stats-web/public;
    index index.php index.html index.htm;

    location = /favicon.ico {

    }

    location ~ ^/(echarts|antv|jquery|jqueryui|d3|nvd3|semantic|bootstrap|static)/ {
        }

    location ~ /clf {
        proxy_pass http://10.16.172.70:8888;
    }

    location ~ ^(.*)$ {
        content_by_php '
                global $START_TIME;
                $START_TIME = microtime(true);

                if (!defined("APPLICATION_PATH")){
                        define("APPLICATION_PATH", "/home/mbxps/mbxps/develop/quanzhao/production/cp-stats-web");
                }

                require_once(APPLICATION_PATH."/vendor/autoload.php");

                require_once(APPLICATION_PATH."/framework/Dispatch.php");

                $application = new Dispatch();
                $application->run();
        ';
    }
}

@joanhey
Copy link
Contributor

joanhey commented Dec 23, 2022

Also I'm finishing and adapter for Ngx-php to use any php app, without touch 1 line of code.

I made it first for Workerman https://github.com/joanhey/AdapterMan

@joanhey
Copy link
Contributor

joanhey commented Dec 23, 2022

@rryqszq4 My email, I want to contact you.
[email protected]

@rryqszq4
Copy link
Owner

@rryqszq4 My email, I want to contact you. [email protected]

@joanhey My email is [email protected]

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