Trang chủ
Các bài mới
Latest activity
Biên tập viên
Diễn Đàn
Bài viết mới
Tìm kiếm diễn đàn
Tin Mới
Bài viết mới
New resources
Bài đăng tiểu sử mới
Hoạt động mới nhất
Resources
Latest reviews
Search resources
Thành Viên
Khách truy cập hiện tại
Bài mới trên trang cá nhân
Tìm kiếm bài đăng trong trang cá nhân
Tool
SMTool - Công cụ đăng bài tự động Facebook
50 SEO Tools
Photoshop online
Facebook Video Down
Cầu nguyện Genshin
Biolink
Genshin map
Đăng nhập
Đăng ký
Mới
Tìm kiếm
Tìm kiếm
Chỉ tìm trong tiêu đề
bởi:
Bài viết mới
Tìm kiếm diễn đàn
Menu
Đăng nhập
Đăng ký
Install the app
Install
28/06 cập nhật đăng ký đăng nhập qua Google & Facebook
Diễn Đàn
Thủ thuật
Thủ thuật internet
Cyber Panel Note
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Nội dung
<blockquote data-quote="TenHoshi" data-source="post: 26420" data-attributes="member: 1"><p>Cấu hình “chuẩn an toàn” cho <strong>VPS 2 vCPU – 2 GB RAM</strong> chạy <strong>CyberPanel + OpenLiteSpeed + PHP 8.2</strong>. Mục tiêu: hết “possible dead lock”, giảm swap, giữ site mượt ổn định.</p><p></p><h3>1) OpenLiteSpeed → External App (lsphp)</h3><p><strong>WebAdmin (port 7080) → Server Configuration → External App → lsphp</strong></p><ul> <li data-xf-list-type="ul"><strong>Name</strong>: lsphp</li> <li data-xf-list-type="ul"><strong>Address</strong>: uds://tmp/lshttpd/lsphp.sock (giữ UDS)</li> <li data-xf-list-type="ul"><strong>Max Connections</strong>: 12</li> <li data-xf-list-type="ul"><strong>Environment</strong>:<br /> PHP_LSAPI_CHILDREN=4<br /> PHP_LSAPI_MAX_REQUESTS=300<br /> </li> <li data-xf-list-type="ul"><strong>Initial Request Timeout</strong>: 90</li> <li data-xf-list-type="ul"><strong>Retry Timeout</strong>: 0</li> <li data-xf-list-type="ul"><strong>Persistent Connection</strong>: Yes</li> <li data-xf-list-type="ul"><strong>Connection Keep-Alive Timeout</strong>: 3</li> <li data-xf-list-type="ul"><strong>Response Buffering</strong>: No</li> <li data-xf-list-type="ul"><strong>Start By Server</strong>: Yes (Through CGI Daemon)</li> <li data-xf-list-type="ul"><strong>Command</strong>: lsphp82/bin/lsphp</li> <li data-xf-list-type="ul"><strong>Back Log</strong>: 20</li> <li data-xf-list-type="ul"><strong>Instances</strong>: 2<br /> </li> <li data-xf-list-type="ul"><strong>Run On Start Up</strong>: Not Set (hoặc Yes cũng được)</li> <li data-xf-list-type="ul"><strong>Max Idle Time</strong>: 30</li> <li data-xf-list-type="ul"><strong>Priority</strong>: 0</li> <li data-xf-list-type="ul"><strong>Memory Soft/Hard Limit</strong>: 256M / 384M</li> <li data-xf-list-type="ul"><strong>Process Soft/Hard Limit</strong>: giữ mặc định (không phải nút thắt)</li> </ul><p><strong>Lưu → Actions → Graceful Restart</strong>.</p><h3>2) OpenLiteSpeed → Tuning</h3><p><strong>Server Configuration → Tuning</strong></p><ul> <li data-xf-list-type="ul"><strong>PHP suEXEC Max Conn</strong>: 12 (khớp Max Connections)</li> <li data-xf-list-type="ul"><strong>Connection Timeout</strong>: 120</li> <li data-xf-list-type="ul"><strong>Max Connections (server)</strong>: để mặc định hoặc ≥ 1000 (không phải bottleneck)</li> <li data-xf-list-type="ul"><strong>Log Level</strong>: ERROR (giảm spam NOTICE)</li> </ul><h3>3) PHP 8.2 (lsphp) – php.ini</h3><p>Đường dẫn thường:</p><p>/usr/local/lsws/lsphp82/etc/php/8.2/litespeed/php.ini (tuỳ bản cài)</p><p></p><p>; --- Memory / execution ---</p><p>memory_limit = 128M; nếu thiếu mới nâng 160M</p><p>max_execution_time = 60</p><p>max_input_time = 60</p><p>post_max_size = 32M</p><p>upload_max_filesize = 32M</p><p>default_socket_timeout = 30</p><p></p><p>; --- Opcache (bắt buộc bật) ---</p><p>opcache.enable=1</p><p>opcache.enable_cli=0</p><p>opcache.memory_consumption=128</p><p>opcache.interned_strings_buffer=16</p><p>opcache.max_accelerated_files=65000</p><p>opcache.validate_timestamps=1</p><p>opcache.revalidate_freq=2</p><p>opcache.jit=0</p><p></p><p>; --- MySQL client timeouts ---</p><p>mysqlnd.net_read_timeout=30</p><p></p><p></p><h3>4) MySQL/MariaDB (cơ bản, hợp 2 GB)</h3><p>File /etc/mysql/mariadb.conf.d/60-server.cnf (hoặc tương đương):</p><p></p><p>[mysqld]</p><p>innodb_buffer_pool_size=512M</p><p>innodb_log_file_size=128M</p><p>innodb_flush_log_at_trx_commit=1</p><p>innodb_flush_method=O_DIRECT</p><p>max_connections=80</p><p>table_open_cache=1024</p><p>query_cache_size=0</p><p>query_cache_type=0</p><p></p><p># Slow log để bắt truy vấn nặng</p><p>slow_query_log=1</p><p>long_query_time=1</p><p>log_slow_verbosity=query_plan</p><p></p><p></p><p>sudo systemctl restart mariadb || sudo systemctl restart mysql</p><p></p><h3>5) Kernel: giảm dùng swap</h3><p>echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf</p><p>sudo sysctl -p /etc/sysctl.d/99-swappiness.conf</p><p></p><p></p><h3>6) Log: xoay & nén (logrotate)</h3><p></p><p>Tạo /etc/logrotate.d/openlitespeed:</p><p></p><p>/usr/local/lsws/logs/*.log {</p><p> daily</p><p> rotate 7</p><p> compress</p><p> missingok</p><p> notifempty</p><p> create 640 root root</p><p> sharedscripts</p><p> postrotate</p><p> /bin/systemctl reload lsws > /dev/null 2>&1 || true</p><p> endscript</p><p>}</p><h3>7) LSCache / Cache header (khuyến nghị)</h3> <ul> <li data-xf-list-type="ul">Bật LSCache plugin nếu dùng WordPress/Laravel.</li> <li data-xf-list-type="ul">Với các API tĩnh kiểu avatar đã xử lý xong, thêm header cache:</li> </ul><p>header('Cache-Control: public, max-age=86400, s-maxage=86400');</p><p></p><h3>8) Giảm tải bot Facebook (cực hiệu quả)</h3><p>Ở tầng sớm nhất (bootstrap/index.php hoặc middleware đầu), trả <strong>OG nhẹ</strong> cho UA facebookexternalhit:</p><p></p><p>[CODE]if (isset($_SERVER['HTTP_USER_AGENT']) &&</p><p></p><p> stripos($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') !== false) {</p><p></p><p> header('Content-Type: text/html; charset=UTF-8');</p><p></p><p> echo '<!doctype html><html><head></p><p></p><p> <meta property="og:title" content="Riokupon" /></p><p></p><p> <meta property="og:description" content="Login & deals" /></p><p></p><p> <meta property="og:image" content="https://img.riokupon.com/og/cover.jpg" /></p><p></p><p> </head><body>OK</body></html>';</p><p></p><p> exit;</p><p></p><p>}[/CODE]</p><ul> <li data-xf-list-type="ul">Ảnh OG nén < 300 KB, 1200×630.</li> <li data-xf-list-type="ul">Tránh mọi gọi API/DB nặng khi UA là FB crawler.</li> </ul><h3>9) Kiểm tra & giám sát nhanh</h3><p># Số tiến trình PHP & RAM/tiến trình</p><p>ps -o pid,rss,cmd -C lsphp | sort -nrk2 | head</p><p></p><p># Bộ nhớ & swap</p><p>free -m</p><p>vmstat 1 5</p><p></p><p># Test UA thường & FB</p><p>curl -I <a href="https://riokupon.com/">https://riokupon.com/</a></p><p>curl -I -A "facebookexternalhit/1.1" <a href="https://riokupon.com/">https://riokupon.com/</a></p><p></p><p># Slow queries (sau vài phút bật slow log)</p><p>sudo grep -A3 -B1 -n "Query_time" /var/lib/mysql/*slow*.log 2>/dev/null | head -n 50</p><p></p><h3>Gợi ý mức tải phù hợp</h3> <ul> <li data-xf-list-type="ul">Với site PHP trung bình, cấu hình trên chịu tốt <strong>50–150 req/min</strong> tùy mức cache.</li> <li data-xf-list-type="ul">Nếu traffic tăng: nâng RAM lên 4 GB trước khi tăng Max Connections/CHILDREN.</li> </ul></blockquote><p></p>
[QUOTE="TenHoshi, post: 26420, member: 1"] Cấu hình “chuẩn an toàn” cho [B]VPS 2 vCPU – 2 GB RAM[/B] chạy [B]CyberPanel + OpenLiteSpeed + PHP 8.2[/B]. Mục tiêu: hết “possible dead lock”, giảm swap, giữ site mượt ổn định. [HEADING=2]1) OpenLiteSpeed → External App (lsphp)[/HEADING] [B]WebAdmin (port 7080) → Server Configuration → External App → lsphp[/B] [LIST] [*][B]Name[/B]: lsphp [*][B]Address[/B]: uds://tmp/lshttpd/lsphp.sock (giữ UDS) [*][B]Max Connections[/B]: 12 [*][B]Environment[/B]: PHP_LSAPI_CHILDREN=4 PHP_LSAPI_MAX_REQUESTS=300 [*][B]Initial Request Timeout[/B]: 90 [*][B]Retry Timeout[/B]: 0 [*][B]Persistent Connection[/B]: Yes [*][B]Connection Keep-Alive Timeout[/B]: 3 [*][B]Response Buffering[/B]: No [*][B]Start By Server[/B]: Yes (Through CGI Daemon) [*][B]Command[/B]: lsphp82/bin/lsphp [*][B]Back Log[/B]: 20 [*][B]Instances[/B]: 2 [*][B]Run On Start Up[/B]: Not Set (hoặc Yes cũng được) [*][B]Max Idle Time[/B]: 30 [*][B]Priority[/B]: 0 [*][B]Memory Soft/Hard Limit[/B]: 256M / 384M [*][B]Process Soft/Hard Limit[/B]: giữ mặc định (không phải nút thắt) [/LIST] [B]Lưu → Actions → Graceful Restart[/B]. [HEADING=2]2) OpenLiteSpeed → Tuning[/HEADING] [B]Server Configuration → Tuning[/B] [LIST] [*][B]PHP suEXEC Max Conn[/B]: 12 (khớp Max Connections) [*][B]Connection Timeout[/B]: 120 [*][B]Max Connections (server)[/B]: để mặc định hoặc ≥ 1000 (không phải bottleneck) [*][B]Log Level[/B]: ERROR (giảm spam NOTICE) [/LIST] [HEADING=2]3) PHP 8.2 (lsphp) – php.ini[/HEADING] Đường dẫn thường: /usr/local/lsws/lsphp82/etc/php/8.2/litespeed/php.ini (tuỳ bản cài) ; --- Memory / execution --- memory_limit = 128M; nếu thiếu mới nâng 160M max_execution_time = 60 max_input_time = 60 post_max_size = 32M upload_max_filesize = 32M default_socket_timeout = 30 ; --- Opcache (bắt buộc bật) --- opcache.enable=1 opcache.enable_cli=0 opcache.memory_consumption=128 opcache.interned_strings_buffer=16 opcache.max_accelerated_files=65000 opcache.validate_timestamps=1 opcache.revalidate_freq=2 opcache.jit=0 ; --- MySQL client timeouts --- mysqlnd.net_read_timeout=30 [HEADING=2]4) MySQL/MariaDB (cơ bản, hợp 2 GB)[/HEADING] File /etc/mysql/mariadb.conf.d/60-server.cnf (hoặc tương đương): [mysqld] innodb_buffer_pool_size=512M innodb_log_file_size=128M innodb_flush_log_at_trx_commit=1 innodb_flush_method=O_DIRECT max_connections=80 table_open_cache=1024 query_cache_size=0 query_cache_type=0 # Slow log để bắt truy vấn nặng slow_query_log=1 long_query_time=1 log_slow_verbosity=query_plan sudo systemctl restart mariadb || sudo systemctl restart mysql [HEADING=2]5) Kernel: giảm dùng swap[/HEADING] echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf sudo sysctl -p /etc/sysctl.d/99-swappiness.conf [HEADING=2]6) Log: xoay & nén (logrotate)[/HEADING] Tạo /etc/logrotate.d/openlitespeed: /usr/local/lsws/logs/*.log { daily rotate 7 compress missingok notifempty create 640 root root sharedscripts postrotate /bin/systemctl reload lsws > /dev/null 2>&1 || true endscript } [HEADING=2]7) LSCache / Cache header (khuyến nghị)[/HEADING] [LIST] [*]Bật LSCache plugin nếu dùng WordPress/Laravel. [*]Với các API tĩnh kiểu avatar đã xử lý xong, thêm header cache: [/LIST] header('Cache-Control: public, max-age=86400, s-maxage=86400'); [HEADING=2]8) Giảm tải bot Facebook (cực hiệu quả)[/HEADING] Ở tầng sớm nhất (bootstrap/index.php hoặc middleware đầu), trả [B]OG nhẹ[/B] cho UA facebookexternalhit: [CODE]if (isset($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') !== false) { header('Content-Type: text/html; charset=UTF-8'); echo '<!doctype html><html><head> <meta property="og:title" content="Riokupon" /> <meta property="og:description" content="Login & deals" /> <meta property="og:image" content="https://img.riokupon.com/og/cover.jpg" /> </head><body>OK</body></html>'; exit; }[/CODE] [LIST] [*]Ảnh OG nén < 300 KB, 1200×630. [*]Tránh mọi gọi API/DB nặng khi UA là FB crawler. [/LIST] [HEADING=2]9) Kiểm tra & giám sát nhanh[/HEADING] # Số tiến trình PHP & RAM/tiến trình ps -o pid,rss,cmd -C lsphp | sort -nrk2 | head # Bộ nhớ & swap free -m vmstat 1 5 # Test UA thường & FB curl -I [URL]https://riokupon.com/[/URL] curl -I -A "facebookexternalhit/1.1" [URL]https://riokupon.com/[/URL] # Slow queries (sau vài phút bật slow log) sudo grep -A3 -B1 -n "Query_time" /var/lib/mysql/*slow*.log 2>/dev/null | head -n 50 [HEADING=2]Gợi ý mức tải phù hợp[/HEADING] [LIST] [*]Với site PHP trung bình, cấu hình trên chịu tốt [B]50–150 req/min[/B] tùy mức cache. [*]Nếu traffic tăng: nâng RAM lên 4 GB trước khi tăng Max Connections/CHILDREN. [/LIST] [/QUOTE]
Name
Xác nhận
Gửi đi
Diễn Đàn
Thủ thuật
Thủ thuật internet
Cyber Panel Note
Top