U
U
Ufolob2019-11-18 12:23:42
Nginx
Ufolob, 2019-11-18 12:23:42

How to properly connect CMS to nginx?

Hello. Ran a nuxtjs app on a rented vps.
The nginx configuration now looks like this:

server {
    listen      55.55.55.555:443 ssl;
    server_name test.ru www.test.ru;
    ssl_certificate      /home/admin/conf/web/ssl.test.ru.pem;
    ssl_certificate_key  /home/admin/conf/web/ssl.test.ru.key;
    error_log  /var/log/apache2/domains/test.ru.error.log error;

    location / {
        proxy_pass      http://localhost:3000;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
            root           /home/admin/web/test.ru/public_html;
            access_log     /var/log/apache2/domains/test.ru.log combined;
            access_log     /var/log/apache2/domains/test.ru.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   /home/admin/web/test.ru/document_errors/;
    }
    location /news/ {
       root           /home/admin/web/test.ru/public_html/data/;
       index index.php index.html index.htm;
    }
    location @fallback {
        proxy_pass      http://localhost:3000;
    }
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
    }
    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    disable_symlinks if_not_owner from=/home/admin/web/test.ru/public_html;

    include /home/admin/conf/web/snginx.test.ru.conf*;
}

The public_html folder contains the application files. I also created a "data" folder there in the public_html folder, where the php-CMS files will be located, which will interact with the application and give the necessary information.
Launched php-fmp . Please tell me this:
1. Can the php-framework files be moved outside the public_html folder?
2. How to correctly set the settings of the running php-fmp in nginx so that php works as it should?
3. What needs to be set in the settings so that php-framework starts and works through php-fmp?
4. What is the correct way to specify the location in the nginx configuration, at which I need the CMS to work on a certain url, and not the nuxt application? For example, the link /news/ should give content to php-framework. All this is necessary because the site will be gradually transferred to the new application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2019-11-18
@Ufolob

1) First, define 2 locations - @php {...}and @nuxt {...}(for example)
2) Next, decide what the document_root of the application should be and write it down (you can specify it for each location)
3) Next, specify through try_files for the location for example / api / look at nuxt and for / look at php
profit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question