{"id":1006,"date":"2009-11-29T19:28:00","date_gmt":"2009-11-29T11:28:00","guid":{"rendered":"\/?p=1006"},"modified":"2009-11-29T19:28:00","modified_gmt":"2009-11-29T19:28:00","slug":"1006","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/linux\/1006.html","title":{"rendered":"CentOS+Nginx+PHP+Mysql+\u5b89\u5168\u6307\u5357\u5168\u73af\u5883\u642d\u5efa\u7b14\u8bb0\uff08\u4e8c\uff09"},"content":{"rendered":"
– \u670d\u52a1\u5668\u7684\u5b89\u5168\u8bbe\u7f6e\u53ca\u5176\u4ed6 <\/strong><\/p>\n \u4e3b\u8981\u5185\u5bb9\uff1a [\u8bbe\u7f6eNgnix\u53ef\u63d0\u4f9bAVI\u3001MP3\u7b49\u7684\u4e0b\u8f7d]<\/strong><\/p>\n # vi \/usr\/local\/webserver\/nginx\/conf\/mime.types [\u8bbe\u7f6e\u7f51\u7ad9\u5e76\u53d1\u6570\u9650\u5236] [\u8bbe\u7f6enginx\u7a0b\u5e8f\u9650\u5236\u76841M\u4e0a\u4f20\u95ee\u9898] [\u4f18\u5316PHP]<\/strong> # vi \/usr\/local\/webserver\/php\/etc\/php.ini 1.\u5c06"disable_functions =" 2.\u5c06"upload_max_filesize = 2M" [\u4f18\u5316mysql]<\/strong> # vi \/usr\/local\/webserver\/mysql\/my.cnf \u2191 \u7f16\u8f91my.cnf\u6587\u4ef6<\/p>\n 1.\u5c06"table_cache = 64" 2.\u5c06"sort_buffer_size = 512k" 3.\u5c06"read_buffer_size = 128k" 4.\u5c06"read_rnd_buffer_size = 512k" 5.\u5c06"myisam_sort_buffer_size = 8M"
[\u8bbe\u7f6eNgnix\u53ef\u63d0\u4f9bAVI\u3001MP3\u7b49\u7684\u4e0b\u8f7d]
[\u8bbe\u7f6e\u7f51\u7ad9\u5e76\u53d1\u6570\u9650\u5236]
[\u8bbe\u7f6enginx\u7a0b\u5e8f\u9650\u5236\u76841M\u4e0a\u4f20\u95ee\u9898]
[\u4f18\u5316PHP]
[\u4f18\u5316mysql]
[mysql\u7684\u5b89\u5168\u8bbe\u7f6e]
[\u7cfb\u7edf\u6574\u4f53\u5b89\u5168\u8c03\u6574]<\/p>\n
\u2191 \u7f16\u8f91mime.types\u6587\u4ef6
\u5c06\u9700\u8981\u63d0\u4f9b\u4e0b\u8f7d\u7684\u683c\u5f0f\u524d\u7684\u6587\u4ef6\u7c7b\u578b\u4fee\u6539\u4e3a"application\/octet-stream"
# vi \/usr\/local\/webserver\/nginx\/conf\/mime.types.default
\u2191 \u7f16\u8f91mime.types.default\u6587\u4ef6
\u5c06\u9700\u8981\u63d0\u4f9b\u4e0b\u8f7d\u7684\u683c\u5f0f\u524d\u7684\u6587\u4ef6\u7c7b\u578b\u4fee\u6539\u4e3a"application\/octet-stream"<\/p>\n
<\/strong>\u5df2\u5728\u914d\u7f6enginx.conf\u6587\u4ef6\u65f6\u52a0\u5165\u5e76\u53d1\u6570\u9650\u5236\uff0c\u5177\u4f53\u53c2\u89c1\u5b98\u65b9\u7ef4\u57fa\u767e\u79d1(http:\/\/wiki.codemongers.com\/NginxChsHttpLimit_zoneModule)"httplimit_zonemodule<\/a> "\u90e8\u5206<\/p>\n
<\/strong>\u5df2\u5728\u914d\u7f6enginx.conf\u6587\u4ef6\u65f6\u53d6\u6d881M\u4e0a\u4f20\u9650\u5236\uff0c\u5177\u4f53\u53c2\u89c1nginx.conf\u6587\u4ef6\u5185\u6ce8\u91ca<\/p>\n
\u5177\u4f53\u53c2\u89c1(http:\/\/www.cnprint.org\/bbs\/blogs\/1\/blog312.html)"php<\/a> \u4f18\u5316\u8bbe\u7f6e"\u90e8\u5206
\u6b64\u5904\u4ec5\u8bbe\u7f6e\u90e8\u5206\u5fc5\u8981\u5185\u5bb9<\/p>\n
\u2191 \u7f16\u8f91php.ini\u6587\u4ef6<\/p>\n
\u4fee\u6539\u4e3a "disable_functions = phpinfo,passthru,exec,system,popen,chroot,escapeshellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status"
\u2191**\u8fd9\u6761\u5efa\u8bae\u5728\u7f51\u7ad9\u5efa\u6210\u4e4b\u540e\u4fee\u6539**\u8be5\u9009\u9879\u53ef\u4ee5\u8bbe\u7f6e\u54ea\u4e9bPHP\u51fd\u6570\u662f\u7981\u6b62\u4f7f\u7528\u7684\uff0cPHP\u4e2d\u6709\u4e00\u4e9b\u51fd\u6570\u7684\u98ce\u9669\u6027\u8fd8\u662f\u76f8\u5f53\u5927\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u6267\u884c\u4e00\u4e9b\u7cfb\u7edf\u7ea7\u811a\u672c\u547d\u4ee4\uff0c\u5982\u679c\u5141\u8bb8\u8fd9\u4e9b\u51fd\u6570\u6267\u884c\uff0c\u5f53PHP\u7a0b\u5e8f\u51fa\u73b0\u6f0f\u6d1e\u65f6\uff0c\u635f\u5931\u662f\u975e\u5e38\u4e25\u91cd\u7684\uff01
\u9700\u6ce8\u610f\uff1a\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u4e2d\u542b\u6709\u4e00\u4e9b\u7cfb\u7edf\u72b6\u6001\u68c0\u6d4b\u7684PHP\u7a0b\u5e8f\uff0c\u5219\u4e0d\u8981\u7981\u7528shell_exec,proc_open,proc_get_status\u7b49\u51fd\u6570\u3002<\/p>\n
\u4fee\u6539\u4e3a "upload_max_filesize = 50M"
\u2191\u8be5\u9009\u9879\u8bbe\u5b9aPHP\u6240\u80fd\u5141\u8bb8\u6700\u5927\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\uff0c\u9ed8\u8ba4\u4e3a2MB\u3002\u6839\u636e\u5b9e\u9645\u5e94\u7528\u9700\u6c42\uff0c\u53ef\u4ee5\u9002\u5f53\u589e\u5927\u8be5\u8bbe\u7f6e\u3002<\/p>\n
\u5177\u4f53\u53c2\u89c1(http:\/\/www.cnprint.org\/bbs\/blogs\/1\/blog312.html)"mysql<\/a> \u4f18\u5316\u53ca\u5b89\u5168\u8bbe\u7f6e"\u90e8\u5206
\u6b64\u5904\u4ec5\u8bbe\u7f6e\u90e8\u5206\u5fc5\u8981\u5185\u5bb9<\/p>\n
\u4fee\u6539\u4e3a "table_cache = 512"
\u2191\u6307\u5b9a\u8868\u9ad8\u901f\u7f13\u5b58\u7684\u5927\u5c0f\u3002\u6bcf\u5f53MySQL\u8bbf\u95ee\u4e00\u4e2a\u8868\u65f6\uff0c\u5982\u679c\u5728\u8868\u7f13\u51b2\u533a\u4e2d\u8fd8\u6709\u7a7a\u95f4\uff0c\u8be5\u8868\u5c31\u88ab\u6253\u5f00\u5e76\u653e\u5165\u5176\u4e2d\uff0c\u8fd9\u6837\u53ef\u4ee5\u66f4\u5feb\u5730\u8bbf\u95ee\u8868\u5185\u5bb9\u3002\u901a\u8fc7\u68c0\u67e5\u5cf0\u503c\u65f6\u95f4\u7684\u72b6\u6001\u503cOpen_tables\u548cOpened_tables\uff0c\u53ef\u4ee5\u51b3\u5b9a\u662f\u5426\u9700\u8981\u589e\u52a0table_cache\u7684\u503c\u3002\u5982\u679c\u60a8\u53d1\u73b0open_tables\u7b49\u4e8e table_cache\uff0c\u5e76\u4e14opened_tables\u5728\u4e0d\u65ad\u589e\u957f\uff0c\u90a3\u4e48\u60a8\u5c31\u9700\u8981\u589e\u52a0table_cache\u7684\u503c\u4e86\uff08\u4e0a\u8ff0\u72b6\u6001\u503c\u53ef\u4ee5\u4f7f\u7528show status like ‘Open_tables’\u83b7\u5f97\uff09\u3002\u6ce8\u610f\uff0c\u4e0d\u80fd\u76f2\u76ee\u5730\u628atable_cache\u8bbe\u7f6e\u6210\u5f88\u5927\u7684\u503c\u3002\u5982\u679c\u8bbe\u7f6e\u5f97\u592a\u9ad8\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e0d\u8db3\uff0c\u4ece\u800c\u9020\u6210\u6027\u80fd\u4e0d\u7a33\u5b9a\u6216\u8005\u8fde\u63a5\u5931\u8d25\u3002<\/p>\n
\u4fee\u6539\u4e3a "sort_buffer_size = 2M"
\u2191\u6bcf\u4e2a\u7ebf\u7a0b\u6392\u5e8f\u6240\u9700\u7684\u7f13\u51b2<\/p>\n
\u4fee\u6539\u4e3a "read_buffer_size = 2M"
\u2191\u5f53\u4e00\u4e2a\u67e5\u8be2\u4e0d\u65ad\u5730\u626b\u63cf\u67d0\u4e00\u4e2a\u8868\uff0cMySQL\u4f1a\u4e3a\u5b83\u5206\u914d\u4e00\u6bb5\u5185\u5b58\u7f13\u51b2\u533a\u3002read_buffer_size\u53d8\u91cf\u63a7\u5236\u8fd9\u4e00\u7f13\u51b2\u533a\u7684\u5927\u5c0f\u3002\u5982\u679c\u60a8\u8ba4\u4e3a\u8fde\u7eed\u626b\u63cf\u8fdb\u884c\u5f97\u592a\u6162\uff0c\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0\u8be5\u53d8\u91cf\u503c\u4ee5\u53ca\u5185\u5b58\u7f13\u51b2\u533a\u5927\u5c0f\u63d0\u9ad8\u5176\u6027\u80fd\u3002<\/p>\n
\u4fee\u6539\u4e3a "read_rnd_buffer_size = 4M"
\u2191\u52a0\u901f\u6392\u5e8f\u64cd\u4f5c\u540e\u7684\u8bfb\u6570\u636e\uff0c\u63d0\u9ad8\u8bfb\u5206\u7c7b\u884c\u7684\u901f\u5ea6\u3002\u5982\u679c\u6b63\u5bf9\u8fdc\u8fdc\u5927\u4e8e\u53ef\u7528\u5185\u5b58\u7684\u8868\u6267\u884cGROUP BY\u6216ORDER BY\u64cd\u4f5c\uff0c\u5e94\u589e\u52a0read_rnd_buffer_size\u7684\u503c\u4ee5\u52a0\u901f\u6392\u5e8f\u64cd\u4f5c\u540e\u9762\u7684\u884c\u8bfb\u53d6\u3002\u4ecd\u7136\u4e0d\u660e\u767d\u8fd9\u4e2a\u9009\u9879\u7684\u7528\u5904\u2026<\/p>\n
\u4fee\u6539\u4e3a "myisam_sort_buffer_size = 32M"
\u2191\u7528\u4e8eREPAIR TABLE\u3002\u4e0d\u660e\u767d\u8fd9\u4e2a\u9009\u9879\u7684\u7528\u5904\uff0c\u767e\u5ea6\u4e0a\u627e\u5230\u7684\u8bbe\u7f6e\u65b9\u5411\u4e5f\u662f\u4e94\u82b1\u516b\u95e8\uff0c\u6709128M\u300164M\u300132M\u7b49\uff0c\u6298\u4e2d\u9009\u4e00\u4e2a\u3002<\/p>\n