1.安装php
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
或者
安装php
yum install php php-gd php-soap php-mbstring php-xmlrpc php-dom php-fpm -y
2.php和nginx整合
修改/etc/php-fpm.d/www.conf文件中user和group,与ningx.conf中user一致
3.启动php-fpm
service php-fpm start
4.修改nginx配置
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000; //本地9000端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
4.cd /usr/share/nginx/html && vim index.php
<?php phpinfo();?>
5.访问
http://ip/index.php
6.安装nginx-rrd依赖
yum install perl rrdtool perl-libwww-perl libwww-perl perl-rrdtool -y
7.下载解压nginx-rrd
wget http://soft.vpser.net/status/nginx-rrd/nginx-rrd-0.1.4.tgz
tar -zxvf nginx-rrd-0.1.4.tgz
cd nginx-rrd-0.1.4
8.修改配置文件
cp usr/sbin/* /usr/sbin
cp etc/nginx-rrd.conf /etc
cp html/index.php /usr/share/nginx/html
修改vim /etc/nginx-rrd.conf
RRD_DIR="/usr/share/nginx/html/nginx-rrd"
WWW_DIR="/user/share/nginx/html"
新建定时任务 crontab -e
* * * * * /bin/sh /usr/sbin/nginx-collect
*/1 * * * * /bin/sh /usr/sbin/nginx-graph
查看定时任务
crontab -l
观看定时任务执行
tail -f /var/log/cron
9.ab压测
yum -y install httpd-tools
ab -n 10000 -c 10 http://ip/index.html
10.查看
http://ip/index.php