Ubuntu 14.04下Zabbix2.4.5 源码编译安装

Ubuntu14.04 LTS  MySQL 5.6 php-fpm nginx 1.8.0

第一部分,php+mysql+nginx组件安装

1、系统更新

sudo apt-get update && sudo apt-get upgrade

2、安装php-fpm

zabbix的web前端是用php写成的,需要php来运行

sudo apt-get install php-fpm (当然也可以源码编译php)

3、源码编译 mysql5.6

1. 安装环境:  Mysql-5.6.23.tar.gz


2. 安装必备的工具
sudo apt-get install make  bison g++ build-essential libncurses5-dev cmake

3.    添加组合用户 设置安装目录权限
sudo groupadd mysql
sudo useradd –g mysql mysql –s /bin/false  #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
sudo mkdir –p /usr/local/mysql #创建Mysql安装目录
sudo mkdir -p /usr/local/mysql/data
sudo mkdir -p /usr/local/mysql/log
sudo chown -R mysql:mysql /usr/local/mysql/data
sudo chown -R mysql:mysql /usr/local/mysql

4.    编译安装mysql

4.1    获取源码包
cd /usr/local/src 
sudo wget

4.2    解压mysql源码包
sudo tar –zxvf mysql-5.6.23.tar.gz

5.    编译配置
cd mysql-5.6.23
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DWITH_DEBUG=0

注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf
sudo make -j4    #-j数字 表示以多核心运行
sudo make install
6.    相关配置
6.1    配置开机启动
sudo chmod +w /usr/local/mysql
sudo cp ./support-files/my-default.cnf  /etc/my.cnf
sudo cp ./support-files/mysql.server  /etc/init.d/mysqld
sudo chmod 755 /etc/init.d/mysqld

6.2    常用命令软连接,设置环境变量
sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
sudo ln -s /usr/local/mysql/bin/mysql  /usr/bin
sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin

6.3    初始化数据库

sudo /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

7.    启动mysql服务试一试
sudo  /etc/init.d/mysqld start

8.    启动成功后创建root用户的密码
mysqladmin -u root password

9.    成功后使用一下
mysql  -uroot  -p

4、安装nginx

sudo apt-get install nginx (当然也可以源码编译nginx)

nginx配置文件设置

在/etc/ngnix/site-available/default:


复制代码
# You may add here your
# server {
#    ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
#
#
#
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
    listen 80 default_server;
#    listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html/zabbix/;
    index index.php index.html index.htm;

# Make site accessible from
    server_name zabbix.example.com.cn;

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
    #location /RequestDenied {
    #    proxy_pass :8080;   
    #}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #    root /usr/share/nginx/html;
    #}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6cc94beb01df75d87e32b0d1f794b787.html