部署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简要配置的更多相关文章

  1. PXE简要配置过程

    目录 1.所需服务 2.简要配置过程     1.dhcp服务     2.tftp服务     3.提供pxelinux.0配置文件     4.提供系统所需文件 1.所需服务:     dhcp服 ...

  2. lnmp+phpmyadmin配置与出现问题

    本博客归moka同学(新浪微博:moka同学)本人亲自整理,如有使用,请加链接注明出处. lnmp 安装完全后,配置phpmyadmin .其访问方式为 http://202.18.400.379/p ...

  3. CentOS 7 lnmp环境配置laravel项目的问题总结!

    一.最常见的几个问题 1.部署好站点后,访问站点的时候始终是“File Not Found”!(nginx中的路由配置问题) 2.除了根目录可以访问其它的访问全是403问题!(权限问题) 3.除了根目 ...

  4. LNMP的配置与优化

    一.LNMP的下载 LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat/Fedora.Debian/Ubuntu/Raspbian/Deepin VPS或独立主机安 ...

  5. VM虚拟机 Centos7 lnmp环境 配置域名问题 windows浏览器访问的问题

    CentOS7  ip地址为 192.168.0.155 搭有 LNMP集成环境 执行 lnmp vhost add 配置服务器 指定目录的域名 mark.com 这时windows 机器的 浏览器想 ...

  6. [LNMP]——LNMP环境配置

    LNMP=Linux+Nginx+Mysql+PHP Install Nginx //安装依赖包 # yum install openssl openssl-devel zlib-devel //安装 ...

  7. CentOS 下 LNMP 环境配置

    安装配置 Nginx 安装配置 MySQL 安装配置 PHP Nginx 与 PHP-FPM 集成 环境配置验证   LNMP 环境代表 Linux 系统下 Nginx + MySQL + PHP 网 ...

  8. WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机

    版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...

  9. laravel 的lnmp 的配置

    装了lnmp后,一般用 lnmp vhost add 添加网站 一般 只用重写和ssl功能 再发laravel官方的配置 server { listen 80; server_name example ...

随机推荐

  1. 利用Sharepoint 创建轻量型应用之基本功能配置!

    博客同步课程.假设你想跟着视频学习,请跟着例如以下视频: http://edu.csdn.net/course/detail/2097 1.   点击安装程序,出现的界面先期安装完毕准备工具,准备工具 ...

  2. try catch finally的执行顺序

    1.将预见可能引发异常的代码包含在try语句块中. 2.如果发生了异常,则转入catch的执行.catch有几种写法: catch 这将捕获任何发生的异常. catch(Exception e) 这将 ...

  3. 赠 看穿一切的var_dump

    看穿一切的var_dump同学让我送他一首诗,于是作诗如下: 看穿一切被看穿,莫让年少酿毒烟.骄心当制能补拙,拨开云雾见上仙!

  4. python中模块,包,库

    模块:就是.py文件,里面定义了一些函数和变量,需要的时候就可以导入这些模块. 包:在模块之上的概念,为了方便管理而将文件进行打包.包目录下第一个文件便是 __init__.py,然后是一些模块文件和 ...

  5. nodejs搭建简单web服务器!!

    var http = require("http"), url = require("url"), path = require("path" ...

  6. hive与hbase的联系与区别

    hive与hbase的联系与区别: 共同点: 1.hbase与hive都是架构在hadoop之上的.都是用hadoop作为底层存储. 他们的底层是要通过mapreduce分布式计算的,hbase.hi ...

  7. PyQt4工具栏

    工具栏 菜单对程序中的所有命令进行分组防治,而工具栏则提供了快速执行最常用命令的方法. #!/usr/bin/python # -*- coding:utf-8 -*- import sys from ...

  8. poj_1456 贪心

    题目大意 一家超市,要卖出N种物品(每种物品各一个),每种物品都有一个卖出截止日期Di(在该日期之前卖出可以获得收益,否则就无法卖出),且每种物品被卖出都有一个收益值Pi. 卖出每个物品需要耗时1天, ...

  9. centos7 elk install :ELK 安装 6.1.2版本

    参考:http://blog.csdn.net/h952520296/article/details/78873849 (参考) 官网下载:https://www.elastic.co/cn/down ...

  10. NodeJS收发GET和POST请求

    目录: 一 express框架接收 二 接收Get 三 发送Get 四 接收Post 五 发送Post 一 express框架接收 app.get('/',function(req,res) { va ...