当前位置:网站首页>Analysis of PHP environment configuration
Analysis of PHP environment configuration
2022-06-24 05:06:00 【User 7426861】
PHP As an open source server-side scripting language , stay web It's widely used . If you want to download some open source applications ,github On php Open source software choices are often better than Java even more than . lately , Studied linux Next php Installation , The main experience is as follows .
PHP-INI
php.ini File is php And can only be named as php.ini, It's right php Application global settings file , There are a lot of options , contain php Page usage memory size limit , Upload and download file size limit , Floating point precision, etc .
FPM-PHP
fpm-php(FastCGI ProcessManager) It was originally php Third party package for , stay php5.3.3 It became php Core members of , No need to download and install separately .FastCGI Before the birth of ,web The end forwards a php After the request , Need to reload php.ini, adopt fpm-php establish master process , Received more than one php request , Create child processes to share master Process loaded php.ini Information . install fpm-php after , start-up php In fact, by starting fpm-php.service To achieve .fpm-php and web Communication can be achieved in two ways ,socket and tcp The way , adopt /etc/php-fpm.d/www.conf To configure . The main difference between the two methods is listen The configuration of is different . One is php-fpm.sock, One is the server ip:9000.
socket The way is long connection , Apply to php On the same server as other services
[www] user = nginx group = nginx listen = /run/php-fpm.sock
tcp The way is http Request mode , It is suitable for multi server cluster with high concurrency
[www] user = nginx group = nginx listen = 127.0.0.1:9000
Let's talk about how processes are allocated , In terms of the following configuration ,start_servers=10 explain php The service starts 10 individual worker The child process has been waiting ,min_spare_servers=5 Is the smallest active process .php On at start up 8 A process , If not received web request ,fpm-php It will release some , Finally achieve 5 A process . But not more than max_spare_servers = 35. as for max_children=50, That's static configuration , constant , It's a waste of resources , Always on 50 Processes are waiting there , It's the same even if no one visits the site .
pm.max_children = 50 pm.start_servers = 10 pm.min_spare_servers = 5 pm.max_spare_servers = 35
Expansion pack,
Install only php Often can not meet the needs of the application software , There are a lot of other extension packages to support php application . for example ,【odbc,common,ima,mongodb,xml etc. 】, However, it should be noted that the following packages are based on pecl Of 【apcu,imagick,goeip,mcrypt,redis,zip,memcache】. especially ,zip Packages need to be specified in particular pecl, Otherwise, the expansion pack installation will not succeed , other pecl Bags can be made from remi Automatically find the response package in the source .
yum install php-common yum install php-apcu yum install php-pecl-zip
web Server related configuration
php and web The server nginx,apache We also need to do some association configuration , Add the following to their profile :
nginx:
location ~ .*\.php$
{
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $uri = 404;
}
apache:
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php-fpm.sock|fcgi://localhost"
</FilesMatch>however ,ubuntu Under the system PHP Application and use apache In the case of servers , Need configuration , Otherwise, vice versa apache The server reported an error and could not be started . That's right php To understand the configuration of , In the future, with the deepening of its research , And write about php Something new .
边栏推荐
- 阿里云新一代云计算体系架构 CIPU 到底是啥?
- What is the domain name of the website? How much is a domain name
- 阿里云混合云首席架构师张晓丹:政企混合云技术架构的演进和发展
- Here's all you want to know about takin data (1) startup command
- How novices choose ECs and how to judge the quality of ECS
- Use of golang testing framework goshub
- Hard core JS: there may be a memory leak in your program
- How to build an ECS and how to control the server through the local host
- How do ECS create FTP accounts? What should I pay attention to during creation?
- Share 10 creative projects of Gaoxing!
猜你喜欢

Idea creates a servlet and accesses the 404 message

Training methods after the reform of children's programming course

"Emergency response practice" logparser log analysis practice

Leetcode (question 2) - adding two numbers

阿里云新一代云计算体系架构 CIPU 到底是啥?

Popularization of children's programming education in specific scenarios

011_ Cascader cascade selector

Facebook internal announcement: instant messaging will be re integrated

Let children learn the application essence of steam Education

少儿编程课程改革后的培养方式
随机推荐
Let children learn the application essence of steam Education
Automatically convert local pictures to network pictures when writing articles
梯度下降法介紹-黑馬程序員機器學習講義
Use of golang testing framework goshub
How the query address of cloud native monitoring data exposes the public network
『应急响应实践』LogParser日志分析实践
Shutter - how to copy certain elements from a map to a new map in dart/shutter?
What is required for domain name filing and how to select an enterprise domain name
Ext4 file system jam caused by MEM CGroup OOM
LeetCode 1662. Check whether two string arrays are equal
Here's all you want to know about takin data (1) startup command
Oracle database prompts no operation permission
2021-08-27: the normal odometer will display natural numbers in turn to indicate mileage, Kyrgyzstan
How does the mobile phone remotely connect to the ECS? What should be paid attention to during the operation
011_ Cascader cascade selector
How to control CDN traffic gracefully in cloud development?
Inventory of common tools used by dry goods | data journalists
Introduction à la méthode de descente par Gradient - document d'apprentissage automatique pour les programmeurs de chevaux noirs
Idea creates a servlet and accesses the 404 message
Cos+cdn realizes the distribution of game client version files in a faster, better and cheaper manner