Debian中CodeIgniter+nginx+MariaDB+phpMyAdmin配置

本文不讲述软件安装过程,记述本人在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 目录中相应的配置文件。s ite-available 中有一个默认server 配置,下面是我的site-enabled 目录情况:

Debian中CodeIgniter+nginx+MariaDB+phpMyAdmin配置

下面是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’;

Original: https://www.cnblogs.com/lameisoft/p/10555881.html
Author: 腊梅软件
Title: Debian中CodeIgniter+nginx+MariaDB+phpMyAdmin配置

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/606518/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • Base-64字符串无效,The input is not a valid Base-64 string as it contains a non-base 64 character

    base64规则: 字符串只可能包含A-Z,a-z,0-9,+,/,=字符 字符串长度是4的倍数 =只会出现在字符串最后,可能没有或者一个等号或者两个等号 首先,C# 做上传文件的…

    Linux 2023年6月7日
    0115
  • 武装你的WEBAPI-OData常见问题

    本文属于OData系列 Intro 非常喜欢OData,在各种新项目中都使用了这个技术。对于.NET 5.0, OData推出了8.0preview,于是就试用了一下。发现坑还是非…

    Linux 2023年6月6日
    091
  • 聊聊 Netty 那些事儿之 Reactor 在 Netty 中的实现(创建篇)

    本系列Netty源码解析文章基于 4.1.56.Final版本 在上篇文章《聊聊Netty那些事儿之从内核角度看IO模型》中我们花了大量的篇幅来从内核角度详细讲述了五种 IO&am…

    Linux 2023年6月6日
    091
  • 基础算法题

    Problem 3或5的倍数 2: 偶斐波那契数 4:最大回文乘积 5 窗口移动 11:方向数组 13大整数加法 、 14最长考拉兹序列 15:网格路径 25:1000位斐波那契数…

    Linux 2023年6月7日
    0114
  • C语言 四舍五入(学习转型练习)

    #define _CRT_SECURE_NO_WARNINGS #include void main() { double moeny = 0; scanf("%lf&q…

    Linux 2023年6月7日
    096
  • WPF 切换主题使用 luna 复古版本

    本文告诉大家如何在 WPF 里面使用 luna 等复古主题 今天在 lsj 说他准备优化 WPF 的程序集时,准备删除 luna 等程序集时,找到了一段有趣的注释,发现在 WPF …

    Linux 2023年6月6日
    080
  • 机器学习1

    常见的几种假设检验的实例以及对应python代码实现(包括基于图的效果展示 Z检验 t检验 χ2检验 F检验 熟悉scikit-learn及其相关应用 Numpy Numpy 优势…

    Linux 2023年6月6日
    098
  • 构建自定义镜像并优化dockerfile文件

    服务器版本 docker软件版本 CPU架构 CentOS Linux release 7.4.1708 (Core) Docker version 20.10.12 x86_64…

    Linux 2023年6月7日
    098
  • 简单交叉编译学习

    交叉编译 交叉编译是在一个平台上生成另一个平台上的可执行代码。 同一个体系结构可以运行不同的操作系统;同样,同一个操作系统也可以在不同的体系结构上运行。通常是自己的电脑写好代码编译…

    Linux 2023年6月7日
    0129
  • Redis16个常见使用场景

    目录 缓存 数据共享分布式 分布式锁 全局ID 计数器 限流 位统计 购物车 用户消息时间线timeline 消息队列 抽奖 点赞、签到、打卡 商品标签 商品筛选 用户关注、推荐模…

    Linux 2023年5月28日
    0111
  • Linux用户和用户组

    Linux用户和用户组 1.添加新的用户 (用户ID从500开始,0-99系统管理级别、100-499系统预留) useradd 选项 用户名 参数说明 选项: -c commen…

    Linux 2023年6月11日
    098
  • Typora Ubuntu 安装

    官网方法 终端命令行安装 or use sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys BA300B77…

    Linux 2023年6月7日
    095
  • ASP.NET Core 2.2 : 二十三. 深入聊一聊配置的内部处理机制

    上一章介绍了配置的多种数据源被注册、加载和获取的过程,本节看一下这个过程系统是如何实现的。(ASP.NET Core 系列目录) 一、数据源的注册 在上一节介绍的数据源设置中,ap…

    Linux 2023年6月7日
    0143
  • IEEE浮点数标准

    IEEE浮点数标准 阅读笔记:Computer System : A Programmmer’s Perspective 基本概念 IEEE浮点数标准采用 [V=(-1…

    Linux 2023年6月8日
    0121
  • 搭建zabbix 4.0

    安装zabbix的依赖包 下载zabbix源码包 数据库导入数据的命令格式:mysql ­u用户名 ­p密码 数据库名称 < 要导入的数据 此时的路径是在databases/…

    Linux 2023年6月8日
    0118
  • Maven中POM文件总体配置说明

    POM文件总体配置说明 xxx xxx xxx xxx 4.0.0 xxx xxx jar 1.0-SNAPSHOT xxx-maven http://maven.apache.o…

    Linux 2023年6月6日
    090
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球