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 ...
随机推荐
- matlab彩色图像插值
软件是MATLAB R2014b 使用的是matlab中已有的函数imresize(); 彩色图像分别对R.G.B三个通道进行插值,之后融合.[imresize函数不用,可以直接插值] clear;c ...
- 一个简单的Golang实现的HTTP Proxy
http://blog.csdn.net/michael__li/article/details/53941312
- 工作流JBPM_day01:4-管理流程定义
工作流JBPM_day01:4-管理流程定义 管理流程(流程定义) 部署(添加) 查询 删除 查看流程图(xxx.png) -- 修改 --> 没有真正的修改,而是使用“再次部署+使用最新版本启 ...
- POJ 1946 Cow Cycling(抽象背包, 多阶段DP)
Description The cow bicycling team consists of N (1 <= N <= 20) cyclists. They wish to determi ...
- ionic 页面加载事件及loading动画
页面加载完成事件(非刷新情况下,页面切换是不会重复触发此事件的,只在第一次进入页面时触发,需要重复触发的话请使用 $ionicView.enter 事件) angular.module('app.co ...
- shell基础篇(四)算术运算
---内容来源于http://www.jb51.net/article/31232.htm shell中的赋值和操作默认都是字符串处理,1.错误方法举例 a) var=1+1 echo $var 输出 ...
- hadoop程序MapReduce之MaxTemperature
需求:求每年当中最高的温度 样本:temp.log 2016080623 2016072330 2015030420 输出结果:2016 30 2015 20 MapReduce分析设计: Mappe ...
- Java中自己定义缓存方式
说说自己在开发中经常用到的写法. /** * 数据缓存 * @author * */public class DataCache { /** 对象缓存*/ public static Ma ...
- MQTT的学习研究(七)基于HTTP POST MQTT 发布消息服务端使用
参阅官方文档 http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21220_.htm ...
- centos7 elk install :ELK 安装 6.1.2版本
参考:http://blog.csdn.net/h952520296/article/details/78873849 (参考) 官网下载:https://www.elastic.co/cn/down ...