cacti-1.1.38 on centos 7 x86_86 with nginx

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

cacti-1.1.38 on centos 7 x86_86 with nginx

Post by nationals »

hope it can help somebody else

Code: Select all

#!/bin/sh

# disable firewalld and selinux
systemctl disable firewalld.service
systemctl stop firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
/usr/sbin/setenforce 0

# Show IP info before login
cat >> /etc/issue <<EOF

HoseName: \\n@\\o
Server IPv4: \\4{ens5}
Server IPv6: \\6{ens5}

EOF

# config the local yum source for china
if [ ! -f /etc/yum.repos.d/CentOS-Base.repo.bak ];then
  cp /etc/yum.repos.d/{CentOS-Base.repo,CentOS-Base.repo.bak}
fi
sed -i 's/^#baseurl/baseurl/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/^mirrorlist/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/mirror.centos.org/mirrors.ustc.edu.cn/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum check-update
yum makecache 
yum update -y 

reboot
Last edited by nationals on Thu Sep 06, 2018 2:21 am, edited 2 times in total.
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86

Post by nationals »

Code: Select all

#!/bin/sh

# install tools
yum install -y vim wget curl openssl NetworkManager-tui patch

# install nginx
cat > /etc/yum.repos.d/nginx.repo <<EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
gpgcheck=0
enabled=1
EOF
yum install -y nginx
systemctl start nginx.service
systemctl enable nginx.service

# php-fpm
yum install -y php-fpm rrdtool php-common php-mysql php-snmp php-ldap php-xml php-gd php-mbstring php-posix php-cli net-snmp net-snmp-utils openssl
yum install php-session php-sockets php-xml php-pcre php-dom 
systemctl enable php-fpm.service
systemctl start php-fpm.service

touch /dev/shm/php-fcgi.sock
chown apache:apache /dev/shm/php-fcgi.sock #touch /var/run/php-fpm/php-fpm.sock
chmod 777 /dev/shm/php-fcgi.sock

cp /etc/php-fpm.d/{www.conf,www.conf.bak}
sed -i '/^listen = 127.0.0.1:9000/a\listen = \/dev\/shm\/php-fcgi.sock' /etc/php-fpm.d/www.conf
sed -i 's/^listen = 127.0.0.1:9000/;listen = 127.0.0.1:9000/g' /etc/php-fpm.d/www.conf

cp /etc/{php.ini,php.ini.bak}
sed -i '/^;date.timezone/a\date.timezone = Asia/Shanghai' /etc/php.ini

mkdir -p /var/lib/php/session
chown apache:apache /var/lib/php/session

systemctl restart php-fpm.service


nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86

Post by nationals »

Code: Select all

sed -i 's/index.html/index.php index.html/g' /etc/nginx/conf.d/default.conf

Code: Select all

vim /etc/nginx/conf.d/default.conf
add the following

Code: Select all

    #pass the PHP scripts to FastCGI server listening on unix sock
    #
    location ~ \.php$ {
       root           /usr/share/nginx/html;
       fastcgi_pass   unix:/dev/shm/php-fcgi.sock;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       include        fastcgi_params;
    }

Code: Select all

systemctl restart nginx.service
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86

Post by nationals »

Code: Select all

# install mysql server
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum install mysql-server -y

Code: Select all

vim /etc/my.cnf
add the following

Code: Select all

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld] 
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

max_heap_table_size = 192M
max_allowed_packet = 16777216
tmp_table_size = 64M
join_buffer_size = 64M
innodb_buffer_pool_size = 1024M
innodb_doublewrite = OFF
innodb_additional_mem_pool_size = 96M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16

Code: Select all

systemctl enable mysqld.service
systemctl start mysqld.service
checking

Code: Select all

mysql
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

Code: Select all

mysql -u root -e "CREATE DATABASE cacti CHARACTER SET utf8mb4;"
mysql -u root -e "CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
mysql -u root -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';"
mysql -u root -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';"
mysql -u root -e "flush privileges;"

mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root mysql
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86 with nginx

Post by nationals »

Code: Select all

cd ~
wget -N https://www.cacti.net/downloads/cacti-1.1.38.tar.gz
wget -N https://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz

tar zxvf cacti-1.1.38.tar.gz
mv cacti-1.1.38/* /usr/share/nginx/html/
chown -R apache:apache /usr/share/nginx/html/

mysql -u cactiuser -pcactiuser cacti < /usr/share/nginx/html/cacti.sql
sed -i "s/'\/cacti\/'/'\/'/g" /usr/share/nginx/html/include/config.php

yum install gcc autoconf automake binutils libtool cpp glibc-headers kernel-headers \
  glibc-devel mysql-devel net-snmp-devel openssl-devel dos2unix help2man -y

tar zxvf cacti-spine-1.1.38.tar.gz
cd cacti-spine-1.1.38
sh bootstrap
./configure
make && make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine

cp /usr/local/spine/etc/{spine.conf.dist,spine.conf}
Last edited by nationals on Thu Sep 06, 2018 2:19 am, edited 1 time in total.
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86

Post by nationals »

Code: Select all

touch /etc/cron.d/cacti
echo "*/5 * * * * apache /usr/bin/php /usr/share/nginx/html/poller.php > /dev/null 2>&1" > /etc/cron.d/cacti
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti-1.1.38 on centos 7 x86_86

Post by nationals »

secure mysql

Code: Select all

mysql_secure_installation
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests