Nginx1.02 + PHP + piwik + centos5.4 build a website statistics system

Source: Internet
Author: User
Tags centos server piwik

My Sina Weibo:Http://weibo.com/freshairbrucewoo.

You are welcome to exchange ideas and improve your technology together.

 

Build a piwik website statistics system

 

    1. Build Environment

 

Operating System: centos5.4 (cannot connect to the Internet)

 

Web server: nginx1.0.2

Database: MySQL

Open-source software package: piwik

Running Environment: PHP script

    1. Build Steps

(1) install nginx1.0.2

A) download the nginx1.0.2Source codeDecompress the package

B) enter the decompressed SourceCodeConfigure with./configure

C) make and make install

D) configure the nginx. conf file and run nginx. Open the website for testing: localhost: 8080

The execution script is as follows:

# Tar zxvf nginx-1.0.2.tar.gz

# Cd nginx-1.0.2

#./Configure -- prefix =/home/piwik/nginx // you only need to specify a path in this step.

# Make & make install

#/Home/piwik/nginx/sbin/nginx // start nginx

(2) install PHP

1) install libpng

# Tar xvf libpng-1.2.10.tar.tar

# Cd libpng-1.2.10

#./Configure -- prefix =/usr/local/PNG

# Make; make install

# Ln-S/usr/local/PNG/lib/*/usr/lib/

2) install JPEG

# Mkdir/usr/local/JPEG

# Mkdir/usr/local/JPEG/bin

# Mkdir/usr/local/JPEG/lib

# Mkdir/usr/local/JPEG/include

# Mkdir/usr/local/JPEG/man

# Mkdir/usr/local/JPEG/man/Man1

# Tar xvf restart src.v7.tar.tar

# Cd jpeg-7

#./Configure -- prefix =/usr/local/JPEG -- enable-shared -- enable-static

# Make; make install

# Ln-S/usr/local/JPEG/lib/*/usr/lib/

3) install FreeType

# Tar xvf freetype-2.3.9.tar.tar

# Cd freetype-2.3.9

#./Configure -- prefix =/usr/local/FreeType

# Make; make install

4) install fontconfig

# Tar zxvf fontconfig-2.4.2.tar.gz

# Cd fontconfig-2.4.2

#./Configure -- prefix =/usr/local/fontconfig -- With-FreeType-Config =/usr/local/FreeType/bin/FreeType-config

# Make; make install

5) install GD

# Tar zxvf gd-2.0.32.tar.gz

# Cd gd-2.0.32

#. /Configure -- prefix =/usr/local/GD -- With-PNG =/usr/local/PNG -- With-JPEG =/usr/local/JPEG -- With-FreeType =/usr /local/FreeType -- With-fontconfig =/usr/local/fontconfig

# Cp/usr/local/PNG/include/PNG. H ./

# Cp/usr/local/PNG/include/pngconf. H ./

# Make; make install

6) install PHP

Downloaded to the same directory

# Tar xvf php-5.3.0.tar.bz2

# Gzip-CD php-5.3.0-fpm-0.5.12.diff.gz | patch-D php-5.3.0-p1

// Add php-5.3.0-fpm-0.5.12.diff.gz to the php-5.3.0 as a patch

# Cd php-5.3.0

#. /Configure -- prefix =/usr/local/PHP -- With-Gd =/usr/local/GD -- With-JPEG-Dir =/usr/local/JPEG -- With-PNG- dir =/usr/local/PNG -- With-FreeType-Dir =/usr/local/FreeType -- With-mysql =/usr/local/MySQL -- enable-FastCGI -- enable-FPM

Note: For nginx + PhP integration, you must enable -- enable-FastCGI and -- enable-FPM during installation.

# Make

# Make install

# Cp PHP. ini-Dist/usr/local/PHP/etc/PHP. ini

(3) Integrate nginx and PHP

To enable nginx to support PHP, You need to modify the configuration file.

1) modify the nginx. conf file and remove comments that support PHP configurations;

2) modify the PHP configuration file php-fpm.conf to make the listening port number consistent with nginx.

3) run a PHP test page

(4) install and deploy piwik

The specific installation and deployment process piwik has detailed documentation. you can install it by following the steps. errors may occur during the installation and deployment process, but there are usually prompts about how to solve the problem.

There is a step in the installation process to generate the JS Code for statistics. You need to add this code to the page for statistics and the test passes.

3. Notes

(1) When nginx is configured, the port number is changed to 8080 to prevent port conflict, and the port number must be included during access.

(2) The default PHP monitoring port is 9000, but it is used by other applications on the system.ProgramSo you also need to change the port number to 9088. Note that you need to modify both the PHP configuration file and the nginx configuration file.

(3) The JS Code must be added to every page of piwik statistics. The specific position of the Code should be added. A prompt will be prompted when installing piwik.

(4) If the root user is used to start nginx, the error 403 is forbidden during external access. This is also true If PHP is started with the root user.

4. Difficulties and experiences

(1) because the centos server to be installed and deployed does not have an Internet connection and is installed via a route, many difficulties are encountered in this process. For example, all the required software is downloaded from a local machine and then uploaded to the server (via the company intranet ). Because it is not installed online, it may cause incompatibility.

(2) When compiling and installing Development kits or software, you may encounter many libraries that are not installed, in this case, find the missing software package according to the error message and download and install it.

(3) When starting nginx or PHP, if you start with root, external access will fail. If you start with a common user, the startup may fail. There is no error message indicating the failure at this time, you need to view the log, which contains detailed error records.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.