I checked their various configurations, too many and too many of them, and it is impossible to understand them one by one at the current basic O & M level. so I would like to ask you which configurations you are familiar with, especially those you need to know, how can I configure a project to better maintain the project and improve performance. I checked their various configurations, too many and too many of them, and it is impossible to understand them one by one at the current basic O & M level. so I would like to ask you which configurations you are familiar with, especially those you need to know, how can I configure a project to better maintain the project and improve performance.
Reply content:
I checked their various configurations, too many and too many of them, and it is impossible to understand them one by one at the current basic O & M level. so I would like to ask you which configurations you are familiar with, especially those you need to know, how can I configure a project to better maintain the project and improve performance.
This is a big question. let's talk about some of my personal concerns. other partners are welcome to join us to make improvements.
Security
-
Nginx (user configuration item), php-fpm (user, group configuration item), and other services, as well as website directory permissions, users, and user groups are really important.
-
For php security, pay attention to system-level functions. disable all functions without project requirements (disable_functions)
-
Php does not enable error printing, so it is easy to expose information to be attacked.
display_startup_errors = Off ,display_errors = Off
Performance
-
Number of nginx processes worker_processes and maximum number of connections worker_connections
-
Php-fpm performance: pm. max_children, pm. start_servers, pm. min_spare_servers, pm. max_spare_servers, pm. max_requests
Log Monitoring analysis
-
Nginx log: access_log and log_format
-
Php logging: log_errors
-
Php-fpm records slow execution logs: slowlog and request_slowlog_timeout
I will also pay attention to the following system levels: iptables,/etc/sysctl. conf, etc.
Suggestions
It is best to write a script to monitor the memory, traffic, cpu, process count, disk space, and so on. you can also use monitoring products, open-source monitoring projects, and so on to properly control the alarm policy.
Then, analyze the log files generated in the preceding configuration regularly, and check slow response logs, error times, and slow execution logs to solve some performance problems in daily operation.
Php configuration basically does not need to be changed by default. The main thing is to add the configuration in php. ini when adding Xdebug, as shown in
[xdebug]zend_extension="/Applications/MAMP/bin/php/php7.0.0/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"xdebug.remote_enable = 1xdebug.remote_connect_back = 1xdebug.remote_port = 9000xdebug.scream=0 xdebug.cli_color=1xdebug.show_local_vars=1
Xdebug is particularly useful in the Development environment. to enable OPcache in the Production environment, you need to enable the OPcache configuration in php. ini, for example:
[OPcache]zend_extension="/Applications/MAMP/bin/php/php7.0.0/lib/php/extensions/no-debug-non-zts-20151012/opcache.so" opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1
For PHP log processing, we recommend that you use the monolog/monolog library to process log printing.
Here we recommend an exception handling tool Sentry and a log processing tool Logentries.
Php-fpm:
Pm series configuration