搭建LNMP+CI环境
- 安装 Nginx, MySQL 和 PHP 软件包,执行以下命令
yum install -y nginx mariadb-server mariadb php php-fpm php-mysql
启动并检查 Nginx 和 PHP 的安装情况
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; server {
listen 80 default_server;
#listen [::]:80 default_server;
server_name _;
root /var/www/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / { } location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
启动nginx服务器
检查php环境搭建,phpinfo();
启动 PHP-FPM 进程:
service php-fpm start 启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口
netstat -nlpt | grep php-fpm
chkconfig php-fpm on 启动并配置 MySQL
systemctl start mariadb
配置密码, 这里默认使用密码QcloudLabPASSWORD
mysqladmin -u root password 'QcloudLabPASSWORD'
登录 MySQL
mysql -u root -pQcloudLabPASSWORD
创建数据库 CI
create database CI;
退出 MySQL, 回到 Bash shell 下载 CI 框架
实践 CI 框架
- 知识准备这里将会演示如何通过 CI 框架, 使得访问 http://123.207.8.59/index.php/firstrun/hello 返回 "Hello, World"在 CI 的路由规则中, 路由的匹配规则:
- 用户访问的 URL 为 http://123.207.8.59/index.php/firstrun/hello
- 此时 CI 会查找 application/controller 目录下名为
Firstrun.php的 PHP 文件 - 该 PHP 文件有个叫
Firstrun的 class - 该 class 有一个叫
hello的方法, 该方法处理对此 URL 地址的请求并作出响应
编写调用代码
<?php
defined('BASEPATH') OR exit('No direct script access allowed'); class Firstrun extends CI_Controller { public function hello() {
echo 'Hello World';
}
}
修改nginx配置并重启
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; server {
listen 80 default_server;
#listen [::]:80 default_server;
server_name _;
root /var/www/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
# 这里使用try_files进行url重写,不用rewrite了。
try_files $uri $uri/ /index.php?$query_string;
} location ~ .php($|/) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
重启 Nginx
大功告成
搭建LNMP+CI环境的更多相关文章
- 图文详解如何快捷搭建LNMP服务环境
上一篇与大家一起学习了下如何搭建LAMP环境的知识,今天小编再和大家分享下如何快捷地搭建LNMP环境,并搭建起一个网站.Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/S ...
- 使用Docker搭建LNMP开发环境
1.什么是Docker Docker 使用 Google 公司推出的 Go 语言 进行开发实现,基于 Linux 内核的 cgroup,namespace,以及 AUFS 类的 Union FS 等技 ...
- Mac OS上搭建LNMP开发环境
1. 概述 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构.Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统.代表版本有:debian.c ...
- Vmware搭建LNMP环境(Centos7+Nginx+Mysql+PHP7.1.8)
参考:1.Linux学习之CentOS(一)----在VMware虚拟机中安装CentOS 7(图文教程) 2.Centos7搭建LNMP环境 3.MySQL5.7修改默认root密码 4.CentO ...
- Mac OSX 下配置 LNMP开发环境
不久前负责了一个项目需要配置PHP7的开发环境,因为之前所有的项目用的是PHP5的,所以研究了这些东西,但是很遗憾,电脑出了问题,不得已重装了系统,然后你懂得...什么都没有了,要重新来过.. 虽然本 ...
- 五分钟用Docker快速搭建Go开发环境
挺早以前在我写过一篇用 `Docker`搭建LNMP开发环境的文章:[用Docker搭建Laravel开发环境](http://mp.weixin.qq.com/s?__biz=MzUzNTY5MzU ...
- CentOS6.6搭建LNMP环境
CentOS6.6搭建LNMP环境 1.设置yum源,本地安装依赖包 1 yum -y install gcc gcc-c++ automake autoconf libtool make 2.下载依 ...
- CentOS下Web服务器环境搭建LNMP一键安装包
CentOS下Web服务器环境搭建LNMP一键安装包 时间:2014-09-04 00:50来源:osyunwei.com 作者:osyunwei.com 举报 点击:3797次 最新版本:lnmp- ...
- Jenkins+Maven+Git CI环境搭建手册
Jenkins+Maven+Git CI环境搭建手册 环境: OS:Linux version 2.6.32-220.23.2.ali878.el6.x86_64 (ads@kbuild) (gcc ...
随机推荐
- C++ 11 auto关键字
熟悉脚本语言的人都知道,很多脚本语言都引入了“类型自动推断”技术:比如Python,可以直接声明变量,在运行时进行类型检查.随着C++11标准的发布,C++语言也引入了类型自动推断的功能,这就是我们今 ...
- uml 符号关系示意
类(Class) 类(图A)是对象的蓝图,其中包含3个组成部分.第一个是Java中定义的类名.第二个是属性(attributes).第三个是该类提供的方法.属性和操作之前可附加一个可见性修饰符.加号( ...
- spring session实现集群中session共享
本文转自:http://dorole.com/1422/ 使用框架的会话管理工具,也就是本文要说的spring-session,可以理解是替换了Servlet那一套会话管理,既不依赖容器,又不需要改动 ...
- Logback手冊 Chapter 1: Introduction
翻译不周,多多包括 ---------------------------------------------------------------------------------------切割线 ...
- Android中WebView与H5的交互,Native与JS方法互调
项目中经常用到WebView与H5的交互,一个是H5调本地方法,一个是本地调H5方法,在此记录一下. 首先,启用JS支持 //启用js支持 webSettings.setJavaScriptEnabl ...
- Qt 4.8.5 icpc: Command not found
icpc: Command not found 交叉编译Qt4.8.5的时候出现
- si4438 与 si4432通讯
http://www.nicerf.cn/_d275147664.htm http://wenku.baidu.com/view/2109573caf1ffc4ffe47ac8c.html si446 ...
- 关于Javascript判断变量是否为空
如何判断Javascript对象是否存在 原文网址:http://www.ruanyifeng.com/blog/2011/05/how_to_judge_the_existence_of_a_glo ...
- 关于Cocos2d-x中类与类之间调用彼此方法的机制
1.一般情况下都是把需要实例化的对象类的头文件包含到一个GameController.h中,再在GameController.cpp文件里面去使用各种对象类的方法来实现游戏的逻辑. 2.还有的时候会把 ...
- sh脚本循环
sh for循环 for File in 1 2 3 4 5 do echo $File done sh for多重循环 for image_size_input in 160 140 120 100 ...