piwik源码安装部署

一简单介绍
1.piwik介绍
Piwik是一个PHP和MySQL的开放源代码的Web统计软件,它给你一些关于你的网站的实用统计报告,比如网页浏览人数,访问最多的页面,搜索引擎关键词等等。
Piwik拥有众多不同功能的插件,你可以添加新的功能或是移除你不需要的功能,Piwik同样可以安装在你的服务器上面,数据就保存在你自己的服务器上面。你可以非常容易的插入统计图表到你的博客或是网站亦或是后台的控制面板中。安装完成后,你只需将一小段代码放到将要统计的网页中即可。
2.piwik概况
Piwik支持插件,你可以通过插件扩展Piwik的功能,或者去掉一些不需要的功能。用户的界面支持Ajax技术是可定制的,你可以轻松拖放控件,定制自己需要的报告。
使用者独立拥有自己的统计数据,而不是寄存在服务商那里,这样就可以更灵活的使用统计数据,不用担心数据丢失问题。
Piwik是安装在服务器端的统计工具,安装过程很简单,但是需要服务器支持PHP和MySQL。安装的时候上传Piwik到服务器端,然后打开浏览器,Piwik会自动运行安装,整个过程不超过5分钟。目前Piwik已支持中文
二安装
官网:https://piwik.org
我的阿里云的部署环境:

[[email protected] ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
可以比我这个版本高
由于我想安装piwik3.2版本
所以需要的环境最低是:php5.6和mysql5.7
网站服务用:apache和nginx都可以
为了方便环境管理,就在这里直接使用nginx环境
mysql官网:https://dev.mysql.com
php官网:http://php.net/
nginx官网:http://nginx.org/

源码包放在百度云盘中

百度云盘链接:http://pan.baidu.com/s/1dE3gUbB 密码:rpst

为了节省时间,我们使用glibc版本的mysql

2.1安装mysql

[[email protected] software]# mkdir -pv /home/mysql/data
[[email protected] software]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /home/mysql
[[email protected] software]# mv /home/mysql/mysql-5.7.18-linux-glibc2.5-x86_64/* /home/mysql/
[[email protected] software]# useradd -g mysql
初始化数据库
[[email protected] software]# /home/mysql/bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize

红框中的密码要牢记,一会数据库修改密码,需要用到
数据库部署
[[email protected] software]# cp /home/mysql/support-files/mysql.server /home/mysql/support-files/mysql.server.start
[[email protected] software]# vim /home/mysql/support-files/mysql.server.start

[[email protected] software]# /home/mysql/support-files/mysql.server.start start
[[email protected] software]# ln -s /home/mysql/bin/mysql /usr/bin/mysql
[[email protected] software]# vim /etc/my.cnf
如果没有my.cnf就自己添加如下内容
[mysqld]
basedir = /home/mysql
datadir = /home/mysql/data
character_set_server=utf8
init_connect=‘SET NAMES utf8‘

[client]
default-character-set=utf8

[[email protected] software]# cp /home/mysql/support-files/mysql.server.start /etc/init.d/mysqld
[[email protected] software]#chmod 755 /etc/init.d/mysqld
[[email protected] software]#service mysqld start
修改mysql初始化密码
不过不改,会有提示
You must reset your password using ALTER USER statement before executing this statement   
# 意思就是你必须重置你的密码在执行这个execute操作前

所以进入mysql后进行密码更新
[[email protected] software]#mysql -u root -p
前面出现的密码,在这里填入
mysql> SET PASSWORD = PASSWORD(‘123456‘);
mysql> grant all on *.* to ‘root‘@‘%‘ identified by ‘123456‘;
mysql> flush privileges;
完成后为了安装piwik需要创建相关数据库和权限
mysql> create database piwik; 
mysql> grant all on piwik.* to [email protected] identified by ‘123456‘;  
mysql> flush privileges;
刷新权限后,退出。

2.2安装php
[[email protected] software]# tar -zxvf php-5.6.30.tar.gz
[[email protected] software]# cd /software/php-5.6.30
[[email protected] php-5.6.30]# ./configure --prefix=/software/php --with-config-file-path=/etc --with-mysql --with-mysqli=/home/mysql/bin/mysql_config --enable-inline-optimization --enable-fpm --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets--enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear
[[email protected] php-5.6.30]#make && make install
[[email protected] php-5.6.30]#cd /software/php/etc/
[[email protected] etc]#cp php-fpm.conf.default php-fpm.conf
[roo[email protected] php-5.6.30]#cp /software/php-5.6.30/php.ini-production /etc/php.ini
[[email protected] php-5.6.30]#cp /software/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-5.6.30]#/software/php/sbin/php-fpm -t

[[email protected] php-5.6.30]#service php-fpm start
[[email protected] php-5.6.30]#netstat -ntlp | grep php-fpm

2.3安装nginx
[[email protected] software]#tar -zxvf nginx-1.10.2.tar.gz
[[email protected] software]#cd nginx-1.10.2
[[email protected] software]#./configure --user=www --group=www --prefix=/software/nginx \
--conf-path=/software/nginx/conf/nginx.conf \
--pid-path=/software/nginx/run/nginx.pid \
--lock-path=/software/nginx/lock/nginx \
--with-stream \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module
[[email protected] software]#make && make install
2.4修改nginx的配置文件,配合piwik的安装
[[email protected] ~]# cat /software/nginx/conf/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user www;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
#include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /software/nginx/conf/conf.d/*.conf;

# server {
# listen 80 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
server {
listen 80;
server_name 182.92.86.125;
root /var/www/piwik;
index index.php index.html index2.htm;

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/piwik$fastcgi_script_name;
}
}
}
nginx解析php项目

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/piwik$fastcgi_script_name;
}

[[email protected] software]#/software/nginx/sbin/nginx -t

文件正常后,启动nginx
[[email protected] software]#/software/nginx/sbin/nginx

2.4部署piwik
[[email protected] ~]#mkdir -pv /var/www/piwik
[[email protected] software]#unzip piwik.zip
[[email protected] software]#cp -r /software/piwik/* /var/www/piwik/
打开网站后报错,并提示你如何处理

[[email protected] software]# chown -R nobody:nobody /var/www/piwik
[[email protected] software]# chmod -R 755 /var/www/piwik/

修改为中文后,继续下一步,发现一个php相关的预警报错

安装提示修改php.ini
为预防某些严重问题,您必须在 php.ini 文件中加入如下几行:always_populate_raw_post_data=-1
做过这个改动之后,请重新启您的网络服务器。
修改文件 vim /etc/php.ini
加入如下几行:always_populate_raw_post_data=-1

重启服务 service php-fpm restart
此时在看正常后,下一步

填写相关的数据库内容

点击下一步却报错了,如下图

说明,数据库处理有问题,参考数据库安装管理,查看用户权限密码等

发现指定登录是没有问题的,有可能是php页面的输入写错了,重新输入看看
仍然不行,尝试放大权限看看
mysql> grant all on piwik.* to [email protected]‘%‘ identified by ‘123456‘;
Query OK, 0 rows affected, 1 warning (0.04 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
虽然通过了,但是报错告警了,说是有重复的数据库,于是点击,删掉

干掉重复的

于是正常的进入下一个环节了

继续进入下一个环节

admin
123456
然后下一个环节

下一步

<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push([‘trackPageView‘]);
_paq.push([‘enableLinkTracking‘]);
(function() {
var u="//172.16.1.225/";
_paq.push([‘setTrackerUrl‘, u+‘piwik.php‘]);
_paq.push([‘setSiteId‘, ‘1‘]);
var d=document, g=d.createElement(‘script‘), s=d.getElementsByTagName(‘script‘)[0];
g.type=‘text/javascript‘; g.async=true; g.defer=true; g.src=u+‘piwik.js‘; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
将代码给前端处理加入,就好了,完活了

代码部署完成后,就可以看到效果了
有时你会看到这个,直接点升级就好了

升级后效果如下

可以选择打赏,有钱的大人可以给点
继续后,进入正式界面

和前端配合后,就可以看到效果 了

时间: 2024-08-30 09:22:28

piwik源码安装部署的相关文章

nginx的源码安装部署

Nginx安装:源码安装 添加普通用户账号来运行nginx:useradd nginx -M -r -s /sbin/nologin 安装依赖包yum install -y gcc pcre-devel openssl-devel 解压并安装Nginx:wget http://nginx.org/download/nginx-1.10.3.tar.gztar xvf nginx-1.10.3.tar.gz cd nginx-1.10.3./configure --user=nginx \--gr

puppet源码安装部署

一.安装环境 系统环境 CentOS release 6.8 (Final) 2.6.32-642.1.1.el6.x86_64 编译环境 gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 二.源码编译Puppet 步骤1 Ruby的安装 wget https://codeload.github.com/ruby/ruby/zip/ruby_1_8_7 unzip ruby-ruby_1_8_7.zip cd ruby-ruby_1_8_7

CentOS6.8源码安装部署Zabbix3.4.5

本文档主要介绍CentOS6.8在lamp环境下安装以及部署Zabbix3.4.5(注:本文部署环境为 php-5.6.23 + mysql-5.6.24 + httpd-2.2.15 + CentOS6.8) 基本流程: 1.准备编译环境 2.yum源配置并且安装php和Apche的所需包 3.mysql服务的启动和创建zabbix账号 4.下载zabbix3.4.5安装包以及安装 5.zabbix客户端安装 步骤一:准备编译环境 系统版本说明 [[email protected] tools

HYAppFrame(WinForm框架源码)安装部署指南

HYAppFrame是一款基于Win form的应用程序框架,包含服务器Web Service.主程序框架.组织架构.权限控制.菜单导航.基础数据.系统参数.日志管理.定时任务等. 项目地址:http://sourceforge.net/u/chinahysoft/profile/ 0获取安装包 压缩包内容如图1-1所示.将HYAppFrame.zip解压缩,例如解压缩至C:\HYAppFrame. 图1-1 1安装数据库脚本 1.1新建数据库 打开SQL Server ManagementSt

LAMP环境部署:Apache源码安装+MySQL二进制安装+PHP源码安装+Nginx源码安装

Apache 版本:2.2.27 MySQL 版本:5.5.54-linux2.6-x86_64PHP 版本:5.3.27一.源码安装Apache1.首先安装上传工具2.上传LAMP环境所需安装包3.解压所有安装包4.安装Apache依赖包5.创建安装目录6.配置安装文件./configure \ #./configure 是用来生成Makefile文件用于编译安装 --prefix=/application/apache-2.2.27 \ #指定安装目录--enable-deflate \ #

centos7.2源码安装openssl1.0.2

centos7.2默认是安装了opensll软件包的,但是部署个别服务时,由于版本太低.会影响服务的正常部署.只能使用源码安装提高openssl软件版本. 因为之前有openssl软件包,所以要先移除之前版本: 删除旧版本: yum remove -y openssl openssl-devel 源码安装openssl需要perl环境编译,如果没有perl环境还是需要安装: yum -y install perl perl-devel 现在新版本openssl: wget https://www

php源码安装

我是将下载好的软件包放到虚拟机 /home目录下,虚拟机是centos6.4 如果想了解nginx源码安装http://blog.csdn.net/zkg510168343/article/details/43703635 mysql源码安装 http://blog.csdn.net/zkg510168343/article/details/43284071 PHP安装前准备,软件包下载地址 libmcrypt包 http://sourceforge.net/projects/mcrypt/fi

zabbix源码安装,自定义监控205的用户数,有触发器但没有邮件报警

zabbix源码安装,自定义监控205的用户数,有触发器但没有邮件报警 监控端配置:(192.168.4.5) 1基础环境:(实验环境可以关闭防火墙,但生产环境不能关闭,否则不安全,要设置相应规则) [[email protected]桌面]# /etc/init.d/iptables stop [[email protected]桌面]# setenforce 0 2搭建lamp平台,(它运行在lamp平台上) [[email protected]桌面]# yum -y install htt

源码安装mysql5.6.20&&mysql主从设置(多实例做多个主从)

一.源码安装mysql5.6.20 1.编译环境安装 yum install wget gcc* make openssl openssl-devel openssl-clients -y && yum groupinstall "Development Libraries" -y 2.源码下载(软件见Linux部署源码包) wget -P /usr/local/src/ http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.