搭建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 ...
随机推荐
- Chrome浏览器缓存查看工具-ChromeCacheView
最近想听一下最新的流行热歌,按着某网站的新歌排行榜逐首在巨鲸音乐网搜索下载,但相当一部分的歌曲还是没能下载到,逼不得已只能到百度MP3下载,在搜索结果中已经挑体积比较大的文件来下载了,但下载到的MP3 ...
- [转帖]Android平台下OpenGL初步
原文请看 Android平台下OpenGL初步 本文只关注于如何一步步实现在Android平台下运用OpenGl. 1.GLSurfaceView GLSurfaceView是Android应用程序中 ...
- js photoswipe 相册使用 移动pc端均可
http://photoswipe.com/ 官网 这里使用的是最新 4.1.1版本 http://photoswipe.com/documentation/getting-started.html ...
- springmvc集成Freemarke配置的几点
项目结构图 废话不多说, 集成步骤: 1.web.xml spring-mvc配置 <?xml version="1.0" encoding="UTF-8&quo ...
- PowerShell中实现人机交互
编写脚本的过程中有很多时候需要进行人机交互,比如我写一个脚本,需要动态的输入一些内容,比如用户名和密码之类的东西,这些是没办法事先写进代码里的.而通过外部文件进行信息读取,友好性又差了点.所以当我们需 ...
- js中特殊转换字符为html标签
function htmlEncode(text){ return text.replace(/&/g,'&').replace(/\"/g,'"'). ...
- jacky自问自答-数据库
1.exists和in有什么区别? EXISTS用于检查子查询是否至少会返回一行数据,该子查询实际上并不返回任何数据,而是返回值True或False,而In子查询则是返回具体的数据值,与指定的字段比较 ...
- 如何在WebService中重载方法
1. 本来在WebService中这样写的重载方法,如下所示: [WebService(Namespace = "http://tempuri.org/")] [WebSer ...
- pthread_self()究竟根据什么来得到线程的标识符????
#include<stdlib.h> #include<pthread.h> #include<stdio.h> #include<sched.h> # ...
- Android AsyncTask 源代码分析
AsyncTask源代码分析 public abstract class AsyncTask<Params, Progress, Result> { //日志TAG private sta ...