[Cacti] nginx + php + cacti + mysql + php-fpm installation note
The services used include mysql nginx net-snmp php acati php-fpm and various installation packages. The installation environment is Centos6.5.
Mysql nginx is installed normally on my side, mainly because it is unfamiliar with php installation.
Net-snmp and rrdtool Installation
# yum install rrdtool net-snmp net-snmp-libs net-snmp-utils
Php and dependent packages
# yum install php php-mysql php-snmp php-xml php-gd php-pear php-common php-devel php-mbstring php-cli php-fpm
Create a mysql user and a database
mysql>create database cacti default character set utf8;mysql>GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON cacti.* TO cacti@'%' IDENTIFIED BY 'cacti#erya';mysql>flush privileges;
Install cacti
# mkdir /www# cd /www/# wget -c http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz# tar zxvf cacti-0.8.8c.tar.gz# mv cacti-0.8.8c cacti# mysql -ucacti -pcacti#erya -Dcacti < cacti/cacti.sql
Modify Database Configuration
# vim /www/cacti/include/config.php
$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "cacti#erya";$database_port = "3306";$database_ssl = false;
You need to change the time zone. Otherwise, the time axis of the drawn image is incorrect. Set php. ini.
date.timezone = Asia/Shanghai
Add nginx web users and permissions. This is not done here, but it can be modified later.
You can also set the startup mode.
Add nginx configuration, restart nginx php-fpm, etc.
server { listen 8080; server_name localhost; root /www/cacti; location /cacti { alias /www/cacti; index index.php; } location ~ ^/cacti.+\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^/cacti(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME /www/cacti/$fastcgi_script_name; include fastcgi.conf; }}
You do not understand this configuration, but you can use it.
Add scheduled task
#vim /etc/cron.d/cacti
*/5 * * * * /usr/bin/php /www/cacti/poller.php > /dev/null 2>&1
The installation is complete.
Test whether nginx and php are easy to use. Use fastcgi here, just the interface.
[root@MiWiFi-R1D html]# cat index.php
The problem here is how php is started. nginx is easy to configure fastcgi, but php containers need to be installed and re-compiled.
Continue Installation
# yum install php-fpm
This is a service and needs to be configured
Master Profile/etc/php-fpm.conf sub profile in php-fpm.d/
#/Etc/init. d/php-fpm start starting php-fpm: [OK]
Nginx configuration file
server { listen 8080; server_name localhost; root html; index index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } }
Access http: // 192.168.31.206: 8080/to view the php information.
Error
If the following error occurs:
2015/05/22 16:06:33 [error] 30521#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 523800 bytes) in /home/www/cacti/lib/adodb/adodb.inc.php on line 833" while reading response header from upstream, client: 103.254.64.163, server: localhost, request: "GET /cacti/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "124.88.61.42:8890"
It may be because the database is not initialized.