[英]Moving website from Windows localhost to Linux live server: issues with filenames and paths
I am moving my site to a live server and I found out in the process that linux servers are case sensitive, so it is not a good idea to have URLs with capital letters. 我将站点移至实时服务器,并且在此过程中发现linux服务器区分大小写,因此使用带大写字母的URL不是一个好主意。
Is that also important for filenames? 这对文件名也很重要吗?
All my classes start with capital letter which makes it easier to navigate through files. 我所有的课程都以大写字母开头,这使浏览文件更加容易。
Should I change all files to lowercase? 我应该将所有文件更改为小写吗?
No need to change file names, just be consistent ie use the file names as it is in your PHP Code. 无需更改文件名,只需保持一致即可,即使用PHP代码中的文件名。 If your class name is
Post
stick with Post
in the php code and not post
, In fact Capital letter in the beginning of the class name is common standard which should be followed(just for readability, no strict rule). 如果您的类名是
Post
,在php代码中带有Post
而不是post
,则实际上应该在类名开头使用大写字母(出于可读性考虑,没有严格的规定)。
File path will be an issue if you have hard-coded the path like C:\\xampp\\htdocs\\mysite
anywhere in your project. 如果您在项目中的任何地方都对
C:\\xampp\\htdocs\\mysite
类的路径进行了硬编码,则文件路径将是一个问题。 Avoid that. 避免那样。 Use relative path,
__FILE__
and/or __DIR__
instead. 请使用相对路径
__FILE__
和/或__DIR__
。 http://php.net/manual/en/language.constants.predefined.php http://php.net/manual/zh/language.constants.predefined.php
Same goes for URL, avoid using http://localhost
in the code. URL同样适用,请避免在代码中使用
http://localhost
。 You can set the base url in the beginning of your project where you can write something like : 您可以在项目的开头设置基本网址,在其中可以编写类似以下内容的内容:
if(defined('DEV')){
$url = "http://localhost/mysite";
}
elseif(defined('PROD')){
$url = "http://example.com"
}
If you are using any php framework, you can use their global variable to access base url and ignore above code. 如果您使用任何php框架,则可以使用它们的全局变量来访问基本url,而忽略上述代码。
In windows desktop environment(not Server), apache's process is generally same user as the owner of the files. 在Windows桌面环境(不是Server)中,apache的进程通常是与文件所有者相同的用户。 So hardly anyone faces any issues regarding permission in Windows.
因此,几乎没有人会遇到有关Windows中权限的任何问题。 While in linux, see to it all files have proper permission.
在linux中,请查看所有文件是否具有适当的权限。 Generally people find issues with
images
folder. 通常人们会发现
images
文件夹有问题。 Change its permission according to your need. 根据您的需要更改其权限。 https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions
https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.