<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP Starter &#187; Apache</title>
	<atom:link href="http://phpstarter.net/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpstarter.net</link>
	<description>PHP Tips &#38; Tools From Starters to Experts</description>
	<lastBuildDate>Fri, 25 Jun 2010 14:14:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Configuring PHP on Windows Systems</title>
		<link>http://phpstarter.net/2009/01/configuring-php-on-windows-systems/</link>
		<comments>http://phpstarter.net/2009/01/configuring-php-on-windows-systems/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 06:00:27 +0000</pubDate>
		<dc:creator>Kurtis</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Intermediate]]></category>

		<guid isPermaLink="false">http://phpstarter.net/?p=233</guid>
		<description><![CDATA[Though not necessary, running PHP on your home machine can make development much quicker and easier. Without affecting the actual website, you can edit files and execute them locally, uploading all to the server when finished. This article will cover the installation of Apache and configuration of PHP on your local Windows machine.There are several [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Though not necessary, running PHP on your home machine can make development much quicker and easier.  Without affecting the actual website, you can edit files and execute them locally, uploading all to the server when finished.  This article will cover the installation of Apache and configuration of PHP on your local Windows machine.<span id="more-233"></span>There are several methods available for installing Apache, PHP, and valuable modules on your computer, ranging from all-in-one packages, easy PHP installers, and of course, manual installation.</p>
<p>First of all, let&#8217;s detail the major all-in-one installers.  The two most popular are <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP</a> and <a href="http://www.wampserver.com/en/" target="_blank">WAMP</a> (notice the AMP they have in common).  XAMPP is an acronym, each letter standing for a feature of the package:</p>
<ul>
<li><strong>X</strong>: means the package is cross-platform (Linux, Windows, etc)</li>
<li><strong>A</strong>: Apache HTTP Server</li>
<li><strong>M</strong>: MySQL</li>
<li><strong>P</strong>: PHP</li>
<li><strong>P</strong>: Perl</li>
</ul>
<p>The XAMPP package, which can be easily downloaded and installed on Windows machines, includes the following features as well: mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.  It may seem like a lot because, well, it is!  Take my word for it:  if you&#8217;re looking for a quick, simply install with all of the necessities, XAMPP is great!</p>
<p>WAMP is also an acronym, where the <strong>AMP</strong> stands for Apache, MySQL, and PHP, and the <strong>W</strong> here specifies that it only works on <strong>W</strong>indows machines.  WAMP also includes phpMyAdmin but is much more stripped in its features.  I suggest WAMP if you want a lighter install with only the bare-bones features.</p>
<p>The next option is to install Apache and PHP on your own, though this solution is still rather easy.  By downloading the <a href="http://httpd.apache.org/download.cgi">Apache installer</a> (choose the last Win32 option) and running through the steps (detailed later), you can couple it with an easy PHP installer, either one available directly from the PHP website, located <a href="http://us.php.net/manual/en/install.windows.installer.msi.php">here</a>, or one from a third-party source, like the <a href="http://phplens.com/phpeverywhere/easywindows" target="_blank">EasyWindows Installer</a>.  Following the steps they suggest will allow another quick installation option.  This is certainly the lightest quick installation available.</p>
<p>The last option is certainly the toughest, but I, as well as the PHP developers themselves, recommend it.  Installing PHP yourself allows you to take a close look at the files that configure it and work with them as well.  This may seem intimidating to some, so that&#8217;s why there are so many other options available.  You can follow the manual instructions at <a href="http://us.php.net/manual/en/install.windows.manual.php" target="_blank">php.net</a> or follow my instructions for installing Apache and PHP below.  I&#8217;ve sifted through PHP&#8217;s instructions to create the easiest-to-understand steps I could.</p>
<p>Let&#8217;s begin by configuring PHP.</p>
<ol>
<li>Download the <a href="http://www.php.net/downloads.php" target="_blank">PHP package</a>.  I suggest the latest Windows binary (<strong>5.2.8 </strong>as of this article).</li>
<li>Extract the entire package to a folder on your machine (e.g. C:/PHP).  Note that the latest releases of PHP do not create their own folder, so you must extract them to the folder you wish for PHP to reside in.</li>
<li>Make <em>php5ts.dll</em> available to the web server and CGI and CLI binaries through one of the three following options:
<ul>
<li>Copy the file to the windows system directory (<em>C:/WINDOWS</em>)</li>
<li>Copy the file to the web server&#8217;s directory</li>
<li>Add the path to PHP to the PATH environment variable by following these <a href="http://us.php.net/manual/en/faq.installation.php#faq.installation.addtopath">easy steps</a>.</li>
</ul>
</li>
<li>Set up a valid <em>php.ini</em> file.  There are two available in your PHP folder: <em>php.ini-recommended</em> and <em>php.ini-dist</em>.  The &#8220;recommended&#8221; file makes your installation more secure, but if you are installing on a home machine, the &#8220;dist&#8221; file is fine.  Simply save the file as <em>php.ini</em> in your PHP folder.</li>
<li>Now, edit the <em>php.ini </em>file you just saved by finding the <strong>doc_root</strong> variable and setting it equal to the following: <em>C:\Apache\htdocs</em></li>
<li>Find the<strong> extension_dir</strong> variable and set it equal to <em>C:\PHP\ext</em></li>
<li>Be sure to use <strong>backslashes</strong> in the <em>php.ini</em> file.</li>
<li>Save the file and close it.</li>
</ol>
<p>Now you can begin installing Apache and finishing configuration.</p>
<ol>
<li>Download the latest release of Apache <a href="http://httpd.apache.org/download.cgi" target="_blank">here</a> (choose the last Win32 option).  Use the installer to set up Apache, and install it in <em>C:/Apache</em>.</li>
<li>To set up PHP to work as an Apache module, open the <em>httpd.conf</em> file (located in <em>C:/Apache/conf/</em>) and add the following lines to the bottom of the file:
<ul>
<li>LoadModule php5_module &#8220;c:/php/php5apache2_2.dll&#8221;</li>
<li>AddType application/x-httpd-php .php</li>
<li>PHPIniDir &#8220;C:/PHP&#8221;</li>
</ul>
</li>
<li>Be sure to use <strong>forward slashes</strong> in the <em>httpd.conf</em> file.</li>
<li>Save the file and close it.</li>
<li>Restart Apache by double-clicking the icon in your system tray.  Click the &#8220;Restart&#8221; button, and if Apache restarts, everything is ready to work!  If not, try working back through the steps and make sure your settings are correct.</li>
</ol>
<p>With Apache and PHP installed, visiting <em>http://localhost/</em> will load the files from your <em>C:/Apache/htdocs</em> folder, usually by default with an HTML file saying <strong>It works!</strong></p>
<p>Whatever method you employ, setting up Apache and PHP is rather easy and simple to do.  Choose the manner best suited for you, and follow the proper steps.  In no time, you&#8217;ll have your own Apache server with PHP set up on your computer.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://phpstarter.net/2009/01/configuring-php-on-windows-systems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Several mod_rewrite Tricks for a Better Web Application</title>
		<link>http://phpstarter.net/2008/07/several-htaccess-mod_rewrite-tricks-to-better-web-application/</link>
		<comments>http://phpstarter.net/2008/07/several-htaccess-mod_rewrite-tricks-to-better-web-application/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 12:42:51 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Advanced]]></category>

		<guid isPermaLink="false">http://wp.pr0gr4mm3r.com/?p=148</guid>
		<description><![CDATA[Apache&#8217;s .htaccess file options makes it easy to have clean URLs, smart redirects, and even control SSL connections.  In this post, I am going to give you several tips on how you make your web applications smarter.  Note that your server must support mod_rewrite in order to use these tips. Make Sure Everyone is on [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Apache&#8217;s .htaccess file options makes it easy to have clean URLs, smart redirects, and even control SSL connections.  In this post, I am going to give you several tips on how you make your web applications smarter.  Note that your server must support mod_rewrite in order to use these tips.</p>
<p><span id="more-7"></span></p>
<p><strong>Make Sure Everyone is on the Same Domain</strong></p>
<p>Even if you don&#8217;t have multiple domains pointing to your site, it&#8217;s possible that www.example.com <strong>and</strong> just example.com will work.  If that&#8217;s the case, Google and other search engines could be crawling your site twice and the website could take a ranking hit for duplicate content.  The following example shows how we can redirect visitors from two domains down to one.</p>
<blockquote><p>RewriteCond %{HTTP_HOST} ^www.example.net$ [NC,OR]<br />
RewriteCond %{HTTP_HOST} ^example.net$ [NC,OR]<br />
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]<br />
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]</p></blockquote>
<p><strong>Force SSL on Specific Site Directories</strong></p>
<p>I use SSL on a couple of my sites, but it doesn&#8217;t need to be enabled (or forced) on the entire site, so we use .htaccess mod_rewrite rules to enforce SSL where we need it.  The following peice of code will force SSL on all requests in the directory named &#8216;secure&#8217;.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteRule ^secure/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p>Both of these lines need to be copied if we need to enforce more than one directory, so if we need the directory &#8216;secure&#8217; and the the directory &#8216;users&#8217; secured, we would use this code.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteRule ^secure/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p>
<p>RewriteCond %{HTTPS} off<br />
RewriteRule ^users/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p>For the rest of the site, we don&#8217;t need SSL, so use something like this if we have the &#8216;secure&#8217; and &#8216;users&#8217; directory with SSL enabled.</p>
<blockquote><p>RewriteCond %{HTTPS} on<br />
RewriteCond %{REQUEST_URI} !secure/.*$<br />
RewriteCond %{REQUEST_URI} !users/.*$<br />
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p><strong>Force SSL on a Domain or Sub-Domain</strong></p>
<p>Similar to the need above, we can force SSL on an entire domain if we need to.</p>
<blockquote><p>RewriteCond %{HTTPS} off<br />
RewriteCond %{HTTP_HOST} ^wells-it.com$ [NC]<br />
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</p></blockquote>
<p><strong>Take a Website Offline</strong></p>
<p>If a website needs to go down for maintenance or whatever, that can be done with a simple few lines of code.  Just remember to change the page&#8217;s path in both lines where you see not-up.htm, or you could create a redirect loop.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^123\.214\.71\.126<br />
RewriteCond %{REQUEST_URI} !/static/not-up\.htm$<br />
RewriteRule .* /static/not-up.htm [R=302,L]</p></blockquote>
<p><strong>Remove &#8216;index.php&#8217; From the URL</strong></p>
<p>This is one that will come in handy if you use CodeIgniter or any other framework that sends all requests through index.php.  Basically, this code checks to see if the URL request exists as a static file or directory.  If does, it would be a picture, style sheet, javascript include, etc.  If it is not found, then it assumes that it must be for the framework to handle, and it sends it to the index.php file.</p>
<blockquote><p>RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.*)$ /index.php/$1 [L]</p></blockquote>
<p><strong>Keep Visitors Off the Stage</strong></p>
<p>On my large sites, I have both a production copy and a stage copy.  The stage copy is where I do all my developing and testing.  When I am satisfied with the changes, I push the changes to my live site.  The problem is that I don&#8217;t want site visitors seeing my stage copy, so I use some mod_rewrite code to keep them off.  You need to know your IP address for this one, and if you have a dynamic IP, you will have to change the file every time you get a new one.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^56\.51\.98\.126<br />
RewriteCond %{HTTP_HOST} ^stage.wells-it.com$ [NC]<br />
RewriteRule ^(.*)$ http://wells-it.com/$1 [R=301,L]</p></blockquote>
<p>If you have multiple IP address that you want access to the stage, you can just add another condition.</p>
<blockquote><p>RewriteCond %{REMOTE_HOST} !^56\.51\.98\.126<br />
RewriteCond %{REMOTE_HOST} !^74\.65\.95\.128<br />
RewriteCond %{HTTP_HOST} ^stage.wells-it.com$ [NC]<br />
RewriteRule ^(.*)$ http://wells-it.com/$1 [R=301,L]</p></blockquote>
<p><strong>Turn .htaccess Into a Web Application Firewall</strong></p>
<p>I didn&#8217;t write this one, so I can&#8217;t take credit for it, but you can <a href="http://www.0x000000.com/?i=558" target="_blank">find the code here</a>.  It contains some very slick code to keep malicious page requests from getting through to your web applications.</p>
<p><strong>Final Notes</strong></p>
<p>Since some of these URL rewrites actually redirect the browser, it&#8217;s possible to get into a redirect loop where you will never satisfy the rules you have in place, and the browser will redirect forever&#8230;until it detects a loop and stops with an error.  If this happenes, try to see where the loop is or post a comment if you&#8217;re stuck.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://phpstarter.net/2008/07/several-htaccess-mod_rewrite-tricks-to-better-web-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
