用lnmp安装,有兴趣同学可以参考下

Lepus · sbwfnhn · 于 3个月前发布 · 313 次阅读

安装nginx脚本

#!/bin/bash
yum -y install pcre* pcre-devel gcc gcc-c++ openssl openssl-devel autoconf automake
useradd -M nginx -s /sbin/nologin
read -p '按回车开始下载nginx,按ctrl+Z退出'
wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar -zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-debug --user=nginx --group=nginx --error-log-path=/usr/local/nginx/logs/error.log --with-http_realip_module --with-http_addition_module   --with-http_realip_module  --with-stream
make
make install
mkdir -p /usr/local/nginx/logs
#chmod +w /usr/local/nginx/logs
chown -R nginx:nginx /usr/local/nginx
nginx_line=$(grep -n "^}$" /usr/local/nginx/conf/nginx.conf | awk -F : '{print $1}' | tail -1)
echo $nginx_line
sed -i "$nginx_line i\    include /usr/local/nginx/conf/conf.d/*.conf;" /usr/local/nginx/conf/nginx.conf
echo 'include /usr/local/nginx/conf/conf.d/*.tcp.stream;' >> /usr/local/nginx/conf/nginx.conf
mkdir -p /usr/local/nginx/conf/conf.d/

[root@localhost local]# cat /usr/local/nginx/conf/conf.d/php.conf

server {
   listen   80;
   server_name 192.168.56.107;
   root /opt/lepus_php;
   location / {
    index index.php;
    try_files $uri $uri/ /index.php$is_args$args;
    }

location ~ \.php {
        fastcgi_pass 127.0.0.1:9000;
        include /usr/local/nginx/conf/fastcgi_params;
        fastcgi_index index.php;

        set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
    }

   #location ~ \.php$ {
   #   include /usr/local/nginx/conf/fastcgi_params;
   #   fastcgi_pass 127.0.0.1:9000;
   #   fastcgi_index index.php;
   #   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   #   #fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
   # }
}

安装php yum install -y php php-mysql php-fpm php-mcrypt php-mbstring php-gd php-devel php-cli php-soap php-xml php-dom

安装mysql


#!/bin/bash
yum -y install  gcc gcc-c++  autoconf automake zlib*  ncurses-devel  libtool-ltdl-devel* make cmake
yum -y install perl-Module-Install
yum -y install ncurses-devel
yum -y  install glibc*
yum install libmcrypt*
yum -y install libaio
grep -i numa /var/log/dmesg
#dmesg | grep -i numa
#No NUMA configuration found

read -p '按回车开始下载,ctrl+z结束'
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql

mysql_user=$(cat /etc/passwd | grep mysql | awk -F: '{print $1}')
if [[ $mysql_user = 'mysql' ]]; then
    echo 'useradd: user 'mysql' already exists'
else
    useradd -M mysql -s /sbin/nologin
fi

mkdir -p /home/mysql/data/
cd /usr/local/mysql
chown -R mysql:mysql .

cd /home
chown -R mysql:mysql mysql

#添加环境变量
test_profile=`cat /etc/profile | grep mysql/bin`
if [[ -z $test_profile ]]; then
    echo "export PATH=\$PATH:/usr/local/mysql/bin" >> /etc/profile
    source /etc/profile

    cat /proc/sys/vm/swappiness
    sysctl vm.swappiness=1
    echo "vm.swappiness=1" >> /etc/sysctl.conf
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    setenforce 0
    getenforce
fi

#复制mysql启动文件到/etc/init.d/
\cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
\cp /usr/local/mysql/support-files/my-default.cnf   /etc/my.cnf

vim /etc/my.cnf

[mysqld]
#explicit_defaults_for_timestamp=false
lower_case_table_names=1
basedir=/usr/local/mysql
datadir=/home/mysql/data
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER
#sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#innodb_buffer_pool_size=1G
master-info-repository=TABLE
relay-log-info-repository=TABLE
long_query_time=1
slow_query_log=ON
slow-query-log-file=/home/mysql/data/slow.log
skip-ssl
secure_file_priv='/home'
log-error=/home/mysql/data/error.log

登录mysql改密码 mysql -p #5.7默认root密码在log-error=/home/mysql/data/error.log文件里

安装python

yum install epel-release
yum install python-pip
pip install --upgrade pip
yum install MySQL-python -y

mysql -p

create database lepus default character set utf8;
grant select,insert,update,delete,create on lepus.* to 'lepus'@'localhost' identified by '123456';
grant select,insert,update,delete,create on lepus.* to 'lepus'@'127.0.0.1' identified by '123456';     
flush privileges;

cd Lepus_v3.8_beta/ mysql -p lepus < sql/lepus_table.sql
mysql -p lepus < sql/lepus_data.sql

cd python/ chmod +x install.sh ./install.sh

修改配置文件

# cd /usr/local/lepus/
# vim etc/config.ini
[monitor_server]
host="127.0.0.1"
port=3306
user=" lepus"
passwd="123456"
dbname="lepus"

启动Lepus (可选) 此时,你可以执行启动命令启动lepus采集进程 [root@ebs-cloud lepus]# lepus start nohup: 把输出追加到"nohup.out" lepus server start success 但是因为没有添加主机,所以查看日志会看到如下提示,属于正常提示。您也可以在部署完Lepus WEB控制台后再进行启动。 [root@ebs-cloud lepus]# tail -f logs/lepus.log

启动nginx与php-fpm

systemctl enable php-fpm
systemctl start php-fpm

mkdir /opt/lepus_php/ cd Lepus_v3.8_beta/ cp -R php/* /opt/lepus_php/

/usr/local/nginx/sbin/nginx -t /usr/local/nginx/sbin/nginx

vim /opt/lepus_php/application/config/database.php

$db['default']['hostname'] = '127.0.0.1';
$db['default']['port']     = '3306';
$db['default']['username'] = 'lepus';
$db['default']['password'] = '123456';
$db['default']['database'] = 'lepus';
$db['default']['dbdriver'] = 'mysql';

通过浏览器输入IP地址或域名打开监控界面,即可登录系统。.默认管理员账号密码admin/Lepusadmin登录后请修改管理员密码,增加普通账号


共收到 0 条回复
没有找到数据。
回复本帖 (需要登录)