lanmp安装参考-bin

centos7安装lanmp

 

l        关于centos7安装lanmp,在网上查看了各种博客文章,yum安装,apt-get安装.源码编译安装.,期间尝试更换yum源,更新,发现有些版本还是太低了,最终决定主要的anmp还是官网下载,编译安装,其他依赖yum安装

 

l        如果版本足够,也可以yum安装,但是php要找高版本,更新yum源,编译安装,太多依赖问题了

 

一,参考提示:一定要选稳定版本,不要选测试的版本

linux环境 centos7(阿里云)

Apache 2.4.27

Nginx  1.12.1.

Php 5.5.38

Mysql 5.5.57

(注意,apache2.2不能和5.5php)

1.        apache下载图示

http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.27.tar.gz

 

2.        nginx下载图示

 

http://nginx.org/download/nginx-1.12.1.tar.gz

 

Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以说是开发版

Stable version:最新稳定版,生产环境上建议使用的版本

Legacy versions:遗留的老版本的稳定版

 

3.        php下载图示

http://am1.php.net/distributions/php-5.5.38.tar.gz

 

 

4.        mysql下载图示

https://dev.mysql.com/downloads/file/?id=471658

 

 

 

http://jingyan.baidu.com/article/a378c9609eb652b3282830fd.html

 

 

source code  源代码 (源码)

https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.57.tar.gz

 

 

二进制文件安装

https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz

 

 

 

 

 

===================

http://jingyan.baidu.com/article/a378c9609eb652b3282830fd.html

 

linux安装mysql服务分两种安装方法:

①源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错;

②使用官方编译好的二进制文件安装,优点是安装速度快,安装步骤简单,缺点是安装包很大,300M左右。以下介绍linux使用官方编译好的二进制包安装mysql。

mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz

 

 

 

 根据你centos 发行版本号下载对应的mysql 版本号,比如 centos7.0,表示 7 系列的,那么 下载

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

源码(参考,不要下载,选二进制上面的~!!!)

 

 

二,准备

http://blog.csdn.net/superminn/article/details/52130654

 

5.        进入root权限模式

[wujunbin@bogon ~]$ yum install apr

Loaded plugins: fastestmirror, langpacks

You need to be root to perform this command.

出错,所以要进入到root

 

命令行Su     //只需su 然后输入密码

 

 

6.        更改yum源与更新系统。

(如果yum源满足需求,可以不更新,参考参考9)

是什么版本系统选什么,我现在的是centos7

 

更换网易163的源

 

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

cd /etc/yum.repos.d/

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo#是什么版本系统选什么,我现在的是centos7

mv CentOS7-Base-163.repo CentOS-Base.repo

yum clean all

rm -rf /var/cache/yum

yum makecache

yum -y update

 

yum  install epel-release  //扩展包更新包

 

7.        查询已安装软件命令

rpm -qa | grep <关键字>  #

rpm -aq|grep -i libxml 发现libxml2已经安装了

 

8.        开启screen -S lnmp

yum install screen

screen -r lnmp

 

screen 的作用是什么呢?

使用telnet或SSH远程登录linux时,如果连接非正常中断,重新连接时,系统将开一个新的session,无法恢复原来的session.screen命令可以解决这个问题。Screen工具是一个终端多路转接器,在本质上,这意味着你能够使用一个单一的终端窗口运行多终端的应用。

执行:screen -S lnmp 创建screen会话。

如果提示screen:command not found 命令不存在可以执行:yum install screen 或 apt-get install screen安装,

如果网络掉线,可以重新连接,再执行 screen -r lnmp 就会看到你的lnmp安装进程。

查看当前的screen进程
scren -ls
关闭指定的screen
kill 9505

使用会话有个好处,执行命令后,如果是全自动的,关闭ssh黑框可以明显提高速度。

 

9.        关闭规则

参照参考8的规则

 

iptables -F #清除防火墙规则,临时关闭

setenforce 0 #临时关闭selinux

 

====

CentOS 7.0默认使用的是firewall作为防火墙。

1、关闭firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、关闭SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #注释掉

SELINUX=disabled #增加

:wq! #保存退出

setenforce 

0 #使配置立即生效

http://www.linuxidc.com/Linux/2014-06/103266.htm

一、准备工作

配置防火墙,允许防火墙通过22(sshd)、80(WEB)、3306(MYSQL)端口
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
/etc/rc.d/init.d/iptables save #保存配置

关闭selinux:

vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq 保存,退出
reboot #重启系统

 

三,编译安装

10.    依赖库安装

mcrypt-2.6.8.tar.gz、

libmcrypt-2.5.8.tar.gz、

mhash-0.9.9.9.tar.gz)

 

yum install make cmake mcrypt*  mhash*  apr* autoconf automake bzip2 bzip2-devel curl curl-devel gcc gcc-c++ gcc-g77 e2fsprogs e2fsprogs-devel zlib* zlib-devel openssl openssl-devel pcre pcre-devel gd gd-devel kernel keyutils patch perl perl-devel kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* libvpx libjpeg libjpeg-devel libpng zlib libXpm libXpm-devel t1lib libt1-devel freetype freetype-devel libpng* libpng10 libpng10-devel libpng-devel php-common php-gd ncurses* ncurses-devel libtool* libtool-libs  libxml2 libxml2-devel patch glibc glibc-devel glib2 glib2-devel krb5 krb5-devel libevent libevent-devel libidn libidn-devel nss_ldap openldap openldap-clients openldap-devel openldap-servers openssl openssl-devel pspell-devel net-snmp* net-snmp-devel libxslt libxslt-devel  libmcrypt libmcrypt-devel -y

 

 

yum  -y  install libxml2

yum  -y  install libxml2-devel

yum  -y  install openssl

yum  -y  install openssl-devel

yum  -y  install curl

yum  -y  install curl-devel

yum  -y  install libjpeg

yum  -y  install libjpeg-devel

yum  -y  install libpng

yum  -y  install libpng-devel

yum  -y  install freetype

yum  -y  install freetype-devel

yum  -y  install pcre

yum  -y  install pcre-devel

yum  -y  install libxslt

yum  -y  install libxslt-devel

yum  -y  install libmcrypt

yum  -y  install libmcrypt-devel

yum  -y  install zlib

yum  -y  install zlib-devel  

yum  -y  install libmcrypt

yum  -y  install libmcrypt-devel

yum  -y  install gcc+ gcc-c++

yum  -y  install freetype

yum  -y  install freetype-devel

 

 

 

 

 

 

(参考 http://blog.csdn.net/superminn/article/details/52130654

yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash)

 

yum  -y  install libxml2

yum  -y  install libxml2-devel

yum  -y  install openssl

yum  -y  install openssl-devel

yum  -y  install curl

yum  -y  install curl-devel

yum  -y  install libjpeg

yum  -y  install libjpeg-devel

yum  -y  install libpng

yum  -y  install libpng-devel

yum  -y  install freetype

yum  -y  install freetype-devel

yum  -y  install pcre

yum  -y  install pcre-devel

yum  -y  install libxslt

yum  -y  install libxslt-devel

yum install -y libmcrypt

yum install -y libmcrypt-devel

yum install -y zlib

yum install -y zlib-devel   

 

 

http://www.jb51.net/article/104419.htm

 

 

http://www.linuxidc.com/Linux/2014-06/103266.htm

 

11.    下载所需anmp包

test -d /home/lnmp || mkdir -p /home/lnmp  #如果不存在就创建

cd /home/lnmp

 

wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.27.tar.gz

wget http://nginx.org/download/nginx-1.12.1.tar.gz

wget http://am1.php.net/distributions/php-5.5.38.tar.gz

wget https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.57.tar.gz

 

 

 

tar -zxvf   解压

 

 

 

12.    安装apache 

1,首先先依赖安装(参考参考13,依赖库)

 

yum -y install gcc+ gcc-c++ #之前可能装了

(http://blog.sina.com.cn/s/blog_8f0b67a901010cp3.html安装 apr-util时有个地方报错,要执行上面命令)

 

1)依赖下载

test -d /home/lnmp || mkdir -p /home/lnmp  #如果不存在就创建

cd /home/lnmp

 

wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

 

wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

 

wget https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz

 

2)依赖解压安装

apr not found问题

cd /home/lnmp

tar -zxf /home/lnmp/apr-1.5.2.tar.gz 

cd  /home/lnmp/apr-1.5.2

./configure --prefix=/usr/local/apr 

make && make install 

 

 

 

 

APR-util not found问题

cd /home/lnmp

tar -zxf /home/lnmp/apr-util-1.5.4.tar.gz 

cd /home/lnmp/apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config 

make && make install 

 

 

 

pcre问题

 

cd /home/lnmp

tar -zxf /home/lnmp/pcre-8.39.tar.gz

cd /home/lnmp/pcre-8.39

./configure --prefix=/usr/local/pcre 

make && make install 

 

 

 

以上就是解决编译Apache出现的问题:configure: error: APR not found . Please read the documentation

请看以下参考6

 

2,编译apache,记得开启重写模块(—enable-rewrite )

 

cd /home/lnmp

wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.27.tar.gz

 

cd /home/lnmp

tar -zxvf /home/lnmp/httpd-2.4.27.tar.gz

cd /home/lnmp/httpd-2.4.27/

 

./configure --prefix=/usr/local/apache --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

 

make && make install

 

 

3,安装成功启动httpd

 

/usr/local/apache/bin/httpd 

export PATH=$PATH:/usr/local/apache/bin #(修改环境变量,把htppd加进去了)

 

关闭是pkill -9 httpd

##/usr/local/apache/bin/apachectl#这个是根目录启动httpd

 

 

 

 

 

 

 

13.    安装mysql

(mariadb)

 

源码依赖

 

1)    首先,下载安装依赖库,muysql5.5以后源码要cmake

 

yum下载cmake(有了的话,就不用源码安装了,没有的话,看下一步)

 

yum  install cmake^

yum  list cmake^

 

如果没有,下载cmake

 https://cmake.org/download/  官网Older Releases 老版本(记得源码包,不要二进制的,翻译网页查看)

 

https://cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz  下载地址

 

安装cmake

方式查看mysql依赖包

 

 cd /home/lnmp

tar zxvf cmake-2.8.12.2.tar.gz

 cd cmake-2.8.12.2

./bootstrap --prefix=/usr/local/cmake

 make & make install  

export PATH=$PATH:/usr/local/cmake/bin # 将/usr/local/bin加到PATH中

 

 

2)编译安装mysql.

 

新建 MySQL 用户

mkdir /usr/local/mysql

mkdir /usr/local/mysql/data

 

cd /home/lnmp

tar -zxvf /home/lnmp/mysql-5.5.57.tar.gz

cp -r ./mysql-5.5.57 /usr/local/mysql

cd /usr/local/mysql

 

 

groupadd mysql

useradd -r -g mysql mysql

chown -R mysql.mysql .

 

编译安装mysql

 

cd /usr/local/mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

make && make install

 

#报错.-bash: ./mysql_install_db: Permission denied所以先

cd /usr/local/mysql

chmod +x  ./scripts/mysql_install_db

 

 

 vim /etc/my.cnf  

#在[mysqld]中添加:

datadir = /usr/local/mysql/data

log-error = /usr/local/mysql/data/error.log

pid-file = /usr/local/mysql/data/mysql.pid

user = mysql

tmpdir = /tmp

 

#log-error=/var/log/mariadb/mariadb.log#注释掉

#pid-file=/var/run/mariadb/mariadb.pid#注释掉

 

 

 

初始化数据库(创建mysql授权表)

cd /usr/local/mysql

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid  --tmpdir=/tmp

 

复制mysqld

cd /usr/local/mysql/support-files/

cp mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

和开启其权限,

chmod a+wrx /etc/init.d/mysqld 

启动mysqld

service mysqld start

service mysqld restart

 

 

mysql -uroot -p #就可以进入了,第一次不用密码

 

mysql -uroot -p 错误bash: mysql: command not found

解决方案:http://www.jb51.net/article/34622.htm

 ln -s /usr/local/mysql/bin/mysql /usr/bin

 

 

 

修改密码

use mysql;

update user set password=password('root') where user='root';

flush privileges;

mysql> quit

 

 

========================================

二进制安装(可行)

 

test -d /home/lnmp || mkdir -p /home/lnmp  #如果不存在就创建

cd /home/lnmp

 

wget https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz

 

 

 

2安装

 

cd /home/lnmp/

tar -zxvf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz

 

cp mysql-5.5.57-linux-glibc2.12-x86_64 /usr/local/mysql -r

cd /usr/local/mysql

groupadd mysql

useradd -r -g mysql mysql

chown -R mysql.mysql .

./scripts/mysql_install_db —user=mysql

cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

 

cd /usr/local/mysql/support-files/

cp mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

service mysqld start

 

报错[root@bogon support-files]# service mysqld start

Starting MySQL.Logging to '/usr/local/mysql/data/bogon.err'.

. ERROR! The server quit without updating PID file (/usr/local/mysql/data/bogon.pid).

 

解决方案:http://rabbit2013.blog.51cto.com/6658739/1341055

 

重新配置vim /etc/my.cnf 加入

 

#在[mysqld]中添加:

datadir = /usr/local/mysql/data

log-error = /usr/local/mysql/data/error.log

pid-file = /usr/local/mysql/data/mysql.pid

user = mysql

tmpdir = /tmp

 

#log-error=/var/log/mariadb/mariadb.log#注释掉

#pid-file=/var/run/mariadb/mariadb.pid#注释掉

 

 

#保存退出

#初始化数据库

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 

 

#在解压的mysql里面的重新

cd /home/lnmp/mysql-5.5.57-linux-glibc2.12-x86_64/scripts/

 

./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid  --tmpdir=/tmp

 

 service mysqld restart

 

OK.启动,安装mysql完毕

 

pkill -9  mysqld

 

mysql -uroot -p 错误bash: mysql: command not found

解决方案:http://www.jb51.net/article/34622.htm

 

 ln -s /usr/local/mysql/bin/mysql /usr/bin

 

错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

 

解决方案 http://blog.csdn.net/ixidof/article/details/5958904/(参考)

vim /etc/my.cnf

 

[mysqld]

#socket         = /tmp/mysql.sock  #注释掉

 

#log-error=/var/log/mariadb/mariadb.log#注释掉

#pid-file=/var/run/mariadb/mariadb.pid#注释掉

 

 

然后启动,在重启

service mysqld start

 

service mysqld restart

 

mysql -uroot -p #就可以进入了,第一次不用密码

 

修改密码

mysql> use mysql

mysql> update user set password=password('root') where user='root';

mysql> flush privileges;

quit

 

=================

 

 

 

 

 

14.安装php

1)依赖下载

报错

No package freerype available.

freetype

官网https://www.freetype.org/download.html

http://download.savannah.gnu.org/releases/freetype/

 

下载地址

http://ftp.yzu.edu.tw/nongnu/freetype/freetype-2.7.tar.gz

 

安装

cd /home/lnmp

wget http://ftp.yzu.edu.tw/nongnu/freetype/freetype-2.7.tar.gz

tar -zvxf  freetype-2.7.tar.gz

cd freetype-2.7/

 ./configure --prefix=/usr/local/freetype

make && make install 

 

 

 

参考http://blog.csdn.net/lyhDream/article/details/42590057

 

报错

No package libxml available.

Libxml2

 

官网http://xmlsoft.org/downloads.html

ftp://xmlsoft.org/libxml2/

 

下载地址

ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz

 

 

 

安装

cd /home/lnmp

wget  ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz

tar -zvxf  libxml2-2.9.1.tar.gz

cd  /home/lnmp/libxml2-2.9.1

 ./configure --prefix=/usr/local/libxml2

make && make install 

发现错误,没安装python??

 

rpm -qa | grep <关键字>  #CentOS7 查询已安装软件命令

rpm -aq|grep -i libxml 发现libxml2已经安装了

所以

find / -name libxml2

发现在

/usr/share/gtk-doc/html/libxml2

/usr/include/libxml2

所以添加 ./configure --with-libxml-dir=/usr/include/libxml2

 

php安装

http://blog.csdn.net/jovenlu/article/details/14170467

 

cd /home/lnmp

tar -zvxf php-5.5.38.tar.gz

cd /home/lnmp/php-5.5.38/

 

编译安装(需要指定Apache的目录和MySQL的目录)

 

 

--enable-fpm 这个是开启php-fpm,整合nginx一顶要用的

 

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-mcrypt  --with-pdo-mysql --enable-mbstring  --enable-opcache --with-openssl --enable-fpm --with-jpeg-dir  --with-png-dir --with-freetype-dir=/usr/local/freetype  --with-libxml-dir=/usr/include/libxml2   --with-zlib-dir

 

 

make && make install

 

 

复制配置文件到指定目录,并修改Apache的配置文件

 

cp /home/lnmp/php-5.5.38/php.ini-production  /usr/local/php/etc/php.ini

 

rm -rf /etc/php.ini  #删除系统自带配置文件

ln -s /usr/local/php/etc/php.ini /etc/php.ini   #添加软链接到 /etc目录

 

cd /usr/local/apache/conf/

cp httpd.conf httpd.conf.back

 

修改apache配置.把php请求教给php模块去处理

vim  httpd.conf

AddType application/x-httpd-php .php

 

 

 

 

测试,http根目录

cd /usr/local/apache/htdocs/

vim 1.php

 

<?php phpinfo(); ?>

 

 

pkill -9 httpd#关闭

httpd #打开之前已经加到环境变量了,可以直接使用

/usr/local/apache/bin/apachectl#这个是根目录启动httpd

 

 

测试mysql

 

create table cs(

   id INT NOT NULL AUTO_INCREMENT,

title VARCHAR(100) NOT NULL,

   PRIMARY KEY ( id ));

 

insert into cs values(1,'123');

insert into cs values(2,'123');

 

cd /usr/local/apache/htdocs/

vim 1.php

 

<?php

 

$con=mysql_connect("localhost","root","root");

mysql_select_db("test");

$sql = "SELECT * FROM cs;";

$res=mysql_query($sql);

print_r(mysql_fetch_array($res));

 

?>

~                                                                                     

~     

 

 

========================

http://blog.csdn.net/ei__nino/article/details/8598490

onfigure: error: Cannot find ldap libraries in /usr/lib

解决办法:

cp -frp /usr/lib64/libldap* /usr/lib/


然后再./configure ...即可

 

 

 

 

 

 

 # http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz 

http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz 

 

#http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz

 

下载php和依赖包,先前的yum先执行了

 

test -d /home/lnmp || mkdir -p /home/lnmp  #如果不存在就创建

cd /home/lnmp

 

 

wget http://am1.php.net/distributions/php-5.5.38.tar.gz

 

wget https://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

wget https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz


wget https://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

 

 

2安装

编译安装libmcrypt(libmcrypt-2.5.8.tar.gz)

 

cd /home/lnmp

 

 tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

 ./configure --prefix=/usr/local/libmcrypt

 make && make install

 vim /etc/ld.so.conf.d/libmcrypt.conf  # 此选项为将libmcrypt的库文件能让系统找到,不然后面编译安装mcrypt会报错

/usr/local/libmcrypt/lib

 

ldconfig -v # 重新加载库文件

 

编译安装mhash(mhash-0.9.9.9.tar.gz)

cd /home/lnmp

tar -zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure --prefix=/usr/local/libmhash

make && make install

vim /etc/ld.so.conf.d/mhash.conf  # 做添加mhash的库文件让系统找到,不然后面编译安装mcrypt会报错

    /usr/local/mhash/lib

ldconfig -v # 重新加载库文件

 

编译安装mcrypy(mcrypt-2.6.8.tar.gz)

cd /home/lnmp

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

./configure --with-libmcrypt-prefix=/usr/local/libmcrypt/ --with-libmhash-prefix=/usr/local/libmhash/

make && make install

 

 

 

 

==========================

参考8有说到php和nginx要依赖的包,所以要先yum安装,或者源码安装,里面都有说明

http://www.cnblogs.com/mingerlcm/p/6793678.html?utm_source=itdadao&utm_medium=referral

 

yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cmake 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* 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

 

没有libmcrypt,先更新yum

http://jingyan.baidu.com/article/03b2f78c6dd0ce5ea337ae6d.html

 

yum  install epel-release  //扩展包更新包

yum  update //更新yum源

yum install libmcrypt libmcrypt-devel mcrypt mhash  

 

 

cd /home/lnmp

tar -zvxf php-5.5.38.tar.gz

cd /home/lnmp/php-5.5.38/

 

 

http://blog.csdn.net/jovenlu/article/details/14170467

 

 

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-mcrypt  --with-pdo-mysql --enable-mbstring  --enable-opcache --with-openssl --enable-fpm --with-jpeg-dir  --with-png-dir

 

 # --with-freetype-dir  --with-libxml-dir  —with-zlib-dir

 

make && make install

 

1.复制配置文件到指定目录,并修改Apache的配置文件

 

 

 

http://blog.csdn.net/ei__nino/article/details/8598490

onfigure: error: Cannot find ldap libraries in /usr/lib

解决办法:

cp -frp /usr/lib64/libldap* /usr/lib/


然后再./configure ...即可

 

 

make && make install

 

 

9、安装php

 

 

tar -zvxf php-5.5.38.tar.gz

cd php-5.5.38

./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=/data/mysql/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-zlib-dir=/usr/local/zlib  --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   

make  && make install 

 

cp php.ini-production /usr/local/php/etc/php.ini  #复制php配置文件到安装目录

rm -rf /etc/php.ini  #删除系统自带配置文件

ln -s /usr/local/php/etc/php.ini /etc/php.ini   #添加软链接到 /etc目录

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf  #拷贝模板文件为php-fpm配置文件

ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf  #添加软连接到 /etc目录

 

 

 

 

 

vi /usr/local/php/etc/php-fpm.conf #编辑

 

user = www #设置php-fpm运行账号为www

group = www #设置php-fpm运行组为www

pid = run/php-fpm.pid #取消前面的分号

:wq! #保存退出

 

设置 php-fpm开机启动

cp /soft/php-5.5.38/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录

chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限

chkconfig php-fpm on #设置开机启动

 

 

 

 

 

 

 

 

 

 

 

 

./configure --prefix=/usr/local/php -with-apxs2=/usr/local/apache/bin/apxs -with-mysql=/usr/local/mysql --with-gd --with-mcrypt  --with-pdo-mysql --enable-mbstring  --enable-opcache --with-openssl --enable-fpm --with-jpeg-dir  --with-png-dir  --with-freetype-dir  --with-libxml-dir  —with-zlib-dir

 

make && make install

 

./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=/data/mysql/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-zlib-dir=/usr/local/zlib  --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  

 

 

 

 

 

 cp /usr/local/src/php-5.5.38/php.ini-development /usr/local/php/lib/php.ini

 

 

 

与ngin关联

-------------------------------------

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

---------------------------------

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

----------------------------------------

cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf-2016-7-1.back

修改配置

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

 

 

 

 

nginx重写

  location / {

            root   /usr/local/httpd/htdocs/wordpress/;   //一定要存在,正确的

            index  index.php index.html index.htm;

if (-f $request_filename/index.html){

 rewrite (.*) $1/index.html break;

 }

if (-f $request_filename/index.php){

 rewrite (.*) $1/index.php;

 }

if (!-f $request_filename){

 rewrite (.*) /index.php;

 }

 

          }

mkdir /scripts

Vim 1.php

 

phpinfo()

 

 

 

 

 

15.安装nginx

参考18宋虎详

 

1)依赖安装

nginx服务器依赖库pcre     对应的php要开启php-fpm

安装apache时,pcre已经安装 rpm -qa | grep

 

安装php的php-fpm运行模式。在php-5.3.28以后的版本默认里面就存在php-fpm模块,只需要在编译安装php的时候,启用这个模块即可。在编译configure的时候,指定一个选项 —enable-fpm

php安装时已经打开

 

 

2)安装

 

cd /home/lnmp

tar -zvxf nginx-1.12.1.tar.gz

cd /home/lnmp/nginx-1.12.1

 

./configure --prefix=/usr/local/nginx  #-with-pcre=/usr/local/pcre

make && make install 

 

启动nginx

/usr/local/nginx/sbin/nginx

export PATH=$PATH:/usr/local/nginx/sbin #加到系统变量

 

如果apache开启了,在启动nginx会端口冲突

把nginx端口改为8080之类的.

不然先关闭apacje

pkill -9 httpd

 

ngin网站根目录

/usr/local/nginx/html/

===============

 

nginx 服务器重启命令,关闭

nginx -s reload  :修改配置后重新加载生效

nginx -s reopen  :重新打开日志文件

nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

 

关闭nginx:

nginx -s stop  :快速停止nginx

         quit  :完整有序的停止nginx

 

其他的停止nginx 方式:

 

ps -ef | grep nginx

 

kill -QUIT 主进程号     :从容停止Nginx

kill -TERM 主进程号     :快速停止Nginx

pkill -9 nginx          :强制停止Nginx

16.nginx整合php

安装php时已经开启了php-fpm,也就是编译时  —enable-fpm

先复制配置文件

 

 cd /usr/local/php/etc/

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

开启php-fpm位置

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

 

 

 

整合nginx和PHP

使得nginx能够完成动态的请求,修改如下的nginx.conf文件

http://www.linuxidc.com/Linux/2015-12/126200.htm

 

修改配置:vim /usr/local/nginx/nginx.conf

大概在64行左右,模板已经有支持php-fpm的配置了,去掉#注释,然后重启一下nginx就可以了。

再回到/usr/local/nginx/html目录,编写一个phpinfo()的页面,然后在浏览器中访问这个页面,就能看到php和nginx

 

 

cd /usr/local/nginx/conf

cp nginx.conf nginx.conf.back

vim nginx.conf

!!!!!!配置文件最好复制原本的,很容易出错,我死了好多次

去掉#注释,然后重启一下nginx就可以了。

/usr/local/nginx/sbin/nginx -s reload#重新加载配置文件,就可以不用重启killall -9 nginx #杀掉nginx 进程
/usr/local/nginx/sbin/nginx    #然后启动

 

 

 

 

 

 

 

 

 

如果以后有index.php的文件的请求,则nginx会把请求交给php-fpm处理,php-fpm处理的动态脚本的目录是/scripts目录(动态文件夹的目录可以修改)

重启nginx服务器加载配置

/usr/local/nginx/sbin/nginx -s reload

 

7. 增加一个动态请求的目录

 

增加一个index.php测试文件(内容phpinfo()函数)

 

 

 

 

重启nginx服务器加载配置

/usr/local/nginx/sbin/nginx -s reload

 

检测nginx的配置文件语法是否正确

 

帮助查看

 

 

1.#killall -9 nginx #杀掉nginx 进程
#/usr/local/nginx/sbin/nginx    #然后启动

2.浏览器查看

 

 

 

 

 

 

 

 

 

===============

php.ini

cp /home/lnmp/php-5.5.38/php.ini-development /usr/local/php/lib/php.ini

 

重启

pkill -9 php-fpm

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

 

 

nginx重写

  location / {

            root   /usr/local/httpd/htdocs/wordpress/; 

            index  index.php index.html index.htm;

if (-f $request_filename/index.html){

 rewrite (.*) $1/index.html break;

 }

if (-f $request_filename/index.php){

 rewrite (.*) $1/index.php;

 }

if (!-f $request_filename){

 rewrite (.*) /index.php;

 }

 

          }

 

posted @ 2017-09-25 11:55  wujunbin  阅读(369)  评论(0)    收藏  举报