In small and medium-sized projects, which configurations of nginx, php-fpm, and php are frequently used and important and need to be concerned ???

Source: Internet
Author: User
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

  1. 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.

  2. For php security, pay attention to system-level functions. disable all functions without project requirements (disable_functions)

  3. Php does not enable error printing, so it is easy to expose information to be attacked.

display_startup_errors = Off ,display_errors = Off

Performance

  1. Number of nginx processes worker_processes and maximum number of connections worker_connections

  2. Php-fpm performance: pm. max_children, pm. start_servers, pm. min_spare_servers, pm. max_spare_servers, pm. max_requests

Log Monitoring analysis

  1. Nginx log: access_log and log_format

  2. Php logging: log_errors

  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.