简体   繁体   English

将网站从Windows本地主机移到Linux Live服务器:文件名和路径问题

[英]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.

相关问题 移动Joomla后出现错误! 网站从本地主机到实时服务器 - Errors after moving Joomla! website to live server from localhost 网站从本地主机移至服务器时出现Codeigniter错误 - Codeigniter error on moving the website from localhost to server 将opencart从本地主机移至其他主机(Windows服务器)时,我的网站空白 - I am getting blank website while moving opencart from localhost to other host(windows server) 将我的Codeigniter站点从实时服务器移动到本地主机时出现问题 - Problem in moving my Codeigniter site from live server to localhost 使用GoDaddy cPanel将Wordpress网站从本地主机移动到实时服务器 - Moving wordpress site from localhost to live server using GoDaddy cPanel 将站点从本地主机移动到实时服务器时出现 Wordpress 错误 - Wordpress error while moving site from localhost to live server 将 WordPress 从 Live 迁移到本地主机 - Moving WordPress from Live to Localhost 将Laravel从Windows迁移到Linux服务器 - Moving Laravel from Windows to Linux Server 将我的sql数据库localhost移到实时服务器 - moving my sql database localhost to live server 从本地主机移动到实时 web 时读取 serialized.txt 文件时出现问题 - Issues reading serialized .txt file when moving from localhost to live web
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM