CentOS 7 LNMP环境搭建Zabbix3.0

概述:在CentOS 7 64位操作系统环境下搭建LNMP(Linux+Nginx+MySQL+PHP)来运行Zabbix监控程序

CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境)

CentOS 7源码安装最新版LNMP环境

预先安装:

yum install -y autoconf make automake imake cmake gcc gcc-c++ libaio libaio-devel bzr bison expat-devel libtool ncurses5-devel gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel yum install pcre* yum install openssl* yum install epel-release yum clean all yum repolist

第一部分:安装MySQL 5.7

1. 首先下载MySQL Yum repository,CentOS 7对应的下载链接如下

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2. 下载完成之后安装下载好的rpm文件

yum localinstall mysql57-community-release-el7-7.noarch.rpm

3.  安装完成之后验证MySQL YUM repository

yum repolist enabled | grep "mysql.*-community.*"

如下图所示,表示验证成功:

4. 安装最新版的MySQL

yum install mysql-community-server

5. 安装完成之后启动并查看MySQL状态:

service mysqld start service mysqld status

6. 手动验证MySQL安装的版本:

mysql --version

7. 安装MySQL 5.7之后,MySQL会生成一个随机密码在/var/log/mysqld.log文件中,使用如下命令查看密码:

grep 'temporary password' /var/log/mysqld.log

8. 记录密码之后,运行 mysql_secure_installation初始化MySQL,初始化过程中会提示输入随机密码

mysql_secure_installation

9. 使用新设置的密码连接MySQL:

mysql -u root -p

10. 至此,MySQL 5.7安装完成。

第二部门  安装Nginx

1. 首先下载Nginx的最新稳定版,本示例使用的版本是1.10,下载之后解压压缩包:

tar zxvf nginx-1.10.1.tar.gz

2. 进入解压之后的Nginx目录,运行configure

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre

3. 编译安装

make make install

4. 测试Nginx

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

第三部分  安装PHP

1. 首先安装开发软件包:

yum -y groupinstall "Development Tools"

2. 下载PHP最新稳定版,解压安装包,本示例使用的是PHP 5.6.25

tar -zxvf php-5.6.25.tar.gz

3. 切换到PHP目录,运行configure:

./configure -prefix=/usr/local/php -with-config-file-path=/usr/local/php/etc -with-bz2 -with-curl -enable-ftp -enable-sockets -disable-ipv6 -with-gd -with-jpeg-dir=/usr/local -with-png-dir=/usr/local -with-freetype-dir=/usr/local -enable-gd-native-ttf -with-iconv-dir=/usr/local -enable-mbstring -enable-calendar -with-gettext -with-libxml-dir=/usr/local -with-zlib -with-pdo-mysql=mysqlnd -with-mysqli=mysqlnd -with-mysql=mysqlnd -enable-dom -enable-xml -enable-fpm -with-libdir=lib64 -enable-bcmath

4. 

make make install

5. 复制安装包中的php.ini-production到 /usr/local/php/etc/php.ini

cp php.ini-production /usr/local/php/etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default.conf php-fpm.conf

6. 测试PHP安装是否成功。

/usr/local/php/sbin/php-fpm -t

7. 测试成功之后启动PHP

cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod 755 /etc/init.d/php-fpm service php-fpm start  

8. 添加到开机启动

chkconfig php-fpm on

9. 检查是否启动

ps aux |grep php-fpm netstat -ant |grep 9000

第四部分 配置Nginx运行PHP

1. 修改Nginx配置文件如下

vim /usr/local/nginx/conf/nginx.conf

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

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