Language/PIWIK

piwik 설치

아르비스 2016. 1. 6. 09:09

Piwik은 Open Source Web analytics 라는 웹로그 분석기 임.


https://piwik.org/


https://piwik.org/download/


필요 S/W

* MySQL

* PHP 5.5 or later

* Web Hosts (Apache, Nginx, IIS, etc.)


[PIWIK MySQL 설치]

[root@www ~]# yum -y install mysql-server

[root@www ~]# vi /etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# add

character-set-server=utf8

 

 

 [root@www ~]# /etc/rc.d/init.d/mysqld start

mysqld ()를 시작 중:                                     [  OK  ]

 

[root@www ~]# chkconfig mysqld on

[root@www ~]# mysql_secure_installation

 

[root@www ~]# mysql -u root –p

 

mysql> select user,host,password from mysql.user;

+-------+-----------+-------------------------------------------+

| user  | host      | password                                  |

+-------+-----------+-------------------------------------------+

| root  | localhost | *A4B6157319038724E3560894F7F932C8886EBFCF |

| root  | 127.0.0.1 | *A4B6157319038724E3560894F7F932C8886EBFCF |

+-------+-----------+-------------------------------------------+

2 rows in set (0.00 sec)

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

+--------------------+

2 rows in set (0.00 sec)

 


mysql> create database piwik;

Query OK, 1 row affected (0.00 sec)

 

mysql> grant all privileges on piwik.* to piwik@'%' identified by 'piwik';

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> exit

Bye

 

 

[PHP 설치]

[root@www ~]# yum -y install php-pdo php-gd php-xml

[root@www ~]# vi /etc/php.ini

# line 457: increase memory limit

memory_limit = 512M

 

<PHP 설치>

Ø  yum -y install php php-mbstring php-pear

Ø  vi /etc/httpd/conf/httpd.conf

# line 402: add file name that it can access only with directory's name

DirectoryIndex index.html index.php

Ø  [root@www ~]# vi /etc/php.ini

# line 946: set you timezone

date.timezone = "Asia/Tokyo"

Ø  [root@www ~]# /etc/rc.d/init.d/httpd restart

Stopping httpd: [ OK ]

Starting httpd: [ OK ]

 

PHP 그 외 필요요소 설치

Ø  yum -y install php-devel php-gd php-mbstring php-pear php-pecl-mailparse php-mysql mod_ssl

정상설치확인 : which php

 

아파치 php 설정에 다음 줄 추가

Ø  Vi /etc/httpd/conf.d/php.conf

AddHandler php5-script .php

AddType text/html .php

AddType application/x-httpd-php .php .html .htm .inc   ß추가

 

Ø  /etc/rc.d/init.d/httpd restart

 

[mysql uninstall]

Yum remove mysql-server

 

 

---------------------------------------------------------

[PHP 수동설치]

Download PHP file : http://php.net/downloads.php

Ø  tar -zxvf php-5.6.3.tar.gz

cd /root/scr/php-5.6.3/

[root@php-5.6.3]# ./configure \

--prefix=/usr/local/php \

--with-libdir=lib64 \

--with-apxs2=/usr/local/apache/bin/apxs \

--with-openssl=shared \

--enable-sysvshm=yes \

--enable-debug=no \

--enable-cli \

--with-iconv \

--with-png-dir \

--with-zlib-dir \

--with-gd \

--enable-gd-native-ttf \

--with-jpeg \

--enable-exif \

--with-freetype \

--enable-ftp \

--enable-mbstring \

--enable-sockets \

--enable-wddx \

--with-freetype-dir \

--enable-bcmath \

--enable-exif \

--enable-calendar \

--with-libxml-dir \

--with-xmlrpc \

--with-mysqli \

--with-pdo-mysql \

--with-mysql-sock=/var/mysql/mysql.sock \

--with-gettext

[root@php-5.6.3]# make && make install

 

[PHP.ini 설정]

[root@php-5.6.3]# cp php.ini–production /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/register_globals = Off/register_globals = on/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/upload_max_filesize = 2M/upload_max_filesize = 8M/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/allow_url_fopen = On/allow_url_fopen = Off/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/short_open_tag = Off/short_open_tag = On/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/;data.timezon = /data.timezone = Asia\/\Seoul/g" /usr/local/php/lib/php.ini

 

[root@php-5.6.3]# perl -pi -e "s/memory_limit = 128M/ memory_limit = 512M/g" /usr/local/php/lib/php.ini

 

[root@cl-EFSS-linux14 bin]# PATH=$PATH:./usr/local/php/bin

[root@cl-EFSS-linux14 bin]# echo $PATH

/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:.:/usr/local/php/bin

 

[root@cl-EFSS-linux14 bin]# vi /usr/local/apache/conf/httpd.conf

LoadModule php5_module  modules/libphp5.so

AddHandler php5-script  .php

 

DirectoryIndex index.html index.php

 

AddType text/html   .php

 

AddType application/x-httpd-php-source phps

[root@cl-EFSS-linux14 bin]# /usr/local/apache/bin/httpd restart

 

 

[piwik] 설치

1. http://설치서버/piwik/ 접속

2. next > next

3. 데이터베이스 정보 입력(piwik 자체Data 저장용 mysql)

4.  ID: piwik,

PW : piwik,

Database : piwik

테이블접두어 : piwik_db

 

 

 

Folder 권한 변경

chown -R nobody:nobody /usr/local/apache/htdocs/piwik
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp/assets/
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp/cache
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp/logs/
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp/tcpdf/
chmod -R 0755 /usr/local/apache/htdocs/piwik/tmp/templates_c/

 

[Error]

Temp folder 생성 필요

/usr/local/apache/htdocs/piwik/tmp/cache/tracker/" does not exist and could not be created.

Writable 권한 필요

"/usr/local/apache/htdocs/piwik/tmp/cache/tracker/" is not writable.

 

 

-       HTTPS 관련

Piwik cannot use HTTPS to update, it will fall back to the insecure HTTP update. Check that CURL or allow_url_fopen is supported and that the openssl PHP extension is installed: http://piwik.org/faq/troubleshooting/faq_177/.

Ø  vi php.ini

extension=php_openssl.dll

 (comment 제거)

 

 (기타)

Drop User

DROP USER ‘cobub’@’localhost’;

flush privileges;

 

 

 

[piwik proxy 설정]

1. proxy 사용시 error 처리\

[error]

에러: 양식 보안 실패, 양식을 새로고침하여 쿠키가 활성화되어 있는지 확인하세요. 프록시 서버를 사용하는 경우라면, 호스트 헤더에Piwik configure에서 프록시 헤더를 수락하고 전달해야합니다. 또한 리퍼러 헤더가 올바르게 전송되는지 확인합니다.

수정방법 > 아래 내용 추가

Ø  vi config/config.ini.php

[General]

proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"

proxy_host_headers[] = "HTTP_X_FORWARDED_HOST"