简体   繁体   中英

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.

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. 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).

File path will be an issue if you have hard-coded the path like C:\\xampp\\htdocs\\mysite anywhere in your project. Avoid that. Use relative path, __FILE__ and/or __DIR__ instead. http://php.net/manual/en/language.constants.predefined.php

Same goes for URL, avoid using http://localhost in the code. 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.

In windows desktop environment(not Server), apache's process is generally same user as the owner of the files. So hardly anyone faces any issues regarding permission in Windows. While in linux, see to it all files have proper permission. Generally people find issues with images folder. Change its permission according to your need. https://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM