Php 如何为codeigniter项目完美地设置虚拟主机?

Php 如何为codeigniter项目完美地设置虚拟主机?,php,apache,codeigniter,uri,Php,Apache,Codeigniter,Uri,我正在尝试为codeigniter项目创建一个虚拟主机。我已经在httpd-vhosts.conf中这样做了: <VirtualHost *:80> DocumentRoot "C:\xampp\htdocs\CI_projects\facebook-login" ServerName dev.facebook-login.com <Directory "C:\xampp\htdocs\CI_proj

我正在尝试为codeigniter项目创建一个虚拟主机。我已经在httpd-vhosts.conf中这样做了:

    <VirtualHost *:80>
      DocumentRoot "C:\xampp\htdocs\CI_projects\facebook-login"
       ServerName dev.facebook-login.com
       <Directory "C:\xampp\htdocs\CI_projects\facebook-login">
     Require all granted
    </Directory>
    </VirtualHost>

浏览器将打开登录页。但当从任何其他uri转换时,它表示找不到对象。 当我这样配置httpd-vhosts.conf时:

   <VirtualHost *:80>
      DocumentRoot "C:\xampp\htdocs\CI_projects\facebook-login\index.php"
       ServerName dev.facebook-login.com
       <Directory "C:\xampp\htdocs\CI_projects\facebook-login\index.php">
     Require all granted
    </Directory>
    </VirtualHost>

DocumentRoot“C:\xampp\htdocs\CI\u projects\facebook login\index.php”
ServerName dev.facebook-login.com
要求所有授权

这就产生了一些问题,比如图像和一些css不能加载。如何解决这个问题?

我使用的是windows 10,我将xampp与虚拟主机结合使用,这是我设置的方式

在基本url的末尾提出正斜杠

$config['base_url'] = 'http://dev.facebook-login.com/';
先去

Windows>System32>drivers>etc>host

您可能需要以管理员身份打开才能保存它

你可能会看到这样的事情

127.0.0.1       localhost 
下面是为dev.facebook-login.com创建另一个的示例:

省省吧

然后去医院

xampp>apache>conf>extra>httpd vhosts.conf

以管理员身份打开它,以便保存它

无需在DocumentRoot上使用index.php

<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "C:/xampp/htdocs/CI_projects/facebook-login"
    ServerName dev.facebook-login.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost> 
使用Xampp 7.3.25 Dec 2020,因为PHP8不会运行错误
免费的codeigniter 4从这个日期起,这对我来说就像
我的第一个codeigniter 4虚拟主机安装,我的安装
最初使用端口80有困难,似乎希望
端口443,如果可以的话..我不是服务器专家,但我想
把这个留给下一个人…这是严格的名字为基础的
虚拟主机的开发,基于ip将有明显的优势
优势。因为我在最初的CI4测试中遇到了麻烦
虚拟主机vs(*:80)中的端口80(*)似乎解决了一个问题
寻找更多端口的障碍,现在我终于可以开始我的
第一个项目…我的默认URL也更改为example.com
在appstarter/apps/config文件中。仔细重读
输入错误,很容易关闭服务器!
DocumentRoot“C:/Xampp/htdocs/” 服务器名本地主机 要求所有授权

DocumentRoot“C:/Xampp/htdocs/appstarter/public/” ServerName example.com 服务器别名 #可能不尝试使用dir标记,关闭服务器
#httpd.conf上的指令似乎就足够了

我在appstarter/public中添加了一个htaccess文件
我认为这是原始的,可以变得更高级
Apache帮助页面帮助我更加关注
在这种情况下,我必须完成的是基于名称的虚拟主机
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]
2.2 Apache配置::Apache服务器上下文重要!
命令允许,拒绝:黑客们赢了。。。。。
通融
2.4 Apache配置:
要求所有授权
httpd-vhosts.conf

Listen 1122
<VirtualHost *:1122>
DocumentRoot "D:\laragon_server\www\hugpong_production"
<Directory "D:\laragon_server\www\hugpong_production">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Listen 1122
DocumentRoot“D:\laragon\u服务器\www\hugpong\u生产”
命令允许,拒绝
通融
.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
截至2021年1月,PHP8尚未准备好用于CI4! XAMPP在PHP7包中预加载了ssl证书 考虑额外的Vistor并将其放入其中 我唯一一直存在的问题是codeigniter 4路由,必须打开php spark serve才能让XAMPP在默认索引之外路由页面,其他任何东西都不起作用,它的垃圾到了这个程度,下一步将尝试使用composer…整本书都需要 关于codeigniter 4路线以及它们不起作用的原因,200多页

DocumentRoot“C:\xampp\htdocs” ServerName localhost


ServerName example.com
ServerAlias www.example.com
DocumentRoot“C:\xampp\htdocs\codeignite4\public”
//我的项目文件夹是codeignite4,这次没有使用composer
//我在htppd.conf的listen80下添加了listen8080
ServerName example.com
DocumentRoot“C:\xampp\htdocs\codeignite4\public” ServerName example.com 斯伦金安 SSLCertificateFile“C:/xampp/apache/conf/ssl.crt/server.crt” //您可以验证这些文件位置、证书数据 SSLCertificateKeyFile“C:/xampp/apache/conf/ssl.key/server.key” //不使用目录标记可以有助于插入vhost 要求所有授权

通过这样做,我能够复制原始安装,创建站点访问 使用http://localhost:8080 或者作为我的基本url 在我的示例中,index.php被删除,设置为“” 当使用命令提示符进入codeignite4项目文件夹时,我可以
启动php spark serve,路由将运行之前的404

这很难阅读和理解。考虑使用标准英语语法,并添加一些。
<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "C:/xampp/htdocs/CI_projects/facebook-login"
    ServerName dev.facebook-login.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost> 
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Using Xampp 7.3.25 Dec 2020 because php 8 will not run error
free with codeigniter 4 as of this date, this worked for me as
my first codeigniter 4 virtual host setup, my install had 
difficulty initially with using port 80, seems to want to for
port 443 if it can..I'm not a server pro but i wanted to 
leave this for the next guy....This is strictly name based
virtual hosts for develop, ip based would have obvious 
advantages. Because i had trouble in initial CI4 testing with
port 80 the (*) in virtual hosts vs (*:80) seemed to solve one 
hurdle in searching for more ports, now i can finally begin my 
first project ...my default URL was also changed to example.com
in appstarter/apps/config file. Carefully reread <tags> for 
typos, its easy to shut server down! 
I have added a htaccess file in the appstarter/public
I assume this is primitive, can get far more advanced 
The Apache help pages helped me focus a bit more on 
what i must accomplish, name based virtual hosts this case 

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>


2.2 Apache configuration:      :Apache server context important!
     Order allow,deny          :The hackers are winning..... 
     Allow from all
     
2.4 Apache configuration:
     Require all granted
Listen 1122
<VirtualHost *:1122>
DocumentRoot "D:\laragon_server\www\hugpong_production"
<Directory "D:\laragon_server\www\hugpong_production">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<VirtualHost example.com *:8080>
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot "C:\xampp\htdocs\codeignite4\public"
   //my project folder is codeignite4 without using composer this time
   //i added listen 8080 under listen 80 in htppd.conf
    ServerName example.com