搭建环境:
操作系统:CentOS 6.7
MysqL软件:MysqL-5.5.51-linux2.6-x86_64.tar.gz
一、LNMP安装前环境准备
1、设置linux防火墙
1)在iptables上开放80,3306,443端口
[root@db ~]# vim /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p 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 443 -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@db ~]# service iptables restart-----重启iptables服务
2)关闭selinux防火墙
[root@db ~]# vim /etc/sysconfig/selinux
# 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=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@db ~]#setenforc 0
3)安装依赖包
[root@db ~]#yum-y
install
gccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-devel
bzip2
bzip2
-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-developenldap-clientsopenldap-servers
make
libtool*gittreebisonpcre-develperlgdgd-devel
4)编译安装其他软件
[root@db software]# tar xf libiconv-1.14.tar.gz
[root@db libiconv-1.14]#.
/configure
--prefix=
/usr/local
[root@db libiconv-1.14]#make
&&make
install
[root@db libiconv-1.14]# echo $?
0
(显示0,表示软件编译安装成功了)
B:安装libmcrypt (加密算法扩展库,支持DES,3DES,RIJNDAEL,Twofish,IDEA,GOST,CAST-256,ARCFOUR,SERPENT,SAFER+等算法)
[root@db software]# tar xf libmcrypt-2.5.7.tar.gz
[root@db software]# cd libmcrypt-2.5.7
[root@db libmcrypt-2.5.7]# ./configure
[root@db libmcrypt-2.5.7]# cd libltdl/
[root@db libltdl]# ./configure --enable-ltdl-install
[root@db libltdl]# make && make install
C: 安装mhash(mhash的可以用于创建校验数值,消息摘要,消息认证码,以及无需原文的关键信息保存)
[root@db software]# tar xf mhash-0.9.9.9.tar.gz
[root@db software]# cd mhash-0.9.9.9
[root@db mhash-0.9.9.9]# ./configure && make && make install
D:安装mcript(mcrypt 是 PHP 里面重要的加密支持扩展库,Mcrypt扩展库可以实现加密解密功能,就是既能将明文加密,也可以密文还原。)
[root@db software]# tar xf mcrypt-2.6.8.tar.gz
[root@db software]# cd mcrypt-2.6.8
[root@db mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[root@db mcrypt-2.6.8]# ./configure && make && make install
[root@db software]#ln
-s
/usr/local/lib/libmcrypt
.la
/usr/lib/libmcrypt
.la
.so
.so.4
.so.4.4.8
.a
/usr/lib/libmhash
.a