LNMP简要配置
部署LNMP环境
nginx[web服务,接收用户的请求]
php [解释器]
yum -y localinstall php-fpm-5.4.<tab> [服务]
mariadb [数据库客户端]
mariadb-server [数据库服务器]
mariadb-devel [依赖包]
php-mysql [php连接mysql的扩展包]
所有服务
[root@proxy lnmp_soft]# netstat -nutlp |grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
[root@proxy lnmp_soft]# netstat -nutlp |grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN /mysqld
[root@proxy lnmp_soft]# systemctl restart php-fpm
[root@proxy lnmp_soft]# netstat -nutlp |grep
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm: mast
nginx+FastCGI
工作原理图:

工作流程:
1、web server 启动时载入fastCGI进程管理器
2、FastCGI进程管理器初始化,启动多个解释器进程
3、当客户端请求到达web server时,FastCGI进程管理器选择并连接一个解释器(php 9000)
4、FastCGI子进程完成处理后返回结果,将标准输出和错误信息从同一连返回web server FastCGI简介
FastCGI是一种常住型的CGI
将CGI解释器进程保持在内存中,进行委会与调度
FastCGI技术目前支持语言有PHP、C/C++、jave、Perl、Python、Ruby等
FastCGI缺点:内存消耗大
配置FastCGI
[root@proxy ~]# grep -v "^;" /etc/php-fpm.d/www.conf
[www]
listen = 127.0.0.1: 监听9000(php-fpm服务)
listen.allowed_clients = 127.0.0.1 允许的客户地址
user = apache 用户
group = apache 用户组
pm = dynamic 模式
pm.max_children =
pm.start_servers =
pm.min_spare_servers =
pm.max_spare_servers =
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
编辑nginx.conf
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
pass the PHP scripts to FastCGI server listening on 127.0.0.1:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
地址重写
rewrite 旧 新 【选项】
redirect 地址栏变,临时重定向
permanent 地址栏变,永久重定向
last 停止执行其他rewrite
break 停止执行其他语句,结束访问
rewrite /a.html /b.html last;
rewrite /b.html /c.html last;
rewrite /c.html /a.html last; 防止死循环 1:访问a.html跳转到b.html
vim /usr/local/nginx/conf/nginx.conf
... ...
server {
listen
server_name localhost;
location / {
rewrite a.html /b.html redirect;
}
#echo "BB" > /usr/local/nginx/html/b.html
#nginx -s reload
2:访问192.168.4.5跳转到www.tmooc.cn
vim /usr/local/nginx/conf/nginx.conf
... ...
server {
listen
server_name localhost;
location / {
rewrite ^/ http://www.tmooc.cn;
} 附加:
访问旧的网站页面,跳转到新的网站相同页面
rewrite ^/(.*) http://www.jd.com/$1;
保留和粘贴
3:不同浏览器访问相同页面返回结果不同
ie http://192.168.4.5/test.html firefox http://192.168.4.5/test.html uc http://192.168.4.5/test.html nginx【内置变量】
vim /usr/local/nginx/conf/nginx.conf
server {
... ...
if ($http_user_agent ~* curl){
rewrite ^/(.*) /curl/$;
}
#cd /usr/local/nginx/html
#echo "" >test.html
#mkdir curl
#echo "" >curl/test.html
#nginx -s reload
firefox http://192.168.4.5/test.html
curl http://192.168.4.5/test.html
4:如果用户访问的页面不存则转到首页
vim /usr/local/nginx/conf/nginx.conf
server {
... ...
if (!-e $request_filename){
rewrite ^/ http://192.168.4.5;
}
#nginx -s reload
易错
1、php服务没有启动
2、nginx配置文件[动静分离] 出现下载页面
3、404 not found 没有此网页或网页位置放错
4、空白页面 脚本写错了
LNMP简要配置的更多相关文章
- PXE简要配置过程
目录 1.所需服务 2.简要配置过程 1.dhcp服务 2.tftp服务 3.提供pxelinux.0配置文件 4.提供系统所需文件 1.所需服务: dhcp服 ...
- lnmp+phpmyadmin配置与出现问题
本博客归moka同学(新浪微博:moka同学)本人亲自整理,如有使用,请加链接注明出处. lnmp 安装完全后,配置phpmyadmin .其访问方式为 http://202.18.400.379/p ...
- CentOS 7 lnmp环境配置laravel项目的问题总结!
一.最常见的几个问题 1.部署好站点后,访问站点的时候始终是“File Not Found”!(nginx中的路由配置问题) 2.除了根目录可以访问其它的访问全是403问题!(权限问题) 3.除了根目 ...
- LNMP的配置与优化
一.LNMP的下载 LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat/Fedora.Debian/Ubuntu/Raspbian/Deepin VPS或独立主机安 ...
- VM虚拟机 Centos7 lnmp环境 配置域名问题 windows浏览器访问的问题
CentOS7 ip地址为 192.168.0.155 搭有 LNMP集成环境 执行 lnmp vhost add 配置服务器 指定目录的域名 mark.com 这时windows 机器的 浏览器想 ...
- [LNMP]——LNMP环境配置
LNMP=Linux+Nginx+Mysql+PHP Install Nginx //安装依赖包 # yum install openssl openssl-devel zlib-devel //安装 ...
- CentOS 下 LNMP 环境配置
安装配置 Nginx 安装配置 MySQL 安装配置 PHP Nginx 与 PHP-FPM 集成 环境配置验证 LNMP 环境代表 Linux 系统下 Nginx + MySQL + PHP 网 ...
- WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机
版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...
- laravel 的lnmp 的配置
装了lnmp后,一般用 lnmp vhost add 添加网站 一般 只用重写和ssl功能 再发laravel官方的配置 server { listen 80; server_name example ...
随机推荐
- swift学习笔记之--类的计算属性
1,Swift中类可以使用计算属性,即使用get和set来间接获取/改变其他属性的值,代码如下 class Calcuator{ ; ; var sum:Int{ get{ return a + b ...
- Python 入门(七)函数
什么是函数 我们知道圆的面积计算公式为: S = πr² 当我们知道半径r的值时,就可以根据公式计算出面积.假设我们需要计算3个不同大小的圆的面积: r1 = 12.34 r2 = 9.08 r3 = ...
- 从spring容器中取出注入的bean
从spring容器中取出注入的bean 工具类,代码如下: package com.hyzn.fw.util; import org.springframework.beans.BeansExcept ...
- OpenGL 4.0 GLSL 基础教程概览——VAO和VBO常用操作接口
(一) OpenGL 4.3 最新渲染管线图 从OpenGL 2.0 到 OpenGL 3.0变化非常大,但从OpenGL 3.0 到OpenGL 4.0 变化不是太大. 着色器程序直接运行在GPU ...
- jQuery中如何解决多库冲突问题
方法一:使用noConflict():舍弃$,$用jQuery代替jQuery.noConflict(); 方法二:自定义变量:舍弃$,新定义一个$y变量来代替$var $y = jQuery.noC ...
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
情况是这样的,某人最近入手一台nexus7,于是在cyanogenmod 将nexus7的原代码下载到本地,编译环境是UBUNTU 12,04 然后编译的时候,出现了如下的错误导致编译失败 <p ...
- JS-提取字符串—>>普通方法VS正则表达式
如下:“23nr qreq2 34fq4 4454gsr 45” [将这一串字符中的数字挑出来,当然人家作伴的不能被分开]. 一.普通方法: <script type="text/ja ...
- Struts2中的OGNL详解 《转》
首先了解下OGNL的概念: OGNL是Object-Graph Navigation Language的缩写,全称为对象图导航语言,是一种功能强大的表达式语言,它通过简单一致的语法,可以任意存取对象的 ...
- ./configure
./configure --prefix=/usr/local/scws --prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/ ...
- 【BZOJ2434】[NOI2011]阿狸的打字机 AC自动机+DFS序+树状数组
[BZOJ2434][NOI2011]阿狸的打字机 Description 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到一台老式的打字机.打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P ...