web: nginx + php 环境配置(ubuntu)
0、重要提示:
1、守护线程nginx和php8.1-fpm,修改配置以后需要重启(sudo systemctl restart nginx; sudo systemctl restart php8.1-fpm)
2、守护线程nginx和php8.1-fpm需要设置开机启动(sudo systemctl enable);
3、php8.1-fpm的配置文件(/etc/php/8.1/fpm/pool.d/www.conf ;大约36行)www.conf中的 “listen = /run/php/php8.1-fpm.sock”关联到“/etc/nginx/sites-available/default”文件的“location ~ \.php$ { fastcgi_pass unix:/run/php/php8.1-fpm.sock}”.
一、php相关软件的安装
1、sudo apt install php php-fpm php-mysqlnd
二、php相关软件的配置
1、php-fpm配置(/etc/php/8.1/fpm/pool.d/www.conf)
1 [wit@on:pool.d]$ cat /etc/php/8.1/fpm/pool.d/www.conf
2 ; Start a new pool named 'www'.
3 ; the variable $pool can be used in any directive and will be replaced by the
4 ; pool name ('www' here)
5 [www]
6
7 ; Per pool prefix
8 ; It only applies on the following directives:
9 ; - 'access.log'
10 ; - 'slowlog'
11 ; - 'listen' (unixsocket)
12 ; - 'chroot'
13 ; - 'chdir'
14 ; - 'php_values'
15 ; - 'php_admin_values'
16 ; When not set, the global prefix (or /usr) applies instead.
17 ; Note: This directive can also be relative to the global prefix.
18 ; Default Value: none
19 ;prefix = /path/to/pools/$pool
20
21 ; Unix user/group of processes
22 ; Note: The user is mandatory. If the group is not set, the default user's group
23 ; will be used.
24 user = www-data
25 group = www-data
26
27 ; The address on which to accept FastCGI requests.
28 ; Valid syntaxes are:
29 ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
30 ; a specific port;
31 ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
32 ; a specific port;
33 ; 'port' - to listen on a TCP socket to all addresses
34 ; (IPv6 and IPv4-mapped) on a specific port;
35 ; '/path/to/unix/socket' - to listen on a unix socket.
36 ; Note: This value is mandatory.
37 ; listen = /run/php/php8.1-fpm.sock
38
39
40 ; by david at 2023-10-24
41 ; !important for config of nginx:(/etc/nginx/sites-available/default)
42 ; server {
43 ; location ~\.php$ {
44 ; fastcgi_pass unix:/run/php/php8.1-fpm.sock;
45 ; }
46 ; }
47 listen = /run/php/php8.1-fpm.sock
48
49
50
51 ; Set listen(2) backlog.
52 ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
53 ;listen.backlog = 511
54
55
56
57 ; Set permissions for unix socket, if one is used. In Linux, read/write
58 ; permissions must be set in order to allow connections from a web server. Many
59 ; BSD-derived systems allow connections regardless of permissions. The owner
60 ; and group can be specified either by name or by their numeric IDs.
61 ; Default Values: user and group are set as the running user
62 ; mode is set to 0660
63
64 ; listen.owner = www-data
65 ; listen.group = www-data
66 listen.owner = www-data
67 listen.group = www-data
68
69 ; listen.mode = 0660
70 listen.mode = 0660
71
72
73 ; When POSIX Access Control Lists are supported you can set them using
74 ; these options, value is a comma separated list of user/group names.
75 ; When set, listen.owner and listen.group are ignored
76 ;listen.acl_users =
77 ;listen.acl_groups =
78
79 ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
80 ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
81 ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
82 ; must be separated by a comma. If this value is left blank, connections will be
83 ; accepted from any ip address.
84 ; Default Value: any
85 ;listen.allowed_clients = 127.0.0.1
86
87 ; Specify the nice(2) priority to apply to the pool processes (only if set)
88 ; The value can vary from -19 (highest priority) to 20 (lower priority)
89 ; Note: - It will only work if the FPM master process is launched as root
90 ; - The pool processes will inherit the master process priority
91 ; unless it specified otherwise
92 ; Default Value: no set
93 ; process.priority = -19
94
95 ; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
96 ; or group is different than the master process user. It allows to create process
97 ; core dump and ptrace the process for the pool user.
98 ; Default Value: no
99 ; process.dumpable = yes
100
101 ; Choose how the process manager will control the number of child processes.
102 ; Possible Values:
103 ; static - a fixed number (pm.max_children) of child processes;
104 ; dynamic - the number of child processes are set dynamically based on the
105 ; following directives. With this process management, there will be
106 ; always at least 1 children.
107 ; pm.max_children - the maximum number of children that can
108 ; be alive at the same time.
109 ; pm.start_servers - the number of children created on startup.
110 ; pm.min_spare_servers - the minimum number of children in 'idle'
111 ; state (waiting to process). If the number
112 ; of 'idle' processes is less than this
113 ; number then some children will be created.
114 ; pm.max_spare_servers - the maximum number of children in 'idle'
115 ; state (waiting to process). If the number
116 ; of 'idle' processes is greater than this
117 ; number then some children will be killed.
118 ; pm.max_spawn_rate - the maximum number of rate to spawn child
119 ; processes at once.
120 ; ondemand - no children are created at startup. Children will be forked when
121 ; new requests will connect. The following parameter are used:
122 ; pm.max_children - the maximum number of children that
123 ; can be alive at the same time.
124 ; pm.process_idle_timeout - The number of seconds after which
125 ; an idle process will be killed.
126 ; Note: This value is mandatory.
127 pm = dynamic
128
129 ; The number of child processes to be created when pm is set to 'static' and the
130 ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
131 ; This value sets the limit on the number of simultaneous requests that will be
132 ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
133 ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
134 ; CGI. The below defaults are based on a server without much resources. Don't
135 ; forget to tweak pm.* to fit your needs.
136 ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
137 ; Note: This value is mandatory.
138 pm.max_children = 5
139
140 ; The number of child processes created on startup.
141 ; Note: Used only when pm is set to 'dynamic'
142 ; Default Value: (min_spare_servers + max_spare_servers) / 2
143 pm.start_servers = 2
144
145 ; The desired minimum number of idle server processes.
146 ; Note: Used only when pm is set to 'dynamic'
147 ; Note: Mandatory when pm is set to 'dynamic'
148 pm.min_spare_servers = 1
149
150 ; The desired maximum number of idle server processes.
151 ; Note: Used only when pm is set to 'dynamic'
152 ; Note: Mandatory when pm is set to 'dynamic'
153 pm.max_spare_servers = 3
154
155 ; The number of rate to spawn child processes at once.
156 ; Note: Used only when pm is set to 'dynamic'
157 ; Note: Mandatory when pm is set to 'dynamic'
158 ; Default Value: 32
159 ;pm.max_spawn_rate = 32
160
161 ; The number of seconds after which an idle process will be killed.
162 ; Note: Used only when pm is set to 'ondemand'
163 ; Default Value: 10s
164 ;pm.process_idle_timeout = 10s;
165
166 ; The number of requests each child process should execute before respawning.
167 ; This can be useful to work around memory leaks in 3rd party libraries. For
168 ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
169 ; Default Value: 0
170 ;pm.max_requests = 500
171
172 ; The URI to view the FPM status page. If this value is not set, no URI will be
173 ; recognized as a status page. It shows the following information:
174 ; pool - the name of the pool;
175 ; process manager - static, dynamic or ondemand;
176 ; start time - the date and time FPM has started;
177 ; start since - number of seconds since FPM has started;
178 ; accepted conn - the number of request accepted by the pool;
179 ; listen queue - the number of request in the queue of pending
180 ; connections (see backlog in listen(2));
181 ; max listen queue - the maximum number of requests in the queue
182 ; of pending connections since FPM has started;
183 ; listen queue len - the size of the socket queue of pending connections;
184 ; idle processes - the number of idle processes;
185 ; active processes - the number of active processes;
186 ; total processes - the number of idle + active processes;
187 ; max active processes - the maximum number of active processes since FPM
188 ; has started;
189 ; max children reached - number of times, the process limit has been reached,
190 ; when pm tries to start more children (works only for
191 ; pm 'dynamic' and 'ondemand');
192 ; Value are updated in real time.
193 ; Example output:
194 ; pool: www
195 ; process manager: static
196 ; start time: 01/Jul/2011:17:53:49 +0200
197 ; start since: 62636
198 ; accepted conn: 190460
199 ; listen queue: 0
200 ; max listen queue: 1
201 ; listen queue len: 42
202 ; idle processes: 4
203 ; active processes: 11
204 ; total processes: 15
205 ; max active processes: 12
206 ; max children reached: 0
207 ;
208 ; By default the status page output is formatted as text/plain. Passing either
209 ; 'html', 'xml' or 'json' in the query string will return the corresponding
210 ; output syntax. Example:
211 ; http://www.foo.bar/status
212 ; http://www.foo.bar/status?json
213 ; http://www.foo.bar/status?html
214 ; http://www.foo.bar/status?xml
215 ;
216 ; By default the status page only outputs short status. Passing 'full' in the
217 ; query string will also return status for each pool process.
218 ; Example:
219 ; http://www.foo.bar/status?full
220 ; http://www.foo.bar/status?json&full
221 ; http://www.foo.bar/status?html&full
222 ; http://www.foo.bar/status?xml&full
223 ; The Full status returns for each process:
224 ; pid - the PID of the process;
225 ; state - the state of the process (Idle, Running, ...);
226 ; start time - the date and time the process has started;
227 ; start since - the number of seconds since the process has started;
228 ; requests - the number of requests the process has served;
229 ; request duration - the duration in µs of the requests;
230 ; request method - the request method (GET, POST, ...);
231 ; request URI - the request URI with the query string;
232 ; content length - the content length of the request (only with POST);
233 ; user - the user (PHP_AUTH_USER) (or '-' if not set);
234 ; script - the main script called (or '-' if not set);
235 ; last request cpu - the %cpu the last request consumed
236 ; it's always 0 if the process is not in Idle state
237 ; because CPU calculation is done when the request
238 ; processing has terminated;
239 ; last request memory - the max amount of memory the last request consumed
240 ; it's always 0 if the process is not in Idle state
241 ; because memory calculation is done when the request
242 ; processing has terminated;
243 ; If the process is in Idle state, then informations are related to the
244 ; last request the process has served. Otherwise informations are related to
245 ; the current request being served.
246 ; Example output:
247 ; ************************
248 ; pid: 31330
249 ; state: Running
250 ; start time: 01/Jul/2011:17:53:49 +0200
251 ; start since: 63087
252 ; requests: 12808
253 ; request duration: 1250261
254 ; request method: GET
255 ; request URI: /test_mem.php?N=10000
256 ; content length: 0
257 ; user: -
258 ; script: /home/fat/web/docs/php/test_mem.php
259 ; last request cpu: 0.00
260 ; last request memory: 0
261 ;
262 ; Note: There is a real-time FPM status monitoring sample web page available
263 ; It's available in: /usr/share/php/8.1/fpm/status.html
264 ;
265 ; Note: The value must start with a leading slash (/). The value can be
266 ; anything, but it may not be a good idea to use the .php extension or it
267 ; may conflict with a real PHP file.
268 ; Default Value: not set
269 ;pm.status_path = /status
270
271 ; The address on which to accept FastCGI status request. This creates a new
272 ; invisible pool that can handle requests independently. This is useful
273 ; if the main pool is busy with long running requests because it is still possible
274 ; to get the status before finishing the long running requests.
275 ;
276 ; Valid syntaxes are:
277 ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
278 ; a specific port;
279 ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
280 ; a specific port;
281 ; 'port' - to listen on a TCP socket to all addresses
282 ; (IPv6 and IPv4-mapped) on a specific port;
283 ; '/path/to/unix/socket' - to listen on a unix socket.
284 ; Default Value: value of the listen option
285 ;pm.status_listen = 127.0.0.1:9001
286
287 ; The ping URI to call the monitoring page of FPM. If this value is not set, no
288 ; URI will be recognized as a ping page. This could be used to test from outside
289 ; that FPM is alive and responding, or to
290 ; - create a graph of FPM availability (rrd or such);
291 ; - remove a server from a group if it is not responding (load balancing);
292 ; - trigger alerts for the operating team (24/7).
293 ; Note: The value must start with a leading slash (/). The value can be
294 ; anything, but it may not be a good idea to use the .php extension or it
295 ; may conflict with a real PHP file.
296 ; Default Value: not set
297 ;ping.path = /ping
298
299 ; This directive may be used to customize the response of a ping request. The
300 ; response is formatted as text/plain with a 200 response code.
301 ; Default Value: pong
302 ;ping.response = pong
303
304 ; The access log file
305 ; Default: not set
306 ;access.log = log/$pool.access.log
307
308 ; The access log format.
309 ; The following syntax is allowed
310 ; %%: the '%' character
311 ; %C: %CPU used by the request
312 ; it can accept the following format:
313 ; - %{user}C for user CPU only
314 ; - %{system}C for system CPU only
315 ; - %{total}C for user + system CPU (default)
316 ; %d: time taken to serve the request
317 ; it can accept the following format:
318 ; - %{seconds}d (default)
319 ; - %{milliseconds}d
320 ; - %{milli}d
321 ; - %{microseconds}d
322 ; - %{micro}d
323 ; %e: an environment variable (same as $_ENV or $_SERVER)
324 ; it must be associated with embraces to specify the name of the env
325 ; variable. Some examples:
326 ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
327 ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
328 ; %f: script filename
329 ; %l: content-length of the request (for POST request only)
330 ; %m: request method
331 ; %M: peak of memory allocated by PHP
332 ; it can accept the following format:
333 ; - %{bytes}M (default)
334 ; - %{kilobytes}M
335 ; - %{kilo}M
336 ; - %{megabytes}M
337 ; - %{mega}M
338 ; %n: pool name
339 ; %o: output header
340 ; it must be associated with embraces to specify the name of the header:
341 ; - %{Content-Type}o
342 ; - %{X-Powered-By}o
343 ; - %{Transfert-Encoding}o
344 ; - ....
345 ; %p: PID of the child that serviced the request
346 ; %P: PID of the parent of the child that serviced the request
347 ; %q: the query string
348 ; %Q: the '?' character if query string exists
349 ; %r: the request URI (without the query string, see %q and %Q)
350 ; %R: remote IP address
351 ; %s: status (response code)
352 ; %t: server time the request was received
353 ; it can accept a strftime(3) format:
354 ; %d/%b/%Y:%H:%M:%S %z (default)
355 ; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
356 ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
357 ; %T: time the log has been written (the request has finished)
358 ; it can accept a strftime(3) format:
359 ; %d/%b/%Y:%H:%M:%S %z (default)
360 ; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
361 ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
362 ; %u: remote user
363 ;
364 ; Default: "%R - %u %t \"%m %r\" %s"
365 ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
366
367 ; The log file for slow requests
368 ; Default Value: not set
369 ; Note: slowlog is mandatory if request_slowlog_timeout is set
370 ;slowlog = log/$pool.log.slow
371
372 ; The timeout for serving a single request after which a PHP backtrace will be
373 ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
374 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
375 ; Default Value: 0
376 ;request_slowlog_timeout = 0
377
378 ; Depth of slow log stack trace.
379 ; Default Value: 20
380 ;request_slowlog_trace_depth = 20
381
382 ; The timeout for serving a single request after which the worker process will
383 ; be killed. This option should be used when the 'max_execution_time' ini option
384 ; does not stop script execution for some reason. A value of '0' means 'off'.
385 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
386 ; Default Value: 0
387 ;request_terminate_timeout = 0
388
389 ; The timeout set by 'request_terminate_timeout' ini option is not engaged after
390 ; application calls 'fastcgi_finish_request' or when application has finished and
391 ; shutdown functions are being called (registered via register_shutdown_function).
392 ; This option will enable timeout limit to be applied unconditionally
393 ; even in such cases.
394 ; Default Value: no
395 ;request_terminate_timeout_track_finished = no
396
397 ; Set open file descriptor rlimit.
398 ; Default Value: system defined value
399 ;rlimit_files = 1024
400
401 ; Set max core size rlimit.
402 ; Possible Values: 'unlimited' or an integer greater or equal to 0
403 ; Default Value: system defined value
404 ;rlimit_core = 0
405
406 ; Chroot to this directory at the start. This value must be defined as an
407 ; absolute path. When this value is not set, chroot is not used.
408 ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
409 ; of its subdirectories. If the pool prefix is not set, the global prefix
410 ; will be used instead.
411 ; Note: chrooting is a great security feature and should be used whenever
412 ; possible. However, all PHP paths will be relative to the chroot
413 ; (error_log, sessions.save_path, ...).
414 ; Default Value: not set
415 ;chroot =
416
417 ; Chdir to this directory at the start.
418 ; Note: relative path can be used.
419 ; Default Value: current directory or / when chroot
420 ;chdir = /var/www
421
422 ; Redirect worker stdout and stderr into main error log. If not set, stdout and
423 ; stderr will be redirected to /dev/null according to FastCGI specs.
424 ; Note: on highloaded environment, this can cause some delay in the page
425 ; process time (several ms).
426 ; Default Value: no
427 ;catch_workers_output = yes
428
429 ; Decorate worker output with prefix and suffix containing information about
430 ; the child that writes to the log and if stdout or stderr is used as well as
431 ; log level and time. This options is used only if catch_workers_output is yes.
432 ; Settings to "no" will output data as written to the stdout or stderr.
433 ; Default value: yes
434 ;decorate_workers_output = no
435
436 ; Clear environment in FPM workers
437 ; Prevents arbitrary environment variables from reaching FPM worker processes
438 ; by clearing the environment in workers before env vars specified in this
439 ; pool configuration are added.
440 ; Setting to "no" will make all environment variables available to PHP code
441 ; via getenv(), $_ENV and $_SERVER.
442 ; Default Value: yes
443 ;clear_env = no
444
445 ; Limits the extensions of the main script FPM will allow to parse. This can
446 ; prevent configuration mistakes on the web server side. You should only limit
447 ; FPM to .php extensions to prevent malicious users to use other extensions to
448 ; execute php code.
449 ; Note: set an empty value to allow all extensions.
450 ; Default Value: .php
451 ;security.limit_extensions = .php .php3 .php4 .php5 .php7
452
453 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
454 ; the current environment.
455 ; Default Value: clean env
456 ;env[HOSTNAME] = $HOSTNAME
457 ;env[PATH] = /usr/local/bin:/usr/bin:/bin
458 ;env[TMP] = /tmp
459 ;env[TMPDIR] = /tmp
460 ;env[TEMP] = /tmp
461
462 ; Additional php.ini defines, specific to this pool of workers. These settings
463 ; overwrite the values previously defined in the php.ini. The directives are the
464 ; same as the PHP SAPI:
465 ; php_value/php_flag - you can set classic ini defines which can
466 ; be overwritten from PHP call 'ini_set'.
467 ; php_admin_value/php_admin_flag - these directives won't be overwritten by
468 ; PHP call 'ini_set'
469 ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
470
471 ; Defining 'extension' will load the corresponding shared extension from
472 ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
473 ; overwrite previously defined php.ini values, but will append the new value
474 ; instead.
475
476 ; Note: path INI options can be relative and will be expanded with the prefix
477 ; (pool, global or /usr)
478
479 ; Default Value: nothing is defined by default except the values in php.ini and
480 ; specified at startup with the -d argument
481 ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
482 ;php_flag[display_errors] = off
483 ;php_admin_value[error_log] = /var/log/fpm-php.www.log
484 ;php_admin_flag[log_errors] = on
485 ;php_admin_value[memory_limit] = 32M
486 [wit@on:pool.d]$
2、重启php8.1-fpm:[wit@on:pool.d]$ sudo systemctl restart php8.1-fpm.service
三、nginx软件的安装
1、安装nginx: sudo apt install nginx
四、nginx软件的配置
1、nginx文件配置(/etc/nginx/sites-available/default)
1 [wit@on:sites-available]$ pwd
2 /etc/nginx/sites-available
3 [wit@on:sites-available]$ ls
4 default
5 [wit@on:sites-available]$ cat default
6 ##
7 # You should look at the following URL's in order to grasp a solid understanding
8 # of Nginx configuration files in order to fully unleash the power of Nginx.
9 # https://www.nginx.com/resources/wiki/start/
10 # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
11 # https://wiki.debian.org/Nginx/DirectoryStructure
12 #
13 # In most cases, administrators will remove this file from sites-enabled/ and
14 # leave it as reference inside of sites-available where it will continue to be
15 # updated by the nginx packaging team.
16 #
17 # This file will automatically load configuration files provided by other
18 # applications, such as Drupal or Wordpress. These applications will be made
19 # available underneath a path with that package name, such as /drupal8.
20 #
21 # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
22 ##
23
24 # Default server configuration
25 #
26 server {
27 listen 80 default_server;
28 listen [::]:80 default_server;
29
30 # SSL configuration
31 #
32 # listen 443 ssl default_server;
33 # listen [::]:443 ssl default_server;
34 #
35 # Note: You should disable gzip for SSL traffic.
36 # See: https://bugs.debian.org/773332
37 #
38 # Read up on ssl_ciphers to ensure a secure configuration.
39 # See: https://bugs.debian.org/765782
40 #
41 # Self signed certs generated by the ssl-cert package
42 # Don't use them in a production server!
43 #
44 # include snippets/snakeoil.conf;
45
46 root /var/www/html;
47
48 # Add index.php to the list if you are using PHP
49 index index.html index.htm index.nginx-debian.html;
50
51 server_name _;
52
53 location / {
54 # First attempt to serve request as file, then
55 # as directory, then fall back to displaying a 404.
56 # try_files $uri $uri/ =404;
57
58 root /var/www/html;
59 index index.php index.html;
60 # try_files $uri $uri/ /index.php?$args;
61
62 }
63
64
65
66
67
68 # by david at 2023-10-24
69 location ~ \.php$ {
70 fastcgi_pass unix:/run/php/php8.1-fpm.sock;
71 fastcgi_index index.php;
72 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
73 include fastcgi_params;
74 }
75
76
77
78
79
80
81 # pass PHP scripts to FastCGI server
82 #
83 #location ~ \.php$ {
84 # include snippets/fastcgi-php.conf;
85 #
86 # # With php-fpm (or other unix sockets):
87 # fastcgi_pass unix:/run/php/php7.4-fpm.sock;
88 # # With php-cgi (or other tcp sockets):
89 # fastcgi_pass 127.0.0.1:9000;
90 #}
91
92 # deny access to .htaccess files, if Apache's document root
93 # concurs with nginx's one
94 #
95 #location ~ /\.ht {
96 # deny all;
97 #}
98
99
100
101
102 }
103
104
105 # Virtual Host configuration for example.com
106 #
107 # You can move that to a different file under sites-available/ and symlink that
108 # to sites-enabled/ to enable it.
109 #
110 #server {
111 # listen 80;
112 # listen [::]:80;
113 #
114 # server_name example.com;
115 #
116 # root /var/www/example.com;
117 # index index.html;
118 #
119 # location / {
120 # try_files $uri $uri/ =404;
121 # }
122 #}
2、重启ngxin: sudo systemctl restart nginx
五、参考资料
1、Nginx和PHP配置: https://zhuanlan.zhihu.com/p/340284241?utm_id=0
2、怎么搭建nginx php 环境: https://www.php.cn/faq/505110.html
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章的版权归属于【原创作者】; 转载或引用时请【保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/17783862.html