搭建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 ...
随机推荐
- 8个非常实用的PHP安全函数,你知道几个?
原文:Useful functions to provide secure PHP application 译文:实用的PHP安全函数 译者:dwqs 安全是编程很重要的一个方面.在不论什么一种编程语 ...
- Serviceability
http://hg.openjdk.java.net/jdk7u/jdk7u2/hotspot/file/6259c6d3bbb7/agent/doc/clhsdb.html http://blog. ...
- 用c写了个后台扫描
/** * Notice: The program is not debug on internet and not use thread supervene. * date : 6-26 * aut ...
- "高级"数据库小结
刚刚考完高级数据库,这里有多高级等后面考完组合数学和算法再细聊.试卷在往年基础上改进了部分题目(貌似有人知道新题目的来源,如查询优化树),也可能是两份试卷交叉年份考.总之会的还是会,没看过的当然不会只 ...
- ioss使用xcode常用快捷键
// command+r 运行 //command+.停止 // command+shift+y 弹出打印区 // command+z 回退 //command+shift+z 前进 // comma ...
- 【Visual Studio】控制台程序运行时一闪而过
问题:写一个C#控制台程序,运行时控制台一闪而过.程序结束.无法看清控制台输出的结果. 办法: 方法一二三都有人写过百度经验了:怎么解决VS运行程序一闪而过 其实还有一种办法,就是把控制台程序改为Wi ...
- 【WPF】当 ItemsSource 正在使用时操作无效。改用 ItemsControl.ItemsSource 访问和修改元素
问题: 中文版报错:Additional information: 当 ItemsSource 正在使用时操作无效.改用 ItemsControl.ItemsSource 访问和修改元素. 英文版报错 ...
- pku oj overhang叠加卡片求最少的卡片数
这个估计是里面第二简单的了,因为第一简单的是求a+b 哈哈,一submit就ac了 题目如下: Description How far can you make a stack of cards ov ...
- rp2833 网卡以及串口与接插件位置关系
P13 eth0 (电口--兼容光口,如果使用光口,请将去掉U31以及P13) p12 eth1 P9 /dev/ttyS3 调试口 P10-1 /dev/ttyS2 r ...
- 一站式学习Wireshark(六):狙击网络高延时点
在某些情况下,丢包可能并不是造成延时的原因.你可能会发现尽管两台主机之间通讯速度很慢,但这种慢速并没有伴随着TCP重传或是重复ACK的征兆.在这种情况下,需要使用另一种方式来定位高延时点. 查找高延时 ...