本文不讲述软件安装过程,记述本人在Debia中配置CodeIgniter时遇到的问题及解决方法,希望能够为有需要的人提供帮助。

一、Debian版本及所需的软件

  Debian 9.8 stretch

  PHP 7.0.3

  Nginx 1.10.3-1

  Php7.0-fpm

  phpMyAdmin 4.8.5

  MariaDB 10.1.37

  CodeIgniter 3.1.10

二、nginx虚拟主机配置

  首先说一下Debian中nginx配置文件的分布,/etc/nginx/nginx.conf中包含nginx的启动用户、进程ID和http等全局配置,具体server配置通过include /enc/nginx/sites-enabled/* 给出,site-enabled目录中只包含软链接,软链接指向site-available目录中相应的配置文件。site-available中有一个默认server配置,下面是我的site-enabled目录情况:

  下面是codeigniter和php_my_admin两个文件(在sites-available目录中)的内容

codeigniter:

# Server configuration for CodeIgniter
server { listen 80 default_server;
listen [::]:80 default_server; root /var/www/html/CodeIgniter-3.1.10; # Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html; server_name www.ci.com; location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server location ~ \.php($|/) { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}

php_my_amdin:

# Server configuration for phpMyAdmin

server {

    listen 80;

    root /var/www/html/phpMyAdmin;

    # Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html; server_name www.pma.com; location / { # First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
} # pass PHP scripts to FastCGI server location ~ \.php($|/) { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}

注意:以上两个文件有以下两处不同
  1、root

  2、server_name

  这样配置完成后,重新启动nginx会报错,因为两个server_name还没有设置,这个需要修改/etc/hosts文件,添加下面两行:

  127.0.0.1 www.ci.com

  127.0.0.1 www.pma.com

  其中www.ci.com和www.pma.com是codeigniter和php_my_admin中server_name对应,这个两个可以根据自己的喜好设置,重启电脑就可以正常运行nginx了,可以通过www.ci.com和www.pma.com来访问相应的网站了。

注:在配置以上两个server时注意location ~ \.php($|/),默认只有$,要加上|/,否则可能会出现只能访问CI配置路由的页面,访问其他页面会出现404错误。

三、Codeigniter配置

  配置文件config.php

  $config['base_url'] = 'http://www.ci.com/';

  这一句http://这个要有,不能少

  $config['index_page'] = 'index.php';

  在没有配置index.php省略时,这个要有,因为CodeIgniter中site_url会包含$config['base_url']和$config['index_page']两部分。

  $config['uri_protocol'] = 'PATH_INFO';

Debian中CodeIgniter+nginx+MariaDB+phpMyAdmin配置的更多相关文章

  1. codeigniter nginx rewrite规则配置【转】

    转自:http://www.nginx.cn/1134.html nginx如何配置才能支持codeigniter ? 1. codeigniter的url美化去掉index.php   1 2 3 ...

  2. linux(Debian) 中的cron计划任务配置方法

    cron服务每分钟不仅要读一次/var/spool/cron内的所有文件,还需要读一次/etc/crontab,因此我们配置这个文件也能运用cron服务做一些事情.用crontab配置是针对某个用户的 ...

  3. 在win10 docker启动的centos容器中安装nginx

    我是在win10机器上搭建了一个docker,在docker启动了centos容器,在centos中安装nginx. 安装配置docker 直接在官网下载docker for windows:http ...

  4. 在CentOS中快速安装PHP,MySQL,Nginx和phpMyAdmin

    安装环境 yum install -y autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel vim 安装p ...

  5. Ubuntu 安装phpMyAdmin + 配置nginx

    0x01 安装phpMyAdmin ``` sudo apt-get install phpmyadmin ``` 0x02 添加链接 ``` sudo ln -s /usr/share/phpMyA ...

  6. Linux中Nginx安装与配置详解

    转载自:http://www.linuxidc.com/Linux/2016-08/134110.htm Linux中Nginx安装与配置详解(CentOS-6.5:nginx-1.5.0). 1 N ...

  7. linux中keepalived实现nginx高可用配置

    linux中keepalived实现nginx高可用配置 安装keepalived 运行如下命令即可 tar -zxvf keepalived-2.0.8.tar.gz -C /usr/src cd ...

  8. asp.net中 使用Nginx 配置 IIS站点负载均衡

    这是一偏初学者入门的内容,发现有问题的地方,欢迎留言,一起学习,一起进步 本文主要记录一下在Windows平台中,IIS站点如何使用Nginx 做一个简单的负载均衡  一. 准备工作: 官网下载安装包 ...

  9. HHvm建站环境搭建方法:Nginx,Mariadb,hhvm及lnmp/lamp安装部署

    HHVM起源于Facebook公司,是一个开源的PHP虚拟机,使用JIT的编译方式以及其他技术,让PHP代码的执行性能大幅提升.HHVM提升PHP性能的途径,采用的方式就是替代Zend引擎来生成和执行 ...

随机推荐

  1. 记开发个人图书收藏清单小程序开发(四)DB设计

    早上起来,又改动了一下: 主要是,将非常用信息全部拆分出来,让Table尽量的小,小到不能继续拆分了,这样区分DB逻辑.增加了FileBank存储Book的封面图片,统一管理图片资源. 新添加的Typ ...

  2. 如何给Docker hub用户上传头像

    我第一次使用Docker hub时,觉得很奇怪,这个网站上面没有允许用户上传头像的地方. 后来经过研究才发现,需要用在Docker hub上注册用户的同一个邮箱到Gravatar这个网站上再注册一个账 ...

  3. Bootstrap Multiselect

    Getting Started Link the Required Files First, the jQuery library needs to be included. Then Twitter ...

  4. bzoj3718 [PA2014]Parking

    Description 你的老板命令你将停车场里的车移动成他想要的样子.停车场是一个长条矩形,宽度为w.我们以其左下角顶点为原点,坐标轴平行于矩形的边,建立直角坐标系.停车场很长,我们可以认为它一直向 ...

  5. Django logging的介绍

    Django用的是Python buildin的logging模块. Python logging由四部分组成: Loggers - 记录器 Handles - 处理器 Filters - 过滤器 F ...

  6. eclipse去掉xml验证的方法

    eclipse Multiple annotations found at this line错误,eclipse开发过程中,一些XML配置文件会报错,但是这些其实不是错,飘红的原因是因为eclips ...

  7. 关于mvvm:UI、数据、绑定、状态、中间变量、数据适配、数据处理

    绑定: UI控件 --> VM    VM -> UI控件 关于mvvm:UI.数据.绑定.状态.中间变量.数据适配.数据处理: https://github.com/zzf073/Log ...

  8. perl的一些小函数——split、join、sort

    有时候,我们需要将一个字符串或一行文本通过某种方式转换为单个的元素存储在数组中,或者将许多元素通过某种分割符,将他们组合成一个字符串.perl刚好就提供了这样的功能,通过split或者join分割或组 ...

  9. ROBOCOPY——Windows 的可靠文件复制

    复制指定类型文件 (-s :含子目录  不包括空目录) 复制所有 (-e :含子目录  包括空目录) 复制指定成层级内的 (-lev:n 仅复制源目录树的前 n 层) 复制排除给定类型后的 (-xf) ...

  10. mybatis分页PageHelper插件的使用

    1.jar包, 2.改mybatis的配置文件,加上这段配置: <plugins><plugin interceptor="com.github.pagehelper.Pa ...