部署环境:
主机ip地址操作系统nginx172.16.1.100CentOS 7.3 php + memcache172.16.1.110CentOS 7.3 mysql172.16.1.120centos 7.3 memcached172.16.1.130centos 7.3一、环境准备:
搭建LNMP环境(动态解析)
<强> 1,安装nginx 强>
<代码> 1)安装依赖工具包: (root@nginx-server ~) # yum安装gcc - y * pcre-devel openssl-devel zlib-devel使vim 代码>
<代码> 2)创建nginx用户组和用户: (root@nginx-server ~) # groupadd - r nginx,,useradd - r, g nginx - s/bin/false - m nginx 代码>
<代码> 3)解压源码包,配置,及编译安装: (root@nginx-server ~) #焦油zxf nginx-1.8.0.tar.gz # cd nginx-1.8.0 root@nginx-server ~ [root@nginx-server nginx-1.8.0] # ./configure——help # #可以查看自己需要的模块,,或取消的模块——没有 #根据自己的需求添加不同的模块 [root@nginx-server nginx-1.8.0] # ./configure——prefix=/usr/地方/nginx——用户=nginx——组=nginx \ 比;,——with-http_stub_status_module with-http_ssl_module——with-http_dav_module——with-http_flv_module \ 比;——with-http_mp4_module with-http_gzip_static_module——with-http_gzip_static_module \ 比;,——with-http_addition_module with-http_sub_module——with-pcre [root@nginx-server nginx-1.8.0] #做,,制作安装 #优化路径并检查: [root@nginx-server nginx-1.8.0] # ln - s/usr/local/nginx/sbin/nginx,/usr/地方/sbin/[root@nginx-server nginx-1.8.0] # nginx - t/usr/local/nginx/conf/nginx. nginx:配置文件配置语法好/usr/local/nginx/conf/nginx. nginx:配置文件配置测试是成功的 #启动服务: [root@nginx-server nginx-1.8.0] # nginx [root@nginx-server nginx-1.8.0] # netstat -anput | grep nginx tcp,,,,0,0 0.0.0.0:80大敌;,,,,,,0.0.0.0:*,,,,,,,听,,21416/nginx:大师 80 #开启防火墙的端口: [root@nginx-server nginx-1.8.0] # firewall-cmd——添加一个端口=80/tcp,永久性的 成功 [root@nginx-server nginx-1.8.0] # firewall-cmd——重载 成功代码>
<强> 2,安装php 强>
<代码> 1)安装依赖工具包: (root@php-server ~) # yum - y,安装gcc *, pcre-devel openssl-devel zlib-devel libxml2-devel libcurl-devel bzip2-devel使vim 代码>
<代码> 2)安装php的加密扩展模块libmcrypt (root@php-server ~) #焦油zxf libmcrypt-2.5.7.tar.gz # cd libmcrypt-2.5.7 root@php-server ~ [root@php-server libmcrypt-2.5.7] # ./configure——prefix=/usr/地方/libmcrypt,,使,,使安装代码>
<代码> 3)安装php: (root@php-server ~) #焦油zxf php-5.6.27.tar.gz # cd php-5.6.27 root@php-server ~ [root@php-server php-5.6.27] # ./configure,——prefix=/usr/地方/php5.6,——在mysql=mysqlnd \ 比;,——with-pdo-mysql=mysqlnd with-mysqli=mysqlnd——使用openssl enable-fpm,——enable-sockets \ 比;——enable-sysvshm, enable-mbstring——with-freetype-dir with-jpeg-dir,——with-png-dir \ 比;——with-zlib with-libxml-dir=/usr——启用xml,——with-mhash with-mcrypt=/usr/地方/libmcrypt \ 比;——with-config-file-path=/etc with-config-file-scan-dir=/etc/php。d,——with-bz2, enable-maintainer-zts 代码>
配置参数解释:
<代码>——prefix=/usr/地方/php7.2 #指定php的安装路径 mysqlnd (mysql本地司机)# php源码提供的mysql驱动连接代码 ——使用mysql=mysqlnd #支持mysql ——with-pdo-mysql=mysqlnd #支持pdo模块,php执行命令通过pdo语法来连接后端的数据库 ——with-mysqli=mysqlnd, #执行libmysql模块,也叫mysql的增强模块 ——使用openssl #支持ssl ——enable-fpm, #开启php的进程管理器 ——enable-sockets #开启插座支持,套接字本职位编程接口(API) ——enable-sysvshm #开启系统共享内存支持 ——enable-mbstring, #支持多字节字符串,如中文就是多字节字符串,一个汉字代表2个字节 ——with-freetype-dir #支持freetype(字体引擎),需要借助freetype-devel,字体解析工具 ——with-jpeg-dir,#支持jepg和png图片,php在解析的过程会生成一些图像 ——with-png-dir ——with-zlib, #数据压缩用的函数库 ——with-libxml-dir=/usr #打开libxml2库支持的xml文件 xml——启用xml, #开启文件传输 ——with-mhash #支持mhash, mhash可用于创建校验数值,消息摘要,消息认证码,以及无需要原文等待关键信息保存(如密码)等 -with-mcrypt=/usr/地方/libmcrypt # php中加密支持扩展库 ——with-config-file-path=/etc, #配置文件路径 ——with-config-file-scan-dir=/etc/php。d #配置文件扫描路径 ——with-bz2 #支持bzip2压缩 ——enable-maintainer-zts #支持php多线程扩展memcache缓存服务器的安装和配置