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 if 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
At this point, if you want to test PHP information, you can create a new php.info file in the /var/www/html/ directory, and edit the file: <?php phpinfo();?>. After editing, enter: http://127.0.0.1/php.info in the browser to view it.
Fourth, associate the PHP module with the MySQL module
To work properly, PHP and MySQL also need to be linked.
Search module:
[root@localhost /]# yum search php
Install related modules:
[root@localhost /]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Restart Apache for it to take effect:
[root@localhost /]# /etc/init.d/httpd restart
At this point, refresh php.info again, and you can see the relevant MySQL information.
5. Install Piwik
Before installing piwik, you need to debug the database and enter mysql to create the database:
mysql> CREATE DATABASE piwik;
mysql> use databasename;
mysql> create table tablename( id int not null primary key );
Next, you can install piwik. Reference address: http://piwik.org/docs/installation/
In the /var/www/html directory, create a new folder: piwik, then extract the compressed package downloaded from the piwik official website and upload it to the piwik folder, then restart the Apache server.
The last step is to install Piwik in 5 minutes. For details, please refer to the official website process.
Six, PHP version upgrade
In the process of installing Piwik, I encountered that the PHP version is lower and requires a higher version of PHP to run normally. Then you need to upgrade the PHP version.
View current PHP version
[root@localhost /]# php -v
检查当前PHP的安装包
[root@localhost /]# yum list installed | grep php
Check the available PHP resource packages on the yum source [root@localhost /]# yum list php*
移除当前PHP的安装包,否则容易起冲突
[root@localhost /]# yum remove php*
Load the third-party yum source, epel and remi source (at this time, you need to pay attention to your own Cent OS version, if the 6.* version has the 7 yum source installed, then when executing the yum command, an error will be reported: Error: xz compression not available. At this time, you need to uninstall the yum source (assuming the yum was originally: epel-release-latest-7.noarch.rpm): [root@localhost /]# yum remove epel-release Empty the epel directory: [ root@localhost /]# rm -rf /var/cache/yum/x86_64/6/epel/ and finally install another yum source)
[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
Install 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