centos7 源码部署LNMP

一、环境

系统环境:centos 7.4 64位

Nginx:1.7.9

MySQL: 5.7.20 (二进制包)

PHP:5.6.37

二、Ngin 安装

  1. Nginx部署
  2. yum install  pcre-devel zlib-devel -y (如果不行就用源码安装)安装nginx 依赖包
  3. wget http://nginx.org/download/nginx-1.7.9.tar.gz
  4. tar zxvf nginx-1.7.9.tar.gz -C /usr/local/
  5. ./configure --prefix=/usr/local/nginx
  6. make  && make install

三、MySQL 安装

链接:https://www.cnblogs.com/zoulixiang/p/9549170.html

四、PHP 安装

1、安装PHP依赖包, Lib库

yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel  libxslt-devel -y

2、yum中没有的安装包 需自行下载安装

mkdir -p /usr/local/

cd /usr/local/

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar xzf libiconv-1.14.tar.gz

./configure --perfix=/usr/local/libiconv

make && make install

2、yum添加epel第三方源 安装libmcrypt mhash mcrypt库

Wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum install libmcrypt-devel mhash mcrypt -y

3、编译安装

tar zxf php-5.6.37.tar.gz

Cd tar zxf php-5.6.35

./configure \

--prefix=/usr/local/php \

--with-mysql-sock=/home/usr/local/mysql5.7/tmp/mysql_3306.sock \

--with-mysqli=/home/usr/local/mysql5.7/bin/mysql_config \

--with-pdo-mysql=/home/usr/local/mysql5.7/bin/mysql_config \

--with-pdo-mysql=/home/usr/local/mysql5.7/bin/mysql_config \

--with-openssl \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-libdir=/usr/local/lib64 \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--enable-ftp

make && make install

4、初始化php.ini文件

cd /php-5.6.37 # 进入安装包目录

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

5、初始化PHP服务(FastCGI)配置文件

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

6、开启php-fpm 服务

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

7、查看php进程

centos7 源码部署LNMP

五、php安装mysql 扩展

1、由于PHP7已经完全移除了MySQL的扩展支持(由mysqli与mysqlnd取代),因此一些老的软件在升级PHP版本后会报类似mysql_connect()函数未定义的错误,一般建议使用新的PHPmysqli或者pdo扩展进行替换。当然也可以检出遗留版本的支持MySQL扩展的PHP7代码自行编译安装了,不过需要注意的就是MySQL扩展可是完全没有后续更新的了。

2、查看自身的扩展

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

centos7 源码部署LNMP

3、安装目录查看自身扩展

centos7 源码部署LNMP

4、[root@web ext]# git clone https://github.com/php/pecl-database-mysql  --recursive

Cloning into 'mysql'...

remote: Counting objects: 145, done.

remote: Total 145 (delta 0), reused 0 (delta 0), pack-reused 145

Receiving objects: 100% (145/145), 88.41 KiB | 0 bytes/s, done.

Resolving deltas: 100% (65/65), done.

Checking connectivity... done.

5、编译安装Mysql 扩展

[root@web ext]#cd mysql

[root@web mysql]# ls

config.m4 config.w32 CREDITS LICENSE mysql.mak mysql_mysqlnd.h package.xml php_mysql.c php_mysql.h php_mysql_structs.h README.md tests

[root@opstrip.com mysql]# /usr/local/php/bin/phpize

Configuring for:

PHP Api Version:   20151012

Zend Module Api No:  20151012

Zend Extension Api No: 320151012

[root@web mysql]# ./configure --with-php-config=/usr/local/php/bin/php-config

[root@web mysql]#  ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/

mysql.so opcache.a opcache.so

6、在vi /usr/local/php/lib/php.ini 添加一行

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/mysql.so

centos7 源码部署LNMP

六、重启php即可生效

centos7 源码部署LNMP

上一篇:markdown 基本语法(转载)


下一篇:android 编译模块