輕量級站點的特定 apache + mysql 設定

輕量級站點的特定 apache + mysql 設定

我有一個小網站,其中設定了 Joomla 和 Moodle。看來這兩個都很慢。伺服器(CentOS 版本 5.5(最終版))是一個虛擬專用伺服器,具有約 2GB 的 RAM。我預計同時在線的人數不會超過 10-15 人(如果人數很高的話)

我可以在 apache、mysql 甚至作業系統中更改哪些設定來提高網站的效能?

如果訪客太多,我並不擔心資源會耗盡。

如果您需要更具體的數據,請發表評論,我將編輯問題。

資料庫速度:

+--------------------+----------------------+------------------+
| Data Base Name     | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| information_schema |           0.00390625 |       0.00000000 | 
| joomla             |           0.33125496 |       0.07981014 | 
| moodle             |           7.73092937 |       0.01922131 | 
| mysql              |           0.52505302 |       0.00000000 | 
| phpmyadmin         |           0.01499939 |       0.00106049 | 
+--------------------+----------------------+------------------+
5 rows in set (0.07 sec)

Apache 載入的模組:

core prefork http_core mod_so mod_auth_basic mod_auth_digest mod_authn_file mod_authn_alias mod_authn_anon mod_authn_default mod_authz_host mod_authz_user mod_authz_owner mod_authz_default mod_include mod_log_config mod_env mod_ext_filter mod_mime_magic mod_expires mod_deflate mod_headers mod_setenvif mod_mime mod_status mod_autoindex mod_info mod_negotiation mod_dir mod_alias mod_rewrite mod_cache mod_suexec mod_disk_cache mod_file_cache mod_cgi mod_version mod_php5 mod_ssl 

$ 貓 /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#don't use old password format
old_passwords=0

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links=0

#Alwaysuse the better InnoDB
default-storage-engine=InnoDB
innodb_buffer_pool_size=512

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

我在找具體設定更改這將提高伺服器的速度。

答案1

Mysql總是喜歡RAM。將(至少大多數)表(joomla 和moodle 中的表,而不是其他表)轉換為InnoDb 格式並增加使用的記憶體也將有助於提高速度。 innodb_buffer_pool_size是mysql配置。使用的預設大小只有8MB - 如果您的資料庫真的那麼小(坦白說,如果它實際上被使用的話,我會對這麼小感到有點驚訝),那麼即使給它16MB 也會有所不同,而且無論如何,我更有可能只給它 512MB 的 innodb_buffer_pool_size 。由於所有資料庫內容都在記憶體中,因此幾乎不再需要磁碟。

安裝中偵錯工具可以讓您逐行逐行找出網站的哪些部分速度較慢。 網路研磨將解析 Xdebug 的輸出並向您展示。

要了解更多信息,您需要收集一些有關伺服器正在執行的操作的統計信息 - 例如運行 collcted ,然後查看正在生成的圖表。即使只是查看“top”的輸出,在命令列上運行也可以幫助您了解正在發生的情況。

相關內容