nginx+mysql+php+cacti+rrdtool全方位架构急速版

2024-05-18 02:00:04

时间调整:

/usr/sbin/ntpdate stdtime.sinica.edu.tw
centos5.2 系统测试OK
新机全配置步骤及方法:
1、给系统刷新下yum 主件加速yum安装的速度;
yum -y install yum-fastestmirror.noarch
引用
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID*****
错误 执行rpm --import /etc/pki/rpm-gpg/RPM*解决再用解决!
2、更新下系统必须组件;
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 ../
密码修改及帐户设置:
service mysqld restart
mysql -uroot -p
登入执行:
GRANT ALL PRIVILEGES ON *.* TO
JackHuang@192.168.1.101IDENTIFIED BY 'JackHuang2009' WITH GRANT OPTION; (注意:192.168.1.101上面使用了Navicat Lite for MySQL管理软件的windows服务器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;
开机自动启动服务:
vim /etc/rc.local
ulimit -SHn 65535
/user/web/php/sbin/php-fpm start
/user/web/nginx/sbin/nginx
优化Linux内核参数:
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
最后执行生效修改生效命定:
/sbin/sysctl -p
OK 以上mysql+nginx+php安装就结束了,我们可以在/user/web/htm文件夹下,
建立文件
vim index.php
内容为:
<?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
登入执行:
create database cacti;
退出执行:
/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
填写自己设置的连接数据库的帐户密码
加入
crontab -u root -e 
*/5 * * * * /user/web/php/bin/php /user/web/html/cacti/poller.php > /dev/null 2>&1
1、cacti监控nginx服务:
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管理面板导入:
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监控apache服务:
对Apache Server Status的启用
对Apache的状态管理的模块是LoadModule status_module modules/mod_status.so,所以这个需要有
然后打开下面的配置
ExtendedStatus On
配置Apache Server Status的权限
<location /server-status>
         SetHandler server-status
         Order Deny,Allow
         Allow from 127.0.0.1
</location>

本文出自 “JackHuang-技术文档” 博客,请务必保留此出处http://himin6036.blog.51cto.com/1405096/288843

转载于:https://blog.51cto.com/zener/325123

nginx+mysql+php+cacti+rrdtool全方位架构急速版相关推荐

  1. php mysql 论坛 源码_LNMP架构的搭建(linux+nginx+mysql+php源码安装 )+Discuz论坛的搭建...

    主机环境 redhat6.5 64位 实验环境 服务端 ip172.25.29.1  nginx+mysql+php 安装包   nginx-1.10.1.tar.gz mysql-boost-5.7 ...

  2. 伍哥原创之安装nginx,mysql,php-fpm,redis

    为什么80%的码农都做不了架构师?>>>    [伍哥原创] v1.0 2012-6-4 初稿 v1.1 2012-6-5 更新,增加php-redis模块的编译安装 [正文] 本文 ...

  3. linux 安装nginx php mysql 配置文件在哪_linux下 php+nginx+mysql安装配置

    我主要是用来安装php,以及nginx和php的交互. 一 安装插件 可以选择YUM安装或者源码编译安装gccgcc-c++zlib pcre pcre-devel libevent libevent ...

  4. centos 5.6安装nginx+mysql+php(php-fpm)+phpmyadmin总结

    花了3天的时间配置了nginx+mysql+php(php-fpm)+phpmyadmin因为开始根本就没有自己动手去配置过文件,所以自己研究一天时间,在这段时间遇到很多问题,有些时候还搞不清楚fas ...

  5. MySQL集群高可用架构

    MySQL集群高可用架构 前言 高可用架构对于互联网服务基本是标配,无论是应用服务还是数据库服务都需要做到高可用.对于一个系统而言,可能包含很多模块,比如前端应用,缓存,数据库,搜索,消息队列等,每个 ...

  6. 阿里云 Ubuntu PHP7 Nginx Mysql 开发环境搭建

    记录下在阿里云搭建 PHP7 开发环境 安装 nginx sudo apt-get update sudo apt-get install nginx安装完成后会自动开启,通过命令查看 # ps -a ...

  7. Spring Boot 2.0(五):Docker Compose + Spring Boot + Nginx + Mysql 实践

    我知道大家这段时间看了我写关于 docker 相关的几篇文章,不疼不痒的,仍然没有感受 docker 的便利,是的,我也是这样认为的,I know your felling . 前期了解概念什么的确实 ...

  8. Win10+Python+Django+Nginx+MySQL开发教程及实例(1)——开发环境搭建

    Win10+Python+Django+Nginx+MySQL开发教程及实例 PaulTsao 本教程共有三篇内容: 第一篇:Win10+Python+Django+Nginx+MySQL 开发环境搭 ...

  9. 转】MYSQL性能调优与架构设计之select count(*)的思考

    原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/page/5/ 感谢! Posted: Feb 7, 2013 Tag ...

最新文章

  1. 0x41.数据结构进阶 - 并查集
  2. 进程间的通信方式(二):管道Pipe和命令管道FIFO
  3. 选带傅里叶变换(zoom-fft)
  4. 【GDOI2016模拟3.11】历史
  5. 使用VoiceFliter-Lite改进设备上的语音识别
  6. 详解 | 引起电源模块发热的4个主要原因
  7. 【牛客 - 551D】CSL 的字符串(单调栈,思维)
  8. 职中心得体会300字高一计算机,职业高中毕业的自我鉴定范文300字
  9. 使用Linux进行c或c++编程
  10. STM32工作笔记0083---UCOSIII中断和时间管理
  11. day08.4-samba共享网盘服务
  12. 有同学问我:Fetch 和 Ajax 有什么区别?
  13. php 放大镜代码,jQuery实现放大镜效果实例代码_jquery
  14. Ubuntu 安装gcc/g++
  15. k3cloud是java,JAVA调用K3Cloud接口新增报“调用目标发生异常
  16. Vb自动读取本地HTML,VB读取网页内容 方法汇总 - mystic的个人空间 - 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园...
  17. python爬取上证50ETF成分股信息
  18. java选择,智力,数量,推理
  19. SCVMM 2012 R2---安装Hyper-V Server 2012 R2主机服务器
  20. 2015陈奕迅another eason‘s life演唱会歌单

热门文章

  1. 自然语言处理(2)-信息论基础
  2. C++静态类型成员变量的初始化顺序(单例模式)
  3. H.265:网络视频的高清时代
  4. 项目经理常见的沟通坏习惯
  5. 社会生活、工作中的著名法则
  6. springCloud - 第10篇 - 服务间调用追踪 (zipkin 的使用)
  7. 【案例】图片无缝轮播效果
  8. STS的安装教程-鹏鹏
  9. 16.看板方法——三类改进机会笔记
  10. webAPI token验证