2

i have few conceptual queries about moving a locahost site to server for making it available on internet.....what are the steps...how server will recognize the changes in my apache and php config files..i have built a website in php and mysql on apache 2.2

NOTES:

  • i have made some changes in my apache config files.one of them is i have included a fillename "index.php" in "DirectoryIndex"...so now my DirectoryIndex looks like:

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
    
  • so now automatically my apache tells the browser to search for a index.php file whenever header('LOCATION:') or refresh is called.and it's obvious that my index.php files holdas the html and and other php codes which will be shown or displayed

  • third and most importantly...i have used header function in many cases while building the website..my header functions are like header('Location: http://localhost/home/');

so repeating the question again

  • should i change all the header functions while uploading acording to my website name i.e

    header('Location: http://www.my_site_name.com/home/'); in place of

    header('Location: http://localhost/home/');

  • and who will my remote server will recognize the changes i have made in my config file and will work according to the changes
  • and what are the steps to upload a website to internet
  • use a constant to store `http://localhost/` and for [replacing strings in multiple files](http://stackoverflow.com/questions/1895819/find-and-replace-in-multiple-files-on-command-line) – जलजनक Apr 02 '13 at 08:21

2 Answers2

1

and who will my remote server will recognize the changes i have made in my config file and will work according to the changes

Normally hosting servers are configured to allow the use of .htaccess files to override apache configuration

you may create a .htaccess file in your root directory and place there your DirectoryIndex settings

Azathoth
  • 582
  • 1
  • 7
  • 29
  • am sorry..am have very few knowledge about that....what is .htaccess file ..what i should write into that...and root directory of what???? – Sarthok Bhattacharya Apr 02 '13 at 08:35
  • does this file will help my remote server to acknowledgfe the changes in my con fig files of php and apache – Sarthok Bhattacharya Apr 02 '13 at 08:36
  • You cannot access directly the apache configuration of a webhosting. If you want to replicate your " DirectoryIndex index.html index.php " rule on your webhosting you have to create a textfile named **.htaccesss** in your site root directory (where you have your base index.html file). In this file simply copy **DirectoryIndex index.html index.php**. – Azathoth Apr 02 '13 at 08:47
  • Again, you cannot access directly php.ini files so, if you need particular settings you have to use the php **ini_set** function. http://www.php.net/manual/en/function.ini-set.php. Not all possible php.ini settings are supported via ini_set though. – Azathoth Apr 02 '13 at 08:52
  • **.htaccess** file and **ini_set** function are the only way to interfere with apache and php configuration on a server where you don't have administration access (where you cannot edit php.ini and httpd.conf) – Azathoth Apr 02 '13 at 08:57
  • unable to upvote..don't have that much reputation...so i just need to add that `.htaccess` file right???..nothing else right?? – Sarthok Bhattacharya Apr 02 '13 at 09:08
  • one last question please..where should i use this ini_set function..in every code????..or in `.htaccess`?????.. – Sarthok Bhattacharya Apr 02 '13 at 09:10
  • right, nothing else. If you don't notice any changes try using another browser or clear you cache. Note that not all the server supports .htaccess overriding but the majority does – Azathoth Apr 02 '13 at 09:15
  • one last question please..where should i use this ini_set function..in every code????..or in .htaccess?????.. – Sarthok Bhattacharya Apr 02 '13 at 09:21
  • Normally web applications have one php config file (config.php or something like that) included in every file (require_once). This is the right place to put settings needed for the whole project such as constants (database connection vars), paths (as said by @Shikiryu you should prefer relative paths when applicable), etc .. and your ini_set calls. – Azathoth Apr 02 '13 at 09:34
0

should i change all the header functions while uploading acording to my website name i.e header('Location: http://www.my_site_name.com/home/'); in place of header('Location: http://localhost/home/');

Why not using relative paths or simply:

header('Location: /home/');

and who will my remote server will recognize the changes i have made in my config file and will work according to the changes

That way, it'll work on both servers.

and what are the steps to upload a website to internet

You should use a FTP client to upload your website to your webhost.

Shikiryu
  • 10,180
  • 8
  • 49
  • 75
  • `That way, it'll work on both servers.`.. how remote server will undesrstand my "DirectoryIndex" change – Sarthok Bhattacharya Apr 02 '13 at 08:27
  • so i need not to write something like `header('Location: http://www.my_site_name.com/home/');`..right???? – Sarthok Bhattacharya Apr 02 '13 at 08:37
  • Your `DirectoryIndex` is the same on both server right? Do you know what's its use? http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex – Shikiryu Apr 02 '13 at 08:38
  • @SarthokBhattacharya why don't you try for yourself? :) – Shikiryu Apr 02 '13 at 08:38
  • DirectoryIndex tells Apache which filenames to use when it looks for the default page for a given directory.i know it..my question was by default there was not index.php..i have added it...so how remote server will understand that i have added index.php in DirectoryIndex – Sarthok Bhattacharya Apr 02 '13 at 08:52
  • @SarthokBhattacharya Modify your `DirectoryIndex` so as it will be the same on both server (as I told you 20mins ago). I guess it's in a .htaccess file. If it's the case, upload your local one to your server and it's done. – Shikiryu Apr 02 '13 at 09:06
  • @SarthokBhattacharya `DirectoryIndex` is not about PHP but APACHE. You can change it in httpd.conf if you want. (or still .htaccess) – Shikiryu Apr 02 '13 at 09:25