跳转到主要内容
你行网

Main navigation

  • 首页
  • Drupal
  • 编程与开发
  • 数据库
  • 操作系统与应用
  • 服务器与运维
  • 社区
User account menu
  • 登录

面包屑

  1. 首页

如何优化1GB RAM VPS的Apache,PHP和MySQL性能

由 hrs, 3 七月, 2022

访客,特别是David T.提出了许多关于如何优化Apache,php和MySQL / Mariadb服务器的请求,这些服务器安装在具有1gb RAM的VPS服务器上,这样的1 GB RAM vps对于单个应用程序来说足够强大,并且为了避免OOM(内存不足)并从中获取汁液,需要进行优化。

Apache的优化:

优化安装在1gb VPS上的Apache,建议使用Apache MPM worker作为前叉:-

Centos/RHEL:

在 Centos 下 在编辑器中打开此文件:

nano /etc/httpd/httpd.conf

并在 httpd.conf 的末尾添加此配置:

KeepAlive Off
<IfModule prefork.c>
   StartServers        6
   MinSpareServers     5
   MaxSpareServers     15
   ServerLimit         256
   MaxClients          256
   MaxRequestsPerChild 3000
</IfModule>

然后重新启动Apache服务器:

service httpd restart

乌班图 :

在 Ubuntu 下 在编辑器中打开此文件:

nano /etc/apache2/apache2.conf

在apache2.conf文件下查找并添加/更改此配置:

<IfModule mpm_prefork_module>
 StartServers        3
 MinSpareServers     5
 MaxSpareServers     15
 ServerLimit         256
 MaxClients          256
 MaxRequestsPerChild 3000
</IfModule>

然后重新启动Apache服务器:

service apache2 restart

MYSQL的优化:

要优化安装在1gb VPS上的MySQL / Mariadb,您需要在my.cnf的[mysqld]下添加此配置:

[mysqld]
symbolic-links=0
skip-external-locking
key_buffer_size = 32K
max_allowed_packet = 4M
table_open_cache = 8
sort_buffer_size = 128K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
net_buffer_length = 4K
thread_stack = 480K
innodb_file_per_table
max_connections=100
max_user_connections=50
wait_timeout=50
interactive_timeout=50
long_query_time=5

在基于 Centos/RHEL 的系统上,您可以将其添加到:

/etc/my.cnf

在基于 Ubuntu/Debian 的系统上,你可以将其添加到:

/etc/mysql/my.cnf 
  • 还可以考虑将SWAP添加到您的VPS中,这将大大稳定1 GB VPS:在Linux操作系统CWP Centos WebPanel和VestaCP
    上创建和添加交换
  • 为了优化PHP,只需安装php-opcache和memcached(memcached需要由脚本支持)
  • 配置不超过 128 mb 的 PHP 内存限制。
  • 使用脚本提供的缓存系统或WordPress使用WP超级缓存。
  • 登录或注册以发表评论
来源
https://www.uxlinux.com/how-to-optimize-apache-php-and-mysql-performance-for-1gb-ram-vps/
内容类型分类
服务器与运维
文章归类
Linux

文章标签

  • apache

评论

文章标签

Excel
CSS
ubuntu
php
vim
五笔
VPN
Linux
command
drupal 8
HTML
drupal 7
centos
composer
Mysql
模块(module)
drush
Drupal
JavaSrcipt
apache
英语
drupal 9
nerdtree
荔壳风
network
果树种植
surround
drupal10
SEO
主题(theme)
更多

相关文章

  • linux-firmware 是什么,有哪些作用?
  • journalctl 的使用和简介
  • linux 网络检查命令
  • 在drupal 使用composer一次性安装多个模块
  • composer update 命令的参数列表
  • Composer 的常用命令
  • diff 是什么?
  • 如何在 CentOS 7 上使用 Certbot 独立模式检索 Let's Encrypt SSL 证书
  • certbot 安装免费ssl 证书
  • HTTP Basic Authentication HTTP 基本身份验证概述
RSS源

友情链接 网站地图 版权信息 联系我们 网址导航 社区

Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号