[英]CodeIgniter 3, Nginx rewrite how to?
I installed CodeIgniter 3 after a long time on PHP-fpm and nginx (Ubuntu). 经过很长时间,我在PHP-fpm和nginx(Ubuntu)上安装了CodeIgniter 3。 Previously I had always used CodeIgniter on Windows and configuring it on Windows and Apache it was a piece of cake.
以前,我一直在Windows上使用CodeIgniter,并在Windows和Apache上进行配置,这真是小菜一碟。 Now I wanna install it on nginx, because I wanna use nginx-push-stream-module, which isn't possible from apache.
现在,我想在nginx上安装它,因为我想使用nginx-push-stream-module,这在apache中是不可能的。
Now when I'm configuring it, its not working. 现在,当我配置它时,它不起作用。
If I type localhost/myexample.com
or localhost/myexample.com/index.php
it works ( myexample.com
is the name of that directory) 如果我键入
localhost/myexample.com
或localhost/myexample.com/index.php
它就可以工作( myexample.com
是该目录的名称)
but when I try to access 但是当我尝试访问
localhost/myexample.com/welcome
or 要么
localhost/myexample.com/welcome/index
or 要么
localhost/myexample.com/index.php/welcome
or 要么
localhost/myexample.com/index.php/welcome/index
it doesn't work in any of the 4 cases (with or without index.php) 它在4种情况下(无论是否带有index.php)均不起作用
My root directory is /var/www/html/myexample.com
我的根目录是
/var/www/html/myexample.com
I tried all of the rewrite settings available online (including the following settings) from different blog posts etc (as I'm not used to nginx myself) 我尝试了不同博客文章等在线提供的所有重写设置(包括以下设置)(因为我不习惯nginx自己)
server {
server_name myexample.com;
root /var/www/html/myexample.com/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/myexample.com/index.php;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
Edit: I also tried the method mentioned at Nginx's official website, but that's also not working. 编辑:我也尝试了在Nginx的官方网站上提到的方法 ,但这也不起作用。
You should modify your /etc/hosts and add this line: 您应该修改/ etc / hosts并添加以下行:
127.0.0.1 myexample.com
127.0.0.1 myexample.com
And after that use myexample.com or myexample.com/welcome to access your CodeIgniter site 然后,使用myexample.com或myexample.com/welcome访问您的CodeIgniter网站
First - confirm what the server name is going to be. 首先-确认服务器名称是什么。 Set that in the your hosts file, then confirm the web root.
在您的主机文件中进行设置,然后确认网络根目录。
So in /etc/hosts add 因此在/ etc / hosts中添加
127.0.0.1 myexample.com
Then your index.php file should be in 然后,您的index.php文件应位于
/var/www/html/myexample.com/
You should get CI up and working on the url 您应该启动CI并使用url
http://myexample.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.