# php腳本執行時間配置
??php執行腳本時間長會導致腳本超時,報錯504 Gateway Time-out,設置nginx fastcgi\_read\_timeout 時間和php腳本request\_terminate\_timeout 時間解決腳本超錯誤。
**一、nginx配置**
~~~
vim nginx.conf
#增加 fastcgi_read_timeout 300;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
~~~
fastcgi更多設置:
~~~
fastcgi_connect_timeout 300; #連接(很快)
fastcgi_send_timeout 300; #發送(很快)
fastcgi_read_timeout 300; #讀取(php腳本運行并返回數據)
~~~
反向代理到php方式的超時設置:
~~~
#增加 proxy_send_timeout 600;
location / {
proxy_pass http://127.0.0.1/test.php
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_send_timeout 600;
}
~~~
**反向代理到php方式更多的超時設置:**
~~~
proxy_connect_timeout 600; \\跟后端服務器連接的超時時間,發起握手等候響應超時時間
proxy_read_timeout 600;\\連接成功 _等候后端服務器的響應時間_其實已經進入后端的排隊中等候處理
proxy_send_timeout 600; \\后端服務器回傳時間_就是在規定時間內后端服務器必須傳完所有的數據。設置代理服務器轉發請求的超時時間,同樣指完成兩次握手后的時間,如果超過這個時間代理服務器沒有數據轉發到后端服務器,nginx將關閉連接。
~~~
**二、php配置**
~~~
vim www.conf
#配置 ;request_terminate_timeout = 30
request_terminate_timeout = 300
~~~

????重啟nginx,重啟php-fpm
**php代碼超時設置:**
~~~
ini_set("max_execution_time", "120"); //ini_set配置方式
set_time_limit(120);
set_time_limit(0); //不超時
~~~
- (一)服務器架構
- ECS
- (二)寶塔安裝
- 寶塔的webhook使用方法
- (三)配置更改
- php-fpm.conf
- proxy.conf
- nginx.conf
- (四)運維日志
- nginx日志
- nginx錯誤日志
- open socket
- fpm日志
- php-fpm錯誤日志
- seems busy
- slow.log
- 站點日志
- dyhjw.log
- 站點錯誤日志
- dyhjw.error.log
- 499錯誤
- recv()
- recv() failed
- recv() failed-第3種
- no live upstreams
- upstream prematurely
- cache_file_has_too_long_header
- FastCGI sent in stderr
- directory index of is forbidden
- recv() failed-第4種
- (五)站點配置
- appapi配置
- 用到redis的網站
- workman不能運行
- 快訊啟動
- dyhjw偽靜態
- (六)其他問題
- php-5.6重新啟動報錯
- 掛載盤命令
- 服務器怎么增加黑名單不讓指定IP登錄
- (七)自定義頁面
- 自定義404頁面
- 自定義502頁面
- (八)問題
- 負載均衡的文件在哪里
- 站點的負載均衡服務器文件在哪里
- 其他知識
- Nginx--keepalive的配置
- Nginx反爬蟲攻略:禁止某些User Agent抓取網站
- php腳本執行時間配置
- 運維記錄