Форум программистов, компьютерный форум, киберфорум
IRIP
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск  

Настройка php-fpm + nginx доменов на vestacp

Запись от IRIP размещена 12.03.2020 в 09:40
Показов 10175 Комментарии 4

В продолжение темы, и чтобы закрыть этот вопрос для себя (оставив заметку)...

В прошлом посте я приобрел дешевый vps, установил ubuntu 18, и настроил работу связки php7.4-fpm + nginx

В этом посте выложу листинги для настройки конфигов.
они оптимизированы для работы wordpress и instantcms 2


1. В VESTACP создаю пользователя, создаю домен пользователю.
1.1 Обязательно прописываю SSL и только потом приступаю к настройке.

2. Перехожу
/etc/php/php7.4/fpm/pool.d/

2.1 Выбираю .conf созданного домена, и дописываю в него

оригинал:
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[test.site]
listen = 127.0.0.1:9003
listen.allowed_clients = 127.0.0.1
 
user = profit
group = profit
 
pm = ondemand
pm.max_children = 4
pm.max_requests = 4000
pm.process_idle_timeout = 10s
pm.status_path = /status
 
php_admin_value[upload_tmp_dir] = /home/profit/tmp
php_admin_value[session.save_path] = /home/profit/tmp
 
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /home/profit/tmp
env[TMPDIR] = /home/profit/tmp
env[TEMP] = /home/profit/tmp
меняю на:
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[test.site]
;listen = 127.0.0.1:9003
listen.allowed_clients = 127.0.0.1
 
listen = /var/run/php/test-site.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
 
user = profit
group = profit
 
pm = ondemand
pm.max_children = 4
pm.max_requests = 4000
pm.process_idle_timeout = 10s
pm.status_path = /status
 
php_admin_value[upload_tmp_dir] = /home/profit/tmp
php_admin_value[session.save_path] = /home/profit/tmp
 
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /home/profit/tmp
env[TMPDIR] = /home/profit/tmp
env[TEMP] = /home/profit/tmp

3. Перехожу по
/home/USERNAME/conf/web/test.site.nginx.conf

оригинал:
Оригинальный test.site.nginx.conf

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
server {
    listen      192.168.0.1:80;
    server_name test.site www.test.site;
    root        /home/profit/web/test.site/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/test.site.log combined;
    access_log  /var/log/nginx/domains/test.site.bytes bytes;
    error_log   /var/log/nginx/domains/test.site.error.log error;
 
    location / {
 
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
 
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
 
            fastcgi_pass    127.0.0.1:9003;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }
 
    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;
 
    location /error/ {
        alias   /home/profit/web/test.site/document_errors/;
    }
 
    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }
 
    location /vstats/ {
        alias   /home/profit/web/test.site/stats/;
        include /home/profit/conf/web/test.site.auth*;
    }
 
    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
 
    include     /home/profit/conf/web/nginx.test.site.conf*;
}


меняю на:
С изменениями test.site.nginx.conf

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
server {
        listen      192.168.0.1:80;     
        server_name www.test.site;
        return 301 https://test.site$request_uri;
}
 
server {
    listen      192.168.0.1:80;
    server_name test.site;
    root        /home/profit/web/test.site/public_html;
    return 301 https://test.site$request_uri;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/test.site.log combined;
    access_log  /var/log/nginx/domains/test.site.bytes bytes;
    error_log   /var/log/nginx/domains/test.site.error.log error;
 
    location / {
 
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
 
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
 
            fastcgi_pass unix:/var/run/php/test-site.sock;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }
 
    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;
 
    location /error/ {
        alias   /home/profit/web/test.site/document_errors/;
    }
 
    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }
 
    location /vstats/ {
        alias   /home/profit/web/test.site/stats/;
        include /home/profit/conf/web/test.site.auth*;
    }
 
    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
 
    include     /home/profit/conf/web/nginx.test.site.conf*;
}


* само собой, ip адрес у вас будет свой, как и пути


Code
1
service nginx restart && service php7.4-fpm restart

Далее тоже самое проделываю с ssl.conf

оригинал test.site.nginx.ssl.conf
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
server {
    listen      192.168.0.1:443 ssl;
    server_name test.site www.test.site;
    root        /home/profit/web/test.site/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/test.site.log combined;
    access_log  /var/log/nginx/domains/test.site.bytes bytes;
    error_log   /var/log/nginx/domains/test.site.error.log error;
 
    ssl_certificate      /home/profit/conf/web/ssl.test.site.pem;
    ssl_certificate_key  /home/profit/conf/web/ssl.test.site.key;
 
    location / {
 
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
 
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
 
            fastcgi_pass    127.0.0.1:9003;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }
 
    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;
 
    location /error/ {
        alias   /home/profit/web/test.site/document_errors/;
    }
 
    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }
 
    location /vstats/ {
        alias   /home/profit/web/test.site/stats/;
        include /home/profit/conf/web/test.site.auth*;
    }
 
    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
 
    include     /home/profit/conf/web/snginx.test.site.conf*;
}



с изменениями:
Кликните здесь для просмотра всего текста
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
server {
        listen      192.168.0.1:443 ssl;     
        server_name www.test.site;
        return 301 https://test.site$request_uri;
 
    ssl_certificate      /home/profit/conf/web/ssl.test.site.pem;
    ssl_certificate_key  /home/profit/conf/web/ssl.test.site.key;
 
}
 
server {
    listen      192.168.0.1:443 ssl;
    server_name test.site;
    root        /home/profit/web/test.site/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/test.site.log combined;
    access_log  /var/log/nginx/domains/test.site.bytes bytes;
    error_log   /var/log/nginx/domains/test.site.error.log error;
 
    ssl_certificate      /home/profit/conf/web/ssl.test.site.pem;
    ssl_certificate_key  /home/profit/conf/web/ssl.test.site.key;
 
    add_header X-Cache $upstream_cache_status;
    set $skip_cache 0;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;    
    fastcgi_cache_use_stale error timeout invalid_header http_500;
 
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
    }
    if ($query_string != "") {
        set $skip_cache 1;
    }
    # Don't cache uris containing the following segments
    if ($request_uri ~* "/admin/|index.php|sitemap(_index)?.xml|/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*|/ideas.*|/wishlist.*") {
        set $skip_cache 1;
    }
    # Don't use the cache for cookied logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_cart_hash|woocommerce_items_in_cart") {
        set $skip_cache 1;
    }
 
    location / {
 
        location ~ [^/]\.php(/|$) {
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
            
            fastcgi_pass   unix:/var/run/php/test-site.sock;
            fastcgi_index   index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            include         /etc/nginx/fastcgi_params;
 
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_cache_bypass $skip_cache;
            fastcgi_no_cache $skip_cache;
            fastcgi_cache_valid 60m;
            fastcgi_read_timeout 6000;
            fastcgi_connect_timeout 6000;
            fastcgi_send_timeout 6000;
            proxy_read_timeout 6000;
            proxy_connect_timeout 6000;
            proxy_send_timeout 6000;
            send_timeout 6000;
 
        }
 
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
 
        location ~ ^/cache {
            deny all;
            location ~ \.(js|css|xml)$ {
                allow all;
            }
        }
 
        location ~ ^/system/ {
          deny all;
        }
 
        location ~ ^/filters/ {
          deny all;
        }
 
        location ~ ^/languages/ {
          deny all;
        }
 
        location ~ ^/cache/ {
          deny all;
        }
 
        location ~* /static/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
          deny all;
        }
 
        location ~* /templates/.*\.(tpl|txt|php|php3|php4|php5|php6|phps|phtml)$ {
          deny all;
        }
 
        location ~* /upload/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
          deny all;
        }
 
        location ~* /wysiwyg/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
          deny all;
        }
 
        location /credits.txt {
          deny all;
        }
 
        location /readme.txt {
          deny all;
        }
 
        location ~ ^/license.(.*).txt$ {
          deny all;
        }
 
        location ~ /\. {
          deny all;
        }
 
        location /sitemap {
          rewrite ^/sitemap(.*).xml$ /cache/static/sitemaps/sitemap$1.xml;
        }
 
    }
 
    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;
 
    location /error/ {
        alias   /home/profit/web/test.site/document_errors/;
    }
 
    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }
 
    location /vstats/ {
        alias   /home/profit/web/test.site/stats/;
        include /home/profit/conf/web/test.site.auth*;
    }
 
    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
 
    include     /home/profit/conf/web/snginx.test.site.conf*;
}


это действие нужно для того, чтобы перенаправить весь трафик с www на без www
и на https

работает для wordpress и instantcms 2


Code
1
service nginx restart && service php7.4-fpm restart
Размещено в Без категории
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
Всего комментариев 4
Комментарии
  1. Старый комментарий
    Аватар для IRIP
    1234 тест
    Запись от IRIP размещена 12.03.2020 в 11:41 IRIP вне форума
  2. Старый комментарий
    Аватар для IRIP
    если ошибка в centos7 php-fpm cannot get uid for user 'www-data': Success (0)

    то нужно

    1. Откройте конфиг
    /usr/local/vesta/data/templates/web/php-fpm/socket.tpl

    2. Найдите
    listen.owner = www-data
    listen.group = www-data

    3. Замените на
    listen.owner = %user%
    listen.group = nginx

    4. Сделайте ребилд WEB и попробуйте посмотреть еще раз, изменилась ли ситуация.
    Запись от IRIP размещена 25.04.2020 в 08:10 IRIP вне форума
  3. Старый комментарий
    Аватар для IRIP
    если в centos 7
    centos7 php-fpm .sock failed (13: Permission denied)
    то нужно

    listen.mode = 0660
    listen.owner = nginx
    listen.group = nginx
    Запись от IRIP размещена 25.04.2020 в 09:22 IRIP вне форума
  4. Старый комментарий
    Аватар для IRIP
    ioncube loader php7.4 https://www.ioncube.com/loaders.php

    php -i | grep extension_dir

    zend_extension = /usr/local/ioncube/ioncube_loader_lin_7.4_10.4.0_beta2.so
    zend_extension_ts = /usr/local/ioncube/ioncube_loader_lin_7.4_10.4.0_beta2_ts.s o
    Запись от IRIP размещена 21.05.2020 в 01:24 IRIP вне форума
 
Новые блоги и статьи
Скрипты Tampermonkey для CyberForum, ChatGPT, Claude и пр.
Jin X 06.09.2026
Скрипты Tampermonkey для CyberForum, ChatGPT, Claude и пр. Работая с форумом и нейросетями в браузере часто хочется что-то подкорректировать или добавить какого-то функционала. Ниже прикреплён. . .
Программа опроса у.з. расходомера SLS-720F
Argus19 02.09.2026
Программа опроса у. з. расходомера SLS-720F Программа опрашивает один раз в минуту три ультразвуковых расходомера SLS-720F через интерфейс RS-485 по протоколу Modbus RTU. Опрашиваются регистры. . .
Hyper-V: Компьютер должен поддерживать доверенный платформенный модуль 2.0.
Maks 31.08.2026
При установке Windows 11 на виртуальную машину Hyper-V 2-го поколения вылезла такая ошибка: Решение: в параметрах виртуальной машины, в разделе "Безопасность" (Security) активировать флаг. . .
Архитектура биовида Стива в Майнкрафте: Зачем бонобо кубический каннибализм
anaschu 30.08.2026
Кубический Вагинокапитализм в Minecraft: Математический инвариант ОДУ и рок Стивов-бонобо Главная задача разработанной «Модели Всего» — наглядно продемонстрировать наличие системной «судьбы». . .
Оттачиваю умение писать js программы.
russiannick 30.08.2026
Проектом выходного дня стало написание Книги шифров Виженера. Итогом стала версия 200, синий туман. Синий туман назван так, потому что замораживает текст под собой. Нажатие синих кнопок управляют. . .
мат медиц модель 30. презентация проекта
anaschu 27.08.2026
хоп хоп хоп хидахоп, а я кладую))
Как у меня протекала болезнь
zorxor 27.08.2026
Здравствуйте, друзья! Эта запись блога предназначена именно для вас - для моих дорогих друзей, которые знали меня лично. Чтобы ответить на вопрос - а что же со мной произошло на самом деле? Я учился. . .
Нашел вот забавное видео о измерениях. Лучшее что я видел на эту тему
kumehtar 26.08.2026
ILETXiw9bMQ Основная суть и тезисы по измерениям: 0D (Нулевое измерение): точка, не имеющая длины, ширины, высоты или объема. Объект не может перемещаться в 0D. 1D (Первое измерение):. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru