{"id":286,"date":"2012-09-04T21:33:52","date_gmt":"2012-09-04T13:33:52","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=286"},"modified":"2018-09-03T22:38:55","modified_gmt":"2018-09-03T14:38:55","slug":"emulating-the-web-production-environment-with-an-apache-http-server-running-on-a-windows-7-development-machine","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/emulating-the-web-production-environment-with-an-apache-http-server-running-on-a-windows-7-development-machine\/","title":{"rendered":"Emulating the web production environment with an Apache HTTP server running on a Windows 7 development machine"},"content":{"rendered":"<p>To minimize overhead costs of my website, I would restrain myself from buying a hosted plan until my website is launch-able. In the process of developing my website, I will want my tests to be as close to the real thing as possible. <\/p>\n<p>This meant that when I type the domain of my website in my browser location bar, my browser will connect to my development web server, instead of the web server which my domain is being parked at. <\/p>\n<p>I was using Windows 7 and an instance of Apache HTTP server as my development environment when I managed to achieve that. That instance of Apache HTTP server was listening at port 80.<\/p>\n<p>There are two main steps to achieving such an objective:<\/p>\n<ul>\n<li>Routing HTTP requests, made to the actual domain, to my local machine<\/li>\n<li>Configuring Apache HTTP server to service HTTP request directed to the domain name<\/li>\n<\/ul>\n<h3>Routing HTTP requests, made to the actual domain, to my local machine<\/h3>\n<p>By default, my Windows 7 machine uses the services of a domain name server to map domain names into actual ip addresses in order to connect to another machines such as web servers. To emulate a hosted environment with my own Windows 7 machine, I tell it to map the domain name which I had bought into the loopback address. <\/p>\n<p>To do so, I looked for the <code>hosts<\/code> file at the <code>C:\/Windows\/System32\/drivers\/etc\/<\/code> folder and added the following lines of configurations in the file:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n127.0.0.1 techcoil.com\r\n127.0.0.1 www.techcoil.com\r\n<\/pre>\n<p>When I do that, I had instructed my Windows 7 machine to return the loop back address (127.0.0.1) when my browser tries to access <code>techcoil.com<\/code> or <code>www.techcoil.com<\/code>. This result in my browser accessing my local Apache HTTP server with the domain name that I had bought.<\/p>\n<h3>Configuring Apache HTTP server to service HTTP request directed to the domain name<\/h3>\n<p>Directing my browser to connect to my local Apache HTTP server fulfills one part of the equation. The other part will be to configure my local Apache HTTP server to service HTTP requests directed to my domain name. To do so, I added the following lines of configurations in my <code>&lt;apache_http_server_installation_dir&gt;\/conf\/httpd.conf<\/code> file:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;VirtualHost *:80&gt;\r\n    \r\n    ServerName techcoil.com\r\n    ServerAlias www.techcoil.com\r\n\r\n    DirectoryIndex index.php\r\n    DocumentRoot &quot;T:\/techcoil.com&quot;\r\n    \r\n    &lt;Directory &quot;T:\/techcoil.com&quot;&gt;\r\n        Order allow,deny\r\n        allow from 127.0.0.1\r\n    &lt;\/Directory&gt;\r\n    \r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>The first two lines after the <code>VirtualHost<\/code> directive tell Apache HTTP server that the configurations enclosed within are for HTTP requests which are directed at either <code>techcoil.com<\/code> or <code>www.techcoil.com<\/code>.<\/p>\n<p>The <code>DirectoryIndex<\/code> directive tells Apache HTTP server to send a HTTP response from <code>index.php<\/code> in the event when the browser tries to access a folder.<\/p>\n<p><code>DocumentRoot<\/code> maps HTTP requests to the domain to the <code>T:\/techcoil.com<\/code> folder in my local filesystem.<\/p>\n<p>The <code>Directory<\/code> directive then instructs Apache HTTP server to limit accesses to files within <code>T:\/techcoil.com<\/code> to only those made from my development machine. Without configurations provided in the <code>Directory<\/code> directive, my Apache HTTP server will return 403 Forbidden for requests hitting <code>techcoil.com<\/code> or <code>www.techcoil.com<\/code>. <\/p>\n<h3>Posts that may interest you<\/h3>\n<ul>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/debugging-php-on-apache-http-server-on-windows-server-2008\/\" title=\"Debugging PHP on Apache HTTP Server on Windows Server 2008\">Debugging PHP on Apache HTTP Server on Windows Server 2008<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/make-your-php-webpage-loads-faster-by-aggregating-external-css-scripts\/\" title=\"Make your PHP webpage loads faster by aggregating external CSS scripts\" target=\"_blank\">Make your PHP webpage loads faster by aggregating external CSS scripts<\/a><\/li>\n<li><a href=\"http:\/\/www.techcoil.com\/blog\/php-codes-to-tell-browsers-to-open-the-download-dialog-box-for-users-to-download-a-file\/\" title=\"PHP codes to tell browsers to open the download dialog box for users to download a file\" target=\"_blank\">PHP codes to tell browsers to open the download dialog box for users to download a file<\/a><\/li>\n<\/ul>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-4C\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-4C&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-4C&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F286&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>To minimize overhead costs of my website, I would restrain myself from buying a hosted plan until my website is launch-able. In the process of developing my website, I will want my tests to be as close to the real thing as possible. <\/p>\n<p>This meant that when I type in the real domain of my website in my browser location bar, my browser will connect to my development web server, instead of the web server which my domain is being parked at. <\/p>\n<p>I was using Windows 7 and an instance of Apache HTTP server as my development environment when I achieved that. My Apache HTTP server was listening at port 80 for HTTP requests.<\/p>\n<p>There are two main steps to achieving my objective:<\/p>\n<ul>\n<li>Routing HTTP requests, made to the actual domain, to my local machine<\/li>\n<li>Configuring Apache HTTP server to serve HTTP requests directed at the actual domain<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":1219,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[14,13,158],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Apache-HTTP-Server-Project-logo.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-4C","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/286"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1219"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}