跳转到主要内容
你行网

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超级缓存。
  • 登录或注册以发表评论
  • 75 次浏览
来源
https://www.uxlinux.com/how-to-optimize-apache-php-and-mysql-performance-for-1gb-ram-vps/
内容类型分类
服务器与运维
文章归类
Linux

文章标签

  • apache

评论

最新文章

  • 内容审核通知 content_moderation_notifications 模块简介
  • 调度程序 scheduler 模块简介
  • 工作流当中的草稿,已发布,很好理解,已归档是怎么理解。
  • 你行网 https://www.dwoke.com seo 关键词
  • brew 是什么命令
  • drupal 9 或 drpal 10 国内内容分享模块 Will Nice social share
  • Views Slideshow - Views Vanilla JavaScript Slideshow (VVJS) 简介和安装方法
  • drupal 11 安装statistics 统计模块
  • drupal11 扩展中找不到Statistics模块
  • drupal11 设置中的“总结摘要”和“切边的” 有什么区别

标签云

adsenseAIapacheaptbadblocksbreadcrumbbrewcentoscertbotckeditorcommandcomposercookiecsharpCSScurlC语言DDEVdiffdnsdockerDreamweaverDrupaldrupal 7drupal 8drupal 9drupal10drupal 11drushExcelfirewalldfirmwareflameshotformgimpgitgzipHTMLHTML5httpdhttp验证inputipjavaJavaScriptJavaSrciptkernelKVMLinuxmavenmbstringmod_expires 模块Mysqlnerdtreenetstatnetworknginxnpmpasswordphpphpmyadminphp扩展RFIDRSSselinuxSEOsharesimple_adsensesshsslStatisticssuperfishsurroundtagcloudstitleubuntuuploadprogressvimVPNVUEWireGuardwpsxdebugyoutubeyumzip主题(theme)二进制五笔分类术语压缩解压哈希值声音字段密码工作流快捷键摄影权限果树种植标签优化模块(module)源地址版本号电子秤电脑基础电脑技巧短信验证端口简介算法网站备份网站运营翻译英语表单视图(views)计算机基础赚钱超五类线网线邮件验证重定向重定向,301错误颜色

相关文章

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

关于我们

  • 你行网简介
  • 关于我们
  • 版权声明

网站相关

  • 社区论坛
  • 网址导航
  • 网站地图
  • 联系我们

友情链接

  • 英文学习

友情链接2

  • drupal 大学
  • 水滴间
  • 爱码网
  • Apache

友情链接3

  • MySQL
  • php
  • drupalcode

友情链接4

  • Drupal 中国
  • Drupal 老葛
  • 宁浩网
  • drupal 台湾
Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号-1