nginx+mysql+php+cacti+rrdtool全方位架构急速版
生活随笔
收集整理的這篇文章主要介紹了
nginx+mysql+php+cacti+rrdtool全方位架构急速版
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?時間調(diào)整:
/usr/sbin/ntpdate stdtime.sinica.edu.tw centos5.2 系統(tǒng)測試OK新機(jī)全配置步驟及方法:
1、給系統(tǒng)刷新下yum 主件加速yum安裝的速度;
yum -y install yum-fastestmirror.noarch
引用
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID*****
錯誤 執(zhí)行rpm --import /etc/pki/rpm-gpg/RPM*解決再用解決!
2、更新下系統(tǒng)必須組件;
sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
sudo -s
LANG=C
yum install elfutils elfutils-devel beecrypt beecrypt-devel net-snmp net-snmp-devel lm_sensors lm_sensors-devel zlib zlib-devel libpng libpng-devel freetype freetype-devel libart_lgpl libart_lgpl-devel? tcl? tcl-devel? perl-XML-Parser freetype*
sudo -s
LANG=C
yum install fontconfig fontconfig-devel cairo cairo-devel glib glib-devel pango pango-devel intltool intltool-devel gd gd-devel net-snmp-utils php-snmp 以上yum 安裝高手自己挑選,新手照葫蘆話即可! mkdir -p /user/soft
cd /user/soft
3、安裝nginx+mysql+php;
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make
make install
cd ../ tar zxvf libmcrypt-2.5.8.tar.gz?
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../ tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../ ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../ /usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.1.38.tar.gz
cd mysql-5.1.38/
./configure --prefix=/user/web/mysql/ --sysconfdir=/etc --localstatedir=/var/lib/mysql --with-charset=gbk --with-extra-charset=all --with-low-memory --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
make && make install
/user/web/mysql/bin/mysql_install_db
/usr/sbin/useradd -M -o -r -d /var/lib/mysql -s /bin/bash -c "MySQL Server" -u 27 mysql
chown -R mysql:mysql /var/lib/mysql
chmod -R 755 /var/lib/mysql
chmod +w /user/web/mysql
chown -R mysql:mysql /user/web/mysql
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
/sbin/chkconfig --add mysqld
/sbin/chkconfig mysqld on
cp /user/web/mysql/bin/* /usr/sbin
ln -s /user/web/mysql/lib/mysql /usr/lib/mysql
ln -s /user/web/mysql/include/mysql /usr/include/mysql
cd ../
密碼修改及帳戶設(shè)置:
service mysqld restart
mysql -uroot -p
登入執(zhí)行:
GRANT ALL PRIVILEGES ON *.* TO?JackHuang@192.168.1.101?IDENTIFIED BY 'JackHuang2009' WITH GRANT OPTION; (注意:192.168.1.101上面使用了Navicat Lite for MySQL管理軟件的windows服務(wù)器IP)
修改root密碼為:"JackHuang2009"
tar zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10/
./configure --prefix=/user/web/php --with-config-file-path=/user/web/php/etc --with-mysql=/user/web/mysql --with-mysqli=/user/web/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --enable-ftp
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /user/web/php/etc/php.ini
cd ../ tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/user/web/php/bin/phpize
./configure --with-php-config=/user/web/php/bin/php-config
make
make install
cd ../ tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/user/web/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/user/web/php/bin/php-config
make
make install
cd ../ tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/user/web/php/bin/phpize
./configure --with-php-config=/user/web/php/bin/php-config --with-pdo-mysql=/user/web/mysql
make
make install
cd ../ tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../ tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/user/web/php/bin/phpize
./configure --with-php-config=/user/web/php/bin/php-config
make
make install
cd ../ 修改php.ini文件
vim /user/web/php/etc/php.ini
手工修改:查找/user/web/php/etc/php.ini中的extension_dir = "./"
修改為extension_dir = "/user/web/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下幾行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off
修改為output_buffering = On 配置eAccelerator加速PHP:
mkdir -p /user/web/eacceleratorcaches
chmod 755 /user/web/eacceleratorcaches
vi /user/web/php/etc/php.ini
按shift+g鍵跳到配置文件的最末尾,加上以下配置信息:
引用
[eaccelerator]
zend_extension="/user/web/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/user/web/eacceleratorcaches"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9" /usr/sbin/groupadd nginx
/usr/sbin/useradd -g nginx nginx vi /user/web/php/etc/php-fpm.conf
找到
<value name="display_errors">0</value>
修改為:
<value name="display_errors">1</value>
找到:
????? Unix user of processes???
修改其下面user及group用戶名稱為如下:
??????? <value name="user">nginx</value>?
??????? <value name="group">nginx</value> ulimit -SHn 65535
/user/web/php/sbin/php-fpm start tar zxvf pcre-7.9.tar.gz
cd pcre-7.9/
./configure
make && make install
cd ../ tar zxvf nginx-0.8.15.tar.gz
cd nginx-0.8.15/
bzcat ../nginx-accesskey-2.0.3.diff.bz2 | patch -p1
./configure --user=nginx --group=nginx --prefix=/user/web/nginx --with-http_stub_status_module --with-http_ssl_module? --with-http_stub_status_module --with-http_accesskey_module --with-md5=/usr/lib
make && make install
cd ../ mkdir -p /user/web/html
chmod -R 755 /user/web/html
chown -R nginx:nginx /user/web/html 修改nginx配置:
vim /user/web/nginx/conf/nginx.conf
如下引用: user? nginx;
worker_processes? 8;
error_log? logs/error.log? crit;
pid??????? logs/nginx.pid; events
{
use epoll;
worker_connections 65535;
} http {
include?????? mime.types;
default_type? application/octet-stream;
access_log? off;
sendfile??????? on;
tcp_nopush???? on;
keepalive_timeout? 65;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip? on;
gzip_min_length? 1k;
gzip_buffers???? 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types?????? text/plain application/x-javascript text/css application/xml;
gzip_vary on;
??? server {
??????? listen?????? 80;
??????? server_name? localhost;
??????? location / {
??????????? root?? /user/web/html;
??????????? index? index.html index.php;
??????? }
error_page?? 402 403 404 /missing.html;
error_page?? 500 502 503 504? /missing.html;
??????? location = /missing.html {
??????????? root?? /user/web/html;
??????? } location ~ \.php$ {
??????????? root?????????? /user/web/html;
??????????? fastcgi_pass?? 127.0.0.1:9000;
??????????? fastcgi_index? index.php;
??????????? include??????? fastcgi_params;
??????? }
??????? location ~ /\.ht {
??????????? deny? all;
??????? }
??? }
} vim /user/web/nginx/conf/fastcgi_params
如下引用: fastcgi_param? QUERY_STRING?????? $query_string;
fastcgi_param? REQUEST_METHOD???? $request_method;
fastcgi_param? CONTENT_TYPE?????? $content_type;
fastcgi_param? CONTENT_LENGTH???? $content_length; fastcgi_param? SCRIPT_FILENAME??? $document_root$fastcgi_script_name;
fastcgi_param? SCRIPT_NAME??????? $fastcgi_script_name;
fastcgi_param? REQUEST_URI??????? $request_uri;
fastcgi_param? DOCUMENT_URI?????? $document_uri;
fastcgi_param? DOCUMENT_ROOT????? $document_root;
fastcgi_param? SERVER_PROTOCOL??? $server_protocol; fastcgi_param? GATEWAY_INTERFACE? CGI/1.1;
fastcgi_param? SERVER_SOFTWARE??? nginx; fastcgi_param? REMOTE_ADDR??????? $remote_addr;
fastcgi_param? REMOTE_PORT??????? $remote_port;
fastcgi_param? SERVER_ADDR??????? $server_addr;
fastcgi_param? SERVER_PORT??????? $server_port;
fastcgi_param? SERVER_NAME??????? $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param? REDIRECT_STATUS??? 200;
開機(jī)自動啟動服務(wù):
vim /etc/rc.local ulimit -SHn 65535
/user/web/php/sbin/php-fpm start
/user/web/nginx/sbin/nginx 優(yōu)化Linux內(nèi)核參數(shù):
vim /etc/sysctl.conf
shift+G 最后面填加:
如下引用:
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =? 32768
net.core.somaxconn = 32768 net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216 net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024? 65535 最后執(zhí)行生效修改生效命定:
/sbin/sysctl -p OK 以上mysql+nginx+php安裝就結(jié)束了,我們可以在/user/web/htm文件夾下,
建立文件
vim index.php
內(nèi)容為:
<?php
phpinfo();
?>
訪問http://localhost即可查看是否OK! 配置snmp:
vim /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser? default?????? public
?????? 改為:com2sec notConfigUser?? 127.0.0.1?????? public
?????? 2、access? notConfigGroup ""????? any?????? noauth??? exact? systemview? none none
?????? 改為:access? notConfigGroup ""????? any?????? noauth??? exact? all? none? none
?????? 3、#view all??? included? .1???????? 80
?????? 將前面的 # 注釋 去掉。
保存退出 :wq
service snmpd restart tar zxvf rrdtool-1.3.9.tar.gz
cd rrdtool-1.3.9
./configure --prefix=/user/web/rrdtool --disable-tcl --disable-python
make
make install
cd ../ ln -s /user/web/rrdtool/bin/rrdtool? /usr/bin/rrdtool
ln -s /user/web/rrdtool/bin/rrdupdate /usr/bin/rrdupdate
ln -s /user/web/rrdtool/bin/rrdcgi /usr/bin/rrdcgi cd /user/soft
tar zxvf cacti-0.8.7d-cn-utf8.gz
mv cacti-0.8.7d-cn-utf8 /user/web/html/cacti
/user/web/mysql/bin/mysql -uroot -pJackHuang2009
登入執(zhí)行:
create database cacti;
退出執(zhí)行:
/user/web/mysql/bin/mysql -uroot -pJackHuang2009 cacti < /user/web/html/cacti/cacti.sql
chown -R nginx:nginx /user/web/html/cacti
chmod -R 777 /user/web/html/cacti/rra
chmod -R 777 /user/web/html/cacti/log vim /user/web/html/cacti/include/config.php
填寫自己設(shè)置的連接數(shù)據(jù)庫的帳戶密碼
加入
crontab -u root -e?
*/5 * * * * /user/web/php/bin/php /user/web/html/cacti/poller.php > /dev/null 2>&1 1、cacti監(jiān)控nginx服務(wù):
nginx編譯時允許http_stub_status_module
在conf文件添加如下:
# vi /user/web/nginx/conf/nginx.conf
location /nginx_status {
stub_status on;
access_log off;
}
重啟動
killall nginx
/user/web/nginx/sbin/nginx tar zxvf cacti-nginx.tar.gz
cp cacti-nginx/get_nginx_socket_status.pl /user/web/html/cacti/scripts/
cp cacti-nginx/get_nginx_clients_status.pl /user/web/html/cacti/scripts/
chmod 755 /user/web/html/cacti/scripts/get_nginx*
在cacti管理面板導(dǎo)入:
cacti_graph_template_nginx_clients_stat.xml
cacti_graph_template_nginx_sockets_stat.xml
檢測插件:
/user/web/html/cacti/scripts/get_nginx_clients_status.pl?http://127.0.0.1/nginx_status 2、cacti監(jiān)控apache服務(wù):
對Apache Server Status的啟用
對Apache的狀態(tài)管理的模塊是LoadModule status_module modules/mod_status.so,所以這個需要有
然后打開下面的配置
ExtendedStatus On
配置Apache Server Status的權(quán)限 <location /server-status>
???????? SetHandler server-status
???????? Order Deny,Allow
???????? Allow from 127.0.0.1
</location>
本文出自 “JackHuang-技術(shù)文檔” 博客,請務(wù)必保留此出處http://himin6036.blog.51cto.com/1405096/288843
轉(zhuǎn)載于:https://blog.51cto.com/zener/325123
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的nginx+mysql+php+cacti+rrdtool全方位架构急速版的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一粒老鼠屎
- 下一篇: 十二星座职业成功忠告