Install lamp and piwik online under Centos 6.8

Record the process of installing the environment:

 

1. Install Apache components

Since CentOS has encapsulated Apache, run the installation directly.

If you want to know whether your server has Apache installed, you can cd to the /etc/rc.d/init.d/ directory to see if there is httpd .


Use httpd -v to see the installed version of httpd


Use rpm -qa | grep httpd to see if httpd is installed


Use ps -ef | grep httpd to view the process of httpd

 

Use service httpd status to view the running status of httpd

 

Use service httpd start to start httpd

 

Use service httpd stop to stop httpd.

 

Next, install Apache.

Run the installation directly:

[root@localhost /]# yum install httpd

Configure the system to start Apache with the system:

[root@localhost /]# chkconfig --levels 235 httpd on

After the configuration is complete, start Apache:

[root@localhost /]# /etc/init.d/httpd start

 

At this point, when the browser accesses the Apache server, an error will be reported:

httpd: Could not reliably determine the server's fully qualified domain name

Solution:

Find the apache configuration file, vi /etc/httpd/conf/httpd.conf , release the #ServerName localhost:80 comment, and then restart the Apache service.

 

Note: The default root directory of Apache in CentOS is /var/www/html, and the configuration file is /etc/httpd/conf/httpd.conf. Additional configuration is stored in the /etc/httpd/conf.d/ directory.

 

2. Install MySQL

Enter the following command to install:

[root@localhost /]# yum install mysql mysql-server

After the installation is complete, let MySQL start automatically with the system:

[root@localhost /]# chkconfig --levels 235 mysqld on

Start MySQL:

[root@localhost /]# /etc/init.d/mysqld start

After the startup is complete, you can modify the mysql password, which will not be discussed here.

 

3. Install PHP

Enter the following command to install: [root@localhost /]# yum install php

Restart the Apache service:

[root@localhost /]# /etc/init.d/httpd restart

此时,若要测试PHP信息,可以在/var/www/html/目录下,新建一个php.info文件,文件编辑:<?php phpinfo();?>。编辑完成之后,在浏览器输入:http://127.0.0.1/php.info,即可查看。

 

四、将 PHP 模块和 MySQL 模块关联起来

要正常工作,还需要将PHP和MySQL关联起来。

搜索模块:

[root@localhost /]# yum search php

安装相关模块:

[root@localhost /]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

重启 Apache 使之生效:

[root@localhost /]# /etc/init.d/httpd restart

 

此时,再次刷新php.info,就能看到相关MySQL的信息。

 

五、安装Piwik

在安装piwik之前需要调试好数据库,进入mysql创建数据库:

mysql> CREATE DATABASE piwik;

mysql> use databasename;

mysql> create table tablename( id int not null primary key );

 

接下来,就可以进行piwik的安装了。参考地址:http://piwik.org/docs/installation/

在/var/www/html目录下,新建文件夹:piwik,然后将从piwik官网下载的压缩包解压呀上传到piwik文件夹下,然后重启Apache服务器。

 

最后就是5分钟Piwik安装,具体请参照官网流程。

 

六、PHP版本升级

在安装Piwik的过程,有遇到,PHP版本较低,需要高版本的PHP才能正常运行。这时就需要升级PHP版本。

查看当前PHP版本

[root@localhost /]# php -v

 

检查当前PHP的安装包

[root@localhost /]# yum list installed | grep php

 

查看yum源上能用的PHP资源包[root@localhost /]# yum list php*

 

移除当前PHP的安装包,否则容易起冲突

[root@localhost /]# yum remove php*

 

加载第三方yum源,epel及remi源(此时,需要注意自己的Cent OS版本,如果是6.*的版本安装了7的yum源,那么在执行yum命令的时候,就会报错:Error: xz compression not available。这时需要先卸载该yum源(假设该yum原为:epel-release-latest-7.noarch.rpm):[root@localhost /]# yum remove epel-release  清空epel目录: [root@localhost /]# rm -rf /var/cache/yum/x86_64/6/epel/   最后再安装另一个yum源)

[root@localhost /]# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm[root@localhost /]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

 

安装PHP

[root@localhost /]# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326313434&siteId=291194637