在此, 按照 系统运维(www.osyunwei.com) 的 qihang01同学的方案做此项目
一;将Centos7的防火墙从firewall变更为iptables
systemctl命令 详见somnus_小凯 同学的博客
[root@Zabbix ~]# systemctl stop firewalld.service #停止firewall
[root@Zabbix ~]# systemctl disable firewalld.service #禁止firewall开机启动
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
[root@Zabbix ~]# yum install iptables-services #安装iptables
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 110 kB 00:00:00
(2/4): base/7/x86_64/group_gz | 156 kB 00:00:00
(3/4): updates/7/x86_64/primary_db | 2.7 MB 00:00:01
(4/4): base/7/x86_64/primary_db | 5.7 MB 00:00:04
Determining fastest mirrors
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 iptables-services.x86_64.0.1.4.21-18.0.1.el7.centos 将被 安装
--> 正在处理依赖关系 iptables = 1.4.21-18.0.1.el7.centos,它被软件包 iptables-services-1.4.21-18.0.1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 iptables.x86_64.0.1.4.21-13.el7 将被 升级
---> 软件包 iptables.x86_64.0.1.4.21-18.0.1.el7.centos 将被 更新
--> 解决依赖关系完成
依赖关系解决
============================================================================================================================================================================================================
Package 架构 版本 源 大小
============================================================================================================================================================================================================
正在安装:
iptables-services x86_64 1.4.21-18.0.1.el7.centos base 51 k
为依赖而更新:
iptables x86_64 1.4.21-18.0.1.el7.centos base 428 k
事务概要
============================================================================================================================================================================================================
安装 1 软件包
升级 ( 1 依赖软件包)
总下载量:479 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
警告:/var/cache/yum/x86_64/7/base/packages/iptables-services-1.4.21-18.0.1.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY ] 0.0 B/s | 120 kB --:--:-- ETA
iptables-services-1.4.21-18.0.1.el7.centos.x86_64.rpm 的公钥尚未安装
(1/2): iptables-services-1.4.21-18.0.1.el7.centos.x86_64.rpm | 51 kB 00:00:00
(2/2): iptables-1.4.21-18.0.1.el7.centos.x86_64.rpm | 428 kB 00:00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 446 kB/s | 479 kB 00:00:01
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) "
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-0.1406.el7.centos.2.3.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : iptables-1.4.21-18.0.1.el7.centos.x86_64 1/3
正在安装 : iptables-services-1.4.21-18.0.1.el7.centos.x86_64 2/3
清理 : iptables-1.4.21-13.el7.x86_64 3/3
验证中 : iptables-1.4.21-18.0.1.el7.centos.x86_64 1/3
验证中 : iptables-services-1.4.21-18.0.1.el7.centos.x86_64 2/3
验证中 : iptables-1.4.21-13.el7.x86_64 3/3
已安装:
iptables-services.x86_64 0:1.4.21-18.0.1.el7.centos
作为依赖被升级:
iptables.x86_64 0:1.4.21-18.0.1.el7.centos
完毕!
vi /etc/sysconfig/iptables #编辑防火墙配置文件
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@Zabbix ~]# systemctl restart iptables.service #重启防火墙使配置生效
[root@Zabbix ~]# systemctl enable iptables.service #设置防火墙开机启动
ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants/iptables.service'
[root@Zabbix ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing #注释掉
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
setenforce 0 #使配置生效
三 、系统约定
[root@Zabbix src]# pwd #确认目录
/usr/local/src
1:下载nginx(目前稳定版)
[root@Zabbix src]# wget http://nginx.org/download/nginx-1.6.0.tar.gz
--2017-10-11 23:52:01-- http://nginx.org/download/nginx-1.6.0.tar.gz
正在解析主机 nginx.org (nginx.org)... 95.211.80.227, 206.251.255.63, 2001:1af8:4060:a004:21::e3, ...
正在连接 nginx.org (nginx.org)|95.211.80.227|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:802956 (784K) [application/octet-stream]
正在保存至: “nginx-1.6.0.tar.gz”
100%[==========================================================================>] 802,956 96.3KB/s 用时 12s
2017-10-11 23:52:13 (64.8 KB/s) - 已保存 “nginx-1.6.0.tar.gz” [802956/802956])
2:下载MySQL
[root@Zabbix src]# wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.19.tar.gz
--2017-10-11 23:53:32-- http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.19.tar.gz
正在解析主机 cdn.mysql.com (cdn.mysql.com)... 2.19.60.91
正在连接 cdn.mysql.com (cdn.mysql.com)|2.19.60.91|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:32879525 (31M) [application/x-tar-gz]
正在保存至: “mysql-5.6.19.tar.gz”
100%[========================================================================>] 32,879,525 961KB/s 用时 36s
2017-10-11 23:54:09 (897 KB/s) - 已保存 “mysql-5.6.19.tar.gz” [32879525/32879525])
[root@Zabbix src]# wget http://cn2.php.net/distributions/php-5.5.14.tar.gz
--2017-10-11 23:55:46-- http://cn2.php.net/distributions/php-5.5.14.tar.gz
正在解析主机 cn2.php.net (cn2.php.net)... 202.108.35.250, 202.108.35.235
正在连接 cn2.php.net (cn2.php.net)|202.108.35.250|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:17160225 (16M) [application/x-gzip]
正在保存至: “php-5.5.14.tar.gz”
100%[=======================================================================>] 17,160,225 7.33MB/s 用时 2.2s
2017-10-11 23:55:48 (7.33 MB/s) - 已保存 “php-5.5.14.tar.gz” [17160225/17160225])
4:下载pcre (支持nginx伪静态)
[root@Zabbix src]# wget http://exim.mirror.fr/pcre/pcre-8.35.tar.gz
--2017-10-11 23:58:57-- http://exim.mirror.fr/pcre/pcre-8.35.tar.gz
正在解析主机 exim.mirror.fr (exim.mirror.fr)... 195.20.15.70
正在连接 exim.mirror.fr (exim.mirror.fr)|195.20.15.70|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1996552 (1.9M) [application/octet-stream]
正在保存至: “pcre-8.35.tar.gz”
100%[======================================================================>] 1,996,552 109KB/s 用时 39s
2017-10-11 23:59:37 (49.7 KB/s) - 已保存 “pcre-8.35.tar.gz” [1996552/1996552])
5:下载openssl(nginx扩展)
[root@Zabbix src]# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
--2017-10-12 00:06:16-- http://www.openssl.org/source/openssl-1.0.1h.tar.gz
正在解析主机 www.openssl.org (www.openssl.org)... 23.200.224.71, 2600:1417:76:18c::c1e, 2600:1417:76:197::c1e
正在连接 www.openssl.org (www.openssl.org)|23.200.224.71|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://www.openssl.org/source/openssl-1.0.1h.tar.gz [跟随至新的 URL]
--2017-10-12 00:06:17-- https://www.openssl.org/source/openssl-1.0.1h.tar.gz
正在连接 www.openssl.org (www.openssl.org)|23.200.224.71|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4475692 (4.3M) [application/x-gzip]
正在保存至: “openssl-1.0.1h.tar.gz”
100%[=======================================================================>] 4,475,692 412KB/s 用时 14s
2017-10-12 00:06:33 (312 KB/s) - 已保存 “openssl-1.0.1h.tar.gz” [4475692/4475692])
[root@Zabbix src]# wget http://zlib.net/zlib-1.2.11.tar.gz
--2017-10-12 00:10:13-- http://zlib.net/zlib-1.2.11.tar.gz
正在解析主机 zlib.net (zlib.net)... 69.73.182.198
正在连接 zlib.net (zlib.net)|69.73.182.198|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:607698 (593K) [application/x-gzip]
正在保存至: “zlib-1.2.11.tar.gz”
100%[=======================================================================>] 607,698 29.9KB/s 用时 20s
2017-10-12 00:10:34 (29.4 KB/s) - 已保存 “zlib-1.2.11.tar.gz” [607698/607698])
7:下载cmake(MySQL编译工具)
[root@Zabbix src]# wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
--2017-10-12 00:11:34-- http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
正在解析主机 www.cmake.org (www.cmake.org)... 66.194.253.19
正在连接 www.cmake.org (www.cmake.org)|66.194.253.19|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:http://cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz [跟随至新的 URL]
--2017-10-12 00:11:34-- http://cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
正在解析主机 cmake.org (cmake.org)... 66.194.253.19
正在连接 cmake.org (cmake.org)|66.194.253.19|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz [跟随至新的 URL]
--2017-10-12 00:11:35-- https://cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
正在连接 cmake.org (cmake.org)|66.194.253.19|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:5887016 (5.6M) [application/x-gzip]
正在保存至: “cmake-2.8.11.2.tar.gz”
100%[=====================================================================>] 5,887,016 481KB/s 用时 15s
2017-10-12 00:11:51 (392 KB/s) - 已保存 “cmake-2.8.11.2.tar.gz” [5887016/5887016])
8: 下载libmcrypt(php扩展)
[root@Zabbix src]# wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
--2017-10-12 00:12:54-- http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
正在解析主机 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 211.79.60.17, 2001:e10:ffff:1f02::17
正在连接 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|211.79.60.17|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1335178 (1.3M) [application/x-gzip]
正在保存至: “libmcrypt-2.5.8.tar.gz”
100%[======================================================================>] 1,335,178 309KB/s 用时 4.2s
2017-10-12 00:13:00 (309 KB/s) - 已保存 “libmcrypt-2.5.8.tar.gz” [1335178/1335178])
9:下载yasm(php扩展)
[root@Zabbix src]# wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
--2017-10-12 00:13:51-- http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
正在解析主机 www.tortall.net (www.tortall.net)... 69.55.226.36
正在连接 www.tortall.net (www.tortall.net)|69.55.226.36|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1436502 (1.4M) [application/octet-stream]
正在保存至: “yasm-1.2.0.tar.gz”
100%[======================================================================>] 1,436,502 31.9KB/s 用时 35s
2017-10-12 00:14:27 (40.4 KB/s) - 已保存 “yasm-1.2.0.tar.gz” [1436502/1436502])
[root@Zabbix src]# wget http://download.freenas.org/distfiles/t1lib-5.1.2.tar.gz
--2017-10-12 00:16:01-- http://download.freenas.org/distfiles/t1lib-5.1.2.tar.gz
正在解析主机 download.freenas.org (download.freenas.org)... 209.51.186.23, 2001:470:1:4c8::1:81
正在连接 download.freenas.org (download.freenas.org)|209.51.186.23|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1872534 (1.8M) [application/octet-stream]
正在保存至: “t1lib-5.1.2.tar.gz”
100%[======================================================================>] 1,872,534 143KB/s 用时 18s
2017-10-12 00:16:21 (102 KB/s) - 已保存 “t1lib-5.1.2.tar.gz” [1872534/1872534])
11:下载gd库安装包
[root@Zabbix src]# wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
--2017-10-12 00:17:28-- https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
正在解析主机 bitbucket.org (bitbucket.org)... 104.192.143.3, 104.192.143.2, 104.192.143.1, ...
正在连接 bitbucket.org (bitbucket.org)|104.192.143.3|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://bbuseruploads.s3.amazonaws.com/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz?Signature=bvXjgYanuWvKtlN0GKUAt%2FxkL04%3D&Expires=1507711678&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22libgd-2.1.0.tar.gz%22 [跟随至新的 URL]
--2017-10-12 00:17:30-- https://bbuseruploads.s3.amazonaws.com/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz?Signature=bvXjgYanuWvKtlN0GKUAt%2FxkL04%3D&Expires=1507711678&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22libgd-2.1.0.tar.gz%22
正在解析主机 bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)... 52.216.84.64
正在连接 bbuseruploads.s3.amazonaws.com (bbuseruploads.s3.amazonaws.com)|52.216.84.64|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2330322 (2.2M) [application/x-tar]
正在保存至: “libgd-2.1.0.tar.gz”
100%[===================================================================>] 2,330,322 129KB/s 用时 75s
2017-10-12 00:18:48 (30.3 KB/s) - 已保存 “libgd-2.1.0.tar.gz” [2330322/2330322])
12:libvpx(gd库需要)
[root@Zabbix src]# wget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
--2017-10-12 00:39:45-- https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
正在解析主机 webm.googlecode.com (webm.googlecode.com)... 108.177.97.82, 2404:6800:4008:c07::52
正在连接 webm.googlecode.com (webm.googlecode.com)|108.177.97.82|:443... ^C
[root@Zabbix src]# wget http://pkgs.fedoraproject.org/repo/pkgs/libvpx/libvpx-v1.3.0.tar.bz2/14783a148872f2d08629ff7c694eb31f/libvpx-v1.3.0.tar.bz2
--2017-10-12 00:43:40-- http://pkgs.fedoraproject.org/repo/pkgs/libvpx/libvpx-v1.3.0.tar.bz2/14783a148872f2d08629ff7c694eb31f/libvpx-v1.3.0.tar.bz2
正在解析主机 pkgs.fedoraproject.org (pkgs.fedoraproject.org)... 209.132.181.4
正在连接 pkgs.fedoraproject.org (pkgs.fedoraproject.org)|209.132.181.4|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2084229 (2.0M) [application/x-bzip2]
正在保存至: “libvpx-v1.3.0.tar.bz2”
100%[====================================================================>] 2,084,229 61.6KB/s 用时 66s
2017-10-12 00:44:47 (31.1 KB/s) - 已保存 “libvpx-v1.3.0.tar.bz2” [2084229/2084229])
13:tiff(gd库需要)
[root@Zabbix src]# wget http://down.linuxprobe.com/Tools/tiff-4.0.3.tar.gz
--2017-10-12 00:46:59-- http://down.linuxprobe.com/Tools/tiff-4.0.3.tar.gz
正在解析主机 down.linuxprobe.com (down.linuxprobe.com)... 123.57.246.147
正在连接 down.linuxprobe.com (down.linuxprobe.com)|123.57.246.147|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2051630 (2.0M) [application/x-gzip]
正在保存至: “tiff-4.0.3.tar.gz”
100%[===================================================================>] 2,051,630 30.9KB/s 用时 75s
2017-10-12 00:48:14 (26.7 KB/s) - 已保存 “tiff-4.0.3.tar.gz” [2051630/2051630])
[root@Zabbix src]# wget http://pkgs.fedoraproject.org/repo/pkgs/libpng/libpng-1.6.12.tar.gz/297388a6746a65a2127ecdeb1c6e5c82/libpng-1.6.12.tar.gz
--2017-10-12 00:49:50-- http://pkgs.fedoraproject.org/repo/pkgs/libpng/libpng-1.6.12.tar.gz/297388a6746a65a2127ecdeb1c6e5c82/libpng-1.6.12.tar.gz
正在解析主机 pkgs.fedoraproject.org (pkgs.fedoraproject.org)... 209.132.181.4
正在连接 pkgs.fedoraproject.org (pkgs.fedoraproject.org)|209.132.181.4|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1354223 (1.3M) [application/x-gzip]
正在保存至: “libpng-1.6.12.tar.gz”
100%[================================================================>] 1,354,223 19.4KB/s 用时 63s
2017-10-12 00:50:53 (21.1 KB/s) - 已保存 “libpng-1.6.12.tar.gz” [1354223/1354223])
15:freetype(gd库需要)
[root@Zabbix src]# wget http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz
--2017-10-12 00:51:40-- http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz
正在解析主机 ring.u-toyama.ac.jp (ring.u-toyama.ac.jp)... 160.26.2.184
正在连接 ring.u-toyama.ac.jp (ring.u-toyama.ac.jp)|160.26.2.184|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2267172 (2.2M) [application/x-gzip]
正在保存至: “freetype-2.5.3.tar.gz”
100%[==============================================================>] 2,267,172 29.4KB/s 用时 1m 41s
2017-10-12 00:53:24 (21.8 KB/s) - 已保存 “freetype-2.5.3.tar.gz” [2267172/2267172])
16:jpegsrc(gd库需要)
[root@Zabbix src]# wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
--2017-10-12 00:54:27-- http://www.ijg.org/files/jpegsrc.v9a.tar.gz
正在解析主机 www.ijg.org (www.ijg.org)... 143.95.79.225
正在连接 www.ijg.org (www.ijg.org)|143.95.79.225|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1000034 (977K) [application/x-gzip]
正在保存至: “jpegsrc.v9a.tar.gz”
100%[=============================================================>] 1,000,034 88.2KB/s 用时 18s
2017-10-12 00:54:46 (54.5 KB/s) - 已保存 “jpegsrc.v9a.tar.gz” [1000034/1000034])
所有软件如下
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
一,安装mysql
1:安装cmake
[root@Zabbix ~]# cd /usr/local/src/
[root@Zabbix src]# tar zxvf cmake-2.8.11.2.tar.gz
[root@Zabbix src]# cd cmake-2.8.11.2
[root@Zabbix cmake-2.8.11.2]# ./configure
[root@Zabbix cmake-2.8.11.2]# make
[root@Zabbix cmake-2.8.11.2]# make install
2:安装MYSQL
[root@Zabbix ~]# groupadd mysql #添加mysql组
[root@Zabbix ~]# useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
[root@Zabbix ~]# mkdir -p /data/mysql #创建MySQL数据库存放目录
[root@Zabbix ~]# chown -R mysql:mysql /data/mysql #设置MySQL数据库存放目录权限
[root@Zabbix ~]# mkdir -p /usr/local/mysql #创建MySQL安装目录
[root@Zabbix ~]# cd /usr/local/src #进入软件包存放目录
[root@Zabbix src]# tar zxvf mysql-5.6.19.tar.gz #解压
[root@Zabbix src]# cd mysql-5.6.19 #进入目录
[root@Zabbix mysql-5.6.19]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #配置
[root@Zabbix mysql-5.6.19]# make #编译
[root@Zabbix mysql-5.6.19]# make install #安装
[root@Zabbix mysql-5.6.19]# rm -rf /etc/my.cnf #删除系统默认的配置文件(如果默认没有就不用删除)
[root@Zabbix mysql-5.6.19]# cd /usr/local/mysql #进入MySQL安装目录
[root@Zabbix mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #生成mysql系统数据库
[root@Zabbix mysql]# ln -s /usr/local/mysql/my.cnf /etc/my.cnf #添加到/etc目录的软连接
[root@Zabbix mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
[root@Zabbix mysql]# chmod 755 /etc/init.d/mysqld #增加执行权限
[root@Zabbix mysql]# chkconfig mysqld on #加入开机启动
[root@Zabbix mysql]# vi /etc/rc.d/init.d/mysqld #编辑
#!/bin/sh
basedir=/usr/local/mysql #MySQL程序安装路径
datadir=/data/mysql #MySQl数据库存放目录
[root@Zabbix mysql]# service mysqld start #启动
Starting MySQL. SUCCESS!
[root@Zabbix mysql]# vi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/mysql/bin
[root@Zabbix mysql]# source /etc/profile #使配置立刻生效
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。
[root@Zabbix mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
[root@Zabbix mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql
[root@Zabbix mysql]# mkdir /var/lib/mysql #创建目录
[root@Zabbix mysql]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #添加软链接
[root@Zabbix mysql]# mysql_secure_installation #设置Mysql密码,根据提示按Y 回车输入2次密码
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# mkdir /usr/local/pcre
[root@Zabbix src]# tar zxvf pcre-8.35.tar.gz
[root@Zabbix src]# cd pcre-8.35
[root@Zabbix pcre-8.35]# ./configure --prefix=/usr/local/pcre
[root@Zabbix pcre-8.35]# make
[root@Zabbix pcre-8.35]# make install
2,安装openssl
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# mkdir /usr/local/openssl
[root@Zabbix src]# tar zxvf openssl-1.0.1h.tar.gz
[root@Zabbix src]# cd openssl-1.0.1h
[root@Zabbix openssl-1.0.1h]# ./config --prefix=/usr/local/openssl
[root@Zabbix openssl-1.0.1h]# make
[root@Zabbix openssl-1.0.1h]# make install
[root@Zabbix openssl-1.0.1h]# vi /etc/profile
export PATH=$PATH:/usr/local/openssl/bin
[root@Zabbix openssl-1.0.1h]# source /etc/profile
3,安装
zlib
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# mkdir /usr/local/zlib
[root@Zabbix src]# tar zxvf zlib-1.2.11.tar.gz
[root@Zabbix src]# cd zlib-1.2.11
[root@Zabbix zlib-1.2.11]# ./configure --prefix=/usr/local/zlib
[root@Zabbix zlib-1.2.11]# make
[root@Zabbix zlib-1.2.11]# make install
[root@Zabbix ~]# groupadd www
[root@Zabbix ~]# useradd -g www www -s /bin/false
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf nginx-1.6.0.tar.gz
[root@Zabbix src]# cd nginx-1.6.0
[root@Zabbix nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.11 --with-pcre=/usr/local/src/pcre-8.35
注意:--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.11 --with-pcre=/usr/local/src/pcre-8.35指向的是源码包解压的路径,而不是安装的路径,否则会报错
[root@Zabbix nginx-1.6.0]# make
[root@Zabbix nginx-1.6.0]# make install
[root@Zabbix nginx-1.6.0]# /usr/local/nginx/sbin/nginx #启动Nginx
设置nginx开机启动
[root@Zabbix nginx-1.6.0]# vi /etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
############################################################
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
#configtest || return $?
stop
sleep 1
start
}
reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
############################################################
[root@Zabbix nginx-1.6.0]# chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限
[root@Zabbix nginx-1.6.0]# chkconfig nginx on #设置开机启动
[root@Zabbix nginx-1.6.0]# /etc/rc.d/init.d/nginx restart #重启
Restarting nginx (via systemctl): [ 确定 ]
三:安装php
1:安装yasm
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf yasm-1.2.0.tar.gz
[root@Zabbix src]# cd yasm-1.2.0
[root@Zabbix yasm-1.2.0]# ./configure
[root@Zabbix yasm-1.2.0]# make
[root@Zabbix yasm-1.2.0]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf libmcrypt-2.5.8.tar.gz
[root@Zabbix src]# cd libmcrypt-2.5.8
[root@Zabbix libmcrypt-2.5.8]# ./configure
[root@Zabbix libmcrypt-2.5.8]# make
[root@Zabbix libmcrypt-2.5.8]# make install
3:安装libvpx
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar xvf libvpx-v1.3.0.tar.bz2
[root@Zabbix src]# cd libvpx-v1.3.0
[root@Zabbix libvpx-v1.3.0]# ./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
[root@Zabbix libvpx-v1.3.0]# make
[root@Zabbix libvpx-v1.3.0]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf tiff-4.0.3.tar.gz
[root@Zabbix src]# cd tiff-4.0.3
[root@Zabbix tiff-4.0.3]# ./configure --prefix=/usr/local/tiff --enable-shared
[root@Zabbix tiff-4.0.3]# make
[root@Zabbix tiff-4.0.3]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf libpng-1.6.12.tar.gz
[root@Zabbix src]# cd libpng-1.6.12
[root@Zabbix libpng-1.6.12]# ./configure --prefix=/usr/local/libpng --enable-shared
[root@Zabbix libpng-1.6.12]# make && make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf freetype-2.5.3.tar.gz
[root@Zabbix src]# cd freetype-2.5.3
[root@Zabbix freetype-2.5.3]# ./configure --prefix=/usr/local/freetype --enable-shared
[root@Zabbix freetype-2.5.3]# make
[root@Zabbix freetype-2.5.3]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf jpegsrc.v9a.tar.gz
[root@Zabbix src]# cd jpeg-9a
[root@Zabbix jpeg-9a]# ./configure --prefix=/usr/local/jpeg --enable-shared
[root@Zabbix jpeg-9a]# make
[root@Zabbix jpeg-9a]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf libgd-2.1.0.tar.gz
[root@Zabbix src]# cd libgd-2.1.0
[root@Zabbix libgd-2.1.0]# ./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx
[root@Zabbix libgd-2.1.0]# make
[root@Zabbix libgd-2.1.0]# make install
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar zxvf t1lib-5.1.2.tar.gz
[root@Zabbix src]# cd t1lib-5.1.2
[root@Zabbix t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enable-shared
[root@Zabbix t1lib-5.1.2]# make without_doc
[root@Zabbix t1lib-5.1.2]# make install
注意:如果系统是64位,请执行以下两条命令,否则安装php会出错(32位系统不需要执行)
[root@Zabbix ~]# \cp -frp /usr/lib64/libltdl.so* /usr/lib/
[root@Zabbix ~]# \cp -frp /usr/lib64/libXpm.so* /usr/lib/
[root@Zabbix ~]# cd /usr/local/src
[root@Zabbix src]# tar -zvxf php-5.5.14.tar.gz
[root@Zabbix src]# cd php-5.5.14
[root@Zabbix php-5.5.14]# export LD_LIBRARY_PATH=/usr/local/libgd/lib
[root@Zabbix php-5.5.14]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
[root@Zabbix php-5.5.14]# make
[root@Zabbix php-5.5.14]# make install
[root@Zabbix php-5.5.14]# cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录
[root@Zabbix php-5.5.14]# rm -rf /etc/php.ini #删除系统自带配置文件
[root@Zabbix php-5.5.14]# ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录
[root@Zabbix php-5.5.14]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
[root@Zabbix php-5.5.14]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录
[root@Zabbix php-5.5.14]# vi /usr/local/php/etc/php-fpm.conf
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
pid = run/php-fpm.pid #取消前面的分号
设置 php-fpm开机启动
[root@Zabbix php-5.5.14]# cp /usr/local/src/php-5.5.14/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录
[root@Zabbix php-5.5.14]# chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限
[root@Zabbix php-5.5.14]# chkconfig php-fpm on #设置开机启动
[root@Zabbix php-5.5.14]# vi /usr/local/php/etc/php.ini #编辑配置文件
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = Off #禁止显示php版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持php短标签
找到opcache.enable=0
修改为opcache.enable=1 #php支持opcode缓存
找到:opcache.enable_cli=1 #php支持opcode缓存
修改为:opcache.enable_cli=0
在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能
配置nginx支持php
[root@Zabbix php-5.5.14]# vi /usr/local/nginx/conf/nginx.conf
修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
index index.html index.htm index.php; #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
[root@Zabbix php-5.5.14]# /etc/init.d/nginx restart #重启nginx
Restarting nginx (via systemctl): [ 确定 ] #启动php-fpm
[root@Zabbix php-5.5.14]# service php-fpm start
Starting php-fpm [13-Oct-2017 21:49:21] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
[13-Oct-2017 21:49:21] ERROR: FPM initialization failed
failed
启动php-fpm报错,地址被占用
[root@Zabbix php-5.5.14]# killall php-fpm #杀掉进程
[root@Zabbix php-5.5.14]# service php-fpm start
Starting php-fpm done #报错消失
[root@Zabbix ~]# cd /usr/local/nginx/html/ #进入nginx默认网站根目录
[root@Zabbix html]# rm -rf /usr/local/nginx/html/* #删除默认测试页
[root@Zabbix html]# vi index.php #新建index.php文件
[root@Zabbix html]# chown www.www /usr/local/nginx/html/ -R #设置目录所有者
[root@Zabbix html]# chmod 700 /usr/local/nginx/html/ -R #设置目录权限
在浏览器中打开服务器IP地址,会看到下面的界面
LNMP安装完成
在此万分感谢 qihang01 同学