一、软件概述

 [root@webserver ~]# cat /etc/redhat-release
CentOS Linux release 7.2. (Core)
[root@webserver ~]# uname -r
3.10.-.el7.x86_64
 [root@webserver ~]# nginx  -V
nginx version: nginx/1.10.3

二、软件安装

1. 通过yum安装必要的开发包到操作系统

[root@webserver ~]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo 
[root@webserver ~]# yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel ssse2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers ncurses ncurses-devel curl curl-devel gd libtool libtool-libs kernel-devel autoconf fontconfig-devel libXpm-devel php-mcrypt libmcrypt-devel

2. 安装nginx

 [root@webserver ~]# cd /usr/local/src/
[root@webserver /usr/local/src]# wget https://www.openssl.org/source/openssl-1.1.0b.tar.gz
[root@webserver /usr/local/src]# tar xf openssl-1.1.0b.tar.gz
[root@webserver /usr/local/src]# cd
[root@webserver ~]# groupadd nginx
[root@webserver ~]# useradd -g nginx -d /usr/local/nginx -s /sbin/nologin nginx
[root@webserver ~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz
[root@webserver ~]# tar xf nginx-1.10..tar.gz
[root@webserver ~]# cd nginx-1.10./
[root@webserver ~/nginx-1.10.]# ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-openssl=/usr/local/src/openssl-1.1.0b --with-http_v2_module
[root@webserver ~/nginx-1.10.]# make
[root@webserver ~/nginx-1.10.]# make install
[root@webserver ~]# nginx
[root@webserver ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /zabbix_agentd
tcp6 ::: :::* LISTEN /sshd
tcp6 ::: :::* LISTEN /zabbix_agentd

3. yum安装mariadb,如果要安装MySQL,请参照下面链接:

https://www.cnblogs.com/cyleon/p/10040728.html

 [root@webserver ~]# yum install mariadb mariadb-server mariadb-devel -y

4. 安装PHP

A. 下载安装libmcrypt库(加密算法扩展)

[root@webserver ~]#wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2
[root@webserver ~]#tar xf libmcrypt-2.5..tar.bz2
[root@webserver ~]#cd libmcrypt-2.5./
[root@webserver libmcrypt-2.5.~]#./configure && make && make install

B. 下载安装mhash库(提供了一个统一的接口,有大量的哈希算法)

 [root@webserver ~]# wget https://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
[root@webserver ~]# tar xf mhash-0.9.9.9.tar.gz -C /usr/local/src/
[root@webserver ~]# cd /usr/local/src/mhash-0.9.9.9/
[root@webserver /usr/local/src/mhash-0.9.9.9]# ./configure && make && make install

C. 创建软链接

 [root@webserver ~]# ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
[root@webserver ~]# ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
[root@webserver ~]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
[root@webserver ~]# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
[root@webserver ~]# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
[root@webserver ~]# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
[root@webserver ~]# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
[root@webserver ~]# ln -s /usr/local/lib/libmhash.so. /usr/lib/libmhash.so.
[root@webserver ~]# ln -s /usr/local/lib/libmhash.so.2.0. /usr/lib/libmhash.so.2.0.
ln -s /usr/local/bin/libmcrypt-config /usr/lib64//libmcrypt-config
[root@webserver ~]# vim /etc/ld.so.conf #配置文件增加如下内容
/usr/local/lib
[root@webserver ~]# ldconfig

D. 下载安装mcrypt库(可实现加密解密功能,即能将明文加密,也要以密文还原)

 [root@webserver ~]# wget https://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
[root@webserver ~]# tar xf mcrypt-2.6..tar.gz -C /usr/local/src/
[root@webserver ~]# cd /usr/local/src/mcrypt-2.6./
[root@webserver /usr/local/src/mcrypt-2.6.]# ./configure && make && make install

E. 下载安装libiconv库(常用的编码转换库,支持常用的多种编码之前的转换)

 [root@webserver ~]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[root@webserver ~]# tar xf libiconv-1.14.tar.gz -C /usr/local/src/
[root@webserver ~]# cd /usr/local/src/libiconv-1.14/
[root@webserver /usr/local/src/libiconv-1.14]# ./configure --prefix=/usr/local/libiconv && make && make install 若在./configure中有如下报错:
In file included from progname.c:::
./stdio.h::: error: ‘gets’ undeclared here (not in a function)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
^
make[]: *** [progname.o] Error
make[]: Leaving directory `/usr/local/src/libiconv-1.14/srclib'
make[]: *** [all] Error
make[]: Leaving directory `/usr/local/src/libiconv-1.14/srclib'
make: *** [all] Error 2 解决方法:
[root@webserver /usr/local/src/libiconv-1.14]# vim srclib/stdio.in.h +698
删除些行内容
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
添加如下内容
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

F. 下载安装PHP

 [root@webserver ~]# wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
[root@webserver ~]# tar xf php-5.6..tar.gz -C /usr/local/src/
[root@webserver ~]# cd /usr/local/src/php-5.6./
[root@webserver /usr/local/src/php-5.6.]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql --with-mysqli --with-iconv \
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd \
--enable-gd-native-ttf --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-ftp --with-gettext --with-libdir=lib6
[root@webserver /usr/local/src/php-5.6.]# make && make install #进行编译安装
[root@webserver /usr/local/src/php-5.6.]# cp php.ini-production /usr/local/php/etc/php.ini #拷贝配置文件模板
[root@webserver /usr/local/src/php-5.6.]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝Fastcgi配置文件
[root@webserver /usr/local/src/php-5.6.]# grep '^[a-z]' /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
emergency_restart_threshold =
emergency_restart_interval =
process_control_timeout =
daemonize = yes
user = nginx
group = nginx
listen = 127.0.0.1:
pm = dynamic
pm.max_children =
pm.start_servers =
pm.min_spare_servers =
pm.max_spare_servers =
[root@webserver ~]# chown -R nginx.nginx /usr/local/php/ 编译报错:
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
解决方法:
[root@webserver /usr/local/src/php-5.6.]# vim /etc/ld.so.conf.d/local.conf #创建此文件加入如下内容
/usr/local/lib64
[root@webserver /usr/local/src/php-5.6.]# ldconfig -v

G. 整合nginx和php

修改nginx配置文件,打开如下注释 
[root@webserver ~]# vim /etc/nginx/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /etc/nginx/html$fastcgi_script_name; #红色部分为nginx发布站点的绝对路径
include fastcgi_params;
}

三、启动服务

 [root@webserver ~]# nginx
[root@webserver ~]# /usr/local/php/sbin/php-fpm
[root@webserver ~]# systemctl start mariadb
[root@webserver ~]# mysqladmin -uroot password 'guoguo' #配置数据库密码

四、LNMP服务验证

 [root@webserver ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm: mast
tcp 0.0.0.0: 0.0.0.0:* LISTEN /mysqld
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /zabbix_agentd
tcp6 ::: :::* LISTEN /sshd
tcp6 ::: :::* LISTEN /zabbix_agentd 查看phpinfo:
[root@webserver ~]# cat /etc/nginx/html/phpinfo.php
<?php
phpinfo();
?>
http://192.168.7.78/phpinfo.php
查看连接MySQL状态:
[root@webserver ~]# cat /etc/nginx/html/mysql.php
<?php
$link=MySQL_connect('127.0.0.1','root','guoguo');
if(!$link) echo 'ERROR!';
else echo 'OK!';
MySQL_close();
?>

五、php安装其它模块

1. 后期需要安装freetds作为PHP连接mssql的扩展,安装freetds

 [root@webserver ~]# wget  http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
[root@webserver ~]# tar xf freetds-stable.tgz -C /usr/local/src/
[root@webserver ~]# cd /usr/local/src/freetds-0.91/ #tdsver7.0连接SQL Server 2000
#tdsver8.0连接SQL Server 2005或2008
[root@webserver /usr/local/src/freetds-0.91]# ./configure --prefix=/usr/local/freetds0. --enable-msdblib --with-tdsver=8.0
[root@webserver /usr/local/src/freetds-0.91]# make && make install
[root@webserver ~]# echo "/usr/local/freetds0.91/lib/" > /etc/ld.so.conf.d/freetds.conf #配置动态连接库
[root@webserver ~]# ln -s /usr/local/freetds0./lib/libsybdb.so.5.0. /usr/local/freetds0./lib/libsybdb.so.
[root@webserver ~]# ldconfig
[root@webserver /usr/local/freetds0./bin]# ./tsql -C #测试是否安装成功
Compile-time settings (established with the "configure" script)
Version: freetds v0.
freetds.conf directory: /usr/local/freetds0./etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no

2. 安装freetds的php扩展

 [root@webserver ~]# cd /usr/local/src/php-5.6./ext/mssql/                                        #此目录为PHP源码的安装目录
[root@webserver /usr/local/src/php-5.6./ext/mssql]# /usr/local/php/bin/phpize
[root@webserver /usr/local/src/php-5.6./ext/mssql]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds0./
[root@webserver /usr/local/src/php-5.6./ext/mssql]# make && make install
 [root@webserver ~]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ #php5.4之后已经自动把扩展复制到了此目录
mssql.so  opcache.a  opcache.so
[root@webserver ~]# vim /usr/local/php/etc/php.ini #添加扩展配置到php.ini
extension = '/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/mssql.so' #最后重启web服务即可

3. 安装pdo_dblib模块

 [root@webserver ~]# cd /usr/local/src/php-5.6./ext/pdo_dblib/
[root@webserver /usr/local/src/php-5.6./ext/pdo_dblib]# /usr/local/php/bin/phpize
[root@webserver /usr/local/src/php-5.6./ext/pdo_dblib]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-dblib=/usr/local/freetds0./
[root@webserver /usr/local/src/php-5.6./ext/pdo_dblib]# make && make install
[root@webserver ~]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-/pdo_dblib.so
/usr/local/php/lib/php/extensions/no-debug-non-zts-/pdo_dblib.so
[root@webserver ~]# vim /usr/local/php/etc/php.ini
[root@webserver ~]# killall php-fpm
[root@webserver ~]# /usr/local/php/sbin/php-fpm

4. 安装memcached扩展

  php的扩展memcache,不支持cas,所以要安装memcached扩展,memcached扩展是基于libmemcached,所以要先安装libmemcached。

  A. 先编译安装libmemcached

# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
# tar xf libmemcached-1.0.
# cd libmemcached-1.0./
./configure --with-memcached --enable-sasl
# make 报错:
clients/memflush.cc: In function ‘int main(int, char**)’:
clients/memflush.cc::: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (opt_servers == false)
^~~~~
clients/memflush.cc::: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (opt_servers == false)
^~~~~
make[]: *** [clients/memflush.o] Error
make[]: Leaving directory `/root/libmemcached-1.0.'
make: *** [all] Error
解决方法:
# vim clients/memflush.cc
替换42和51行的以下内容
if (opt_servers == false)
替换为
if (!opt_servers) 参考链接:https://src.fedoraproject.org/cgit/rpms/libmemcached.git/plain/libmemcached-build.patch
重新编译安装
# make && make install

  B. 编译安装php扩展php-memcached,通过这个可以用php来操作memcached

wget http://pecl.php.net/get/memcached-2.2.0.tgz
# tar xf memcache-2.2..tgz
# cd memcache-2.2./
# /usr/local/php/bin/phpize
# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --disable-memcached-sasl
# make && make install
加入php.ini中引用memcached.so即可
extension=memcached.so

5. imagick扩展(切图和缩图效果)安装

# wget http://www.imagemagick.org/download/ImageMagick.tar.gz
# tar -xf ImageMagick
# cd ImageMagick-7.0.-/
# ./configure --prefix=/usr/local/imagemagick
# make && make install # wget http://pecl.php.net/get/imagick-3.4.3.tgz
# tar -xf imagick-3.4..tgz
# cd imagick-3.4.
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick
# make && make install

6. 安装redis扩展

# wget http://pecl.php.net/get/redis-3.1.0.tgz
# tar xf redis-3.1..tgz
# cd redis-3.1.
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
# echo "extension=redis.so" >> /usr/local/webserver/php/etc/php.ini

7.安装yar扩展

# wget http://pecl.php.net/get/yar-1.1.1.tgz
# tar xf yar-1.1..tgz
# cd yar-1.1.
# /usr/local/webserver/php/bin/phpize
# ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
# make & make install
# echo "extension=yar.so" >> /usr/local/webserver/php/etc/php.ini

8. 安装openssl扩展

# cd php-5.4./ext/openssl/
# 运行phpize有如何报错,找不到config.m4
# /usr/local/webserver/php-5.4./bin/phpize
Cannot find config.m4.
Make sure that you run '/usr/local/webserver/php-5.4.24/bin/phpize' in the top level source directory of the module
# 解决办法:
# ls
config0.m4 config.w32 CREDITS openssl.c openssl.dsp openssl.mak php_openssl.h README tests xp_ssl.c
# mv config0.m4 config.m4
# /usr/local/webserver/php-5.4./bin/phpize
# ./configure --with-php-config=/usr/local/webserver/php-5.4./bin/php-config
# make && make install
# echo "extension = openssl.so" >> /usr/local/webserver/php/etc/php.ini

9. 安装pdo_mysql扩展

# cd php-5.4./ext/pod_mysql/
# /usr/local/webserver/php-5.4./bin/phpize
# ./configure --with-php-config=/usr/local/webserver/php-5.4./bin/php-config
# make && make install
# echo "extension = pod_mysql.so" >> /usr/local/webserver/php/etc/php.ini

LNMP的安装--详细版的更多相关文章

  1. Appium 安装详细版教程

      1.安装Appium Python Client包 输入命令  pip install Appium-Python-Client  

  2. MySQL5.7.25解压版安装详细教程

    MySQL5.7.25解压版安装详细教程 安装步骤: 1.首先,你要下载MySQL解压版,下载地址:https://www.mysql.com/downloads/,图解: 2.解压安装包,根据自己的 ...

  3. phpStudy模式下安装ssl证书,详细版

    phpStudy模式下安装ssl证书,详细版 2017年12月16日 14:27:38 骑着蚂蚁追大象 阅读数:4232 标签: phpstudy安装ssl证书 更多 个人分类: php   版权声明 ...

  4. MySQL 5.7.20绿色版安装详细图文教程

    MySQL 5.7.20绿色版安装详细图文教程 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle旗下产品.这篇文章主要介绍了MySQL 5.7.20绿色版安装 ...

  5. MySQL安装详细教程(数据库免安装版)

    MySQL安装详细教程(数据库免安装版)mysql-5.7.33-winx64.zip 一.软件下载 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,属于 Oracle 旗下产 ...

  6. lnmp 一键安装

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian/Deepin Server/Aliyun/Amazon/Mint Linux发行版 需要5GB以上硬盘剩 ...

  7. lnmp 一键安装配置

    l系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian/Deepin Server/Aliyun/Amazon/Mint Linux发行版 需要5GB以上硬盘 ...

  8. iOS App上架流程(2016详细版)

    iOS App上架流程(2016详细版) 原文地址:http://www.jianshu.com/p/b1b77d804254 感谢大神整理的这么详细 一.前言: 作为一名iOSer,把开发出来的Ap ...

  9. LNMP编译安装教程

    LNMP编译安装教程 此次安装在Centos上,我采用的CentOS的版本是:CentOS release 6.5 (Final) 可以通过以下命令查看:lsb_release -a 一.准备工作: ...

随机推荐

  1. ZTree 使用范例

    http://www.treejs.cn/v3/api.php zTree v3.x 入门指南 Api 文档 https://github.com/zTree/zTree_v3 下载ZTree v3 ...

  2. Spring framework 反序列化的漏洞

    理解这个漏洞需要先看freebuff上的jdni的小例子. jndi注入在jdk8u121绕过参考这俩篇文章: https://bl4ck.in/tricks/2019/01/04/JNDI-Inje ...

  3. selenium + python自动化测试unittest框架学习(五)webdriver的二次封装

    因为webdriver的api方法很长,再加上大多数的定位方式是以xpath方式定位,更加让代码看起来超级长,为了使整体的代码看起来整洁,对webdriver进行封装,学习资料来源于虫师的<se ...

  4. VC++6.0中碰到Cannot access the ClassView information file.ClassView information will not be avaible.的解决方法

    一般情况下是由于类视图文件损坏了,这是经常会发生的现象. 解决步骤: 1.关闭工程,2.删除工程下.clw .ncb 文件及/debug目录,3.重建工程build all. 具体解释如下: dsp ...

  5. ThinkPHP里面用原生SQL

    public function rewardlog(){ $adminNav = C('ADMIN_NAV'); $adminNav[1]['class'] = 'cur'; $this->as ...

  6. select和epoll

    C/S编程模型,对每一个客户端都要开辟一个新的线程,效率必定低下.普通select模型是开辟两个线程,一个用来监听客户端的连接,另一个用于处理客户端请求. fd_set set; FD_ZERO(&a ...

  7. C语言函数指针 和 OC-Block

    C语言函数指针 和 OC-Block 一. C语言函数指针 关于函数指针的知识详细可参考:http://www.cnblogs.com/mjios/archive/2013/03/19/2967037 ...

  8. java核心技术-多线程之基本使用

    多线程程序好处就是可以提高cpu使用率和系统的性能.这里举个例子,民以食为天,咱们以餐馆为例(后面基本上都用餐馆作为对象),后面如果没有特殊说明均采用本节相关术语,围绕餐馆我们可以抽象出如下几个角色以 ...

  9. MySQL8.0.12版本的数据库驱动

    jdbcDriver=com.mysql.cj.jdbc.DriverjdbcUrl=jdbc:mysql://127.0.0.1:3306/jtsys?useUnicode=true&cha ...

  10. Solr 同义词搜索

    1.  进入solr配置目录 cd /usr/local/solr/solrhome/collection1/conf vi schema.xml 增加配置节 <fieldType name=& ...