|
|
|
|
|
|
Powered byD's Bloggie
| Weblog Archive browse by category ... |
|
|
|
|
Opera fix to work with Google Reader - 9:25 pm
Browser , Guides , Internet - DaRen
I don't know why, it seems that the "Search King" Google and Microsoft doesn't like Opera. I can understand why Microsoft sort of hates Opera, and you can find alot of news and rumours on the dark side between Microsoft and Opera. However it seems that there is no negative news that shows Microsoft hates Firefox. For Google, I still remember GMail does not support Opera when it first open the service to public. Now the problem no longer exists. But then, Google Reader and Opera is not living in harmony. In Opera, the elements in Google Reader are cramped up together. Firefox is working fine on it. It seems like Google and Mozilla has some sort of alliance thing between them. Maybe open-source thing will always be the most attractive/peaceful ones among others eh ?
I'm a big fan of Opera for years, but I don't hate Firefox. I still use Firefox once in a while. However, it's just a pain in the ass (alright, maybe it's not that serious) to open Firefox specially for Google Reader, while using Opera to surf other websites. I use Google Reader almost everyday to read news/feeds. For Opera fans out there, here's a fix to make Opera to work perfectly with Google Reader :
- Download Reader.js (contributed by unknown coder)
- Visit Google Reader main page
- Go to Tools menu, select Quick Preferences -> Edit site preferences -> Scripting. Under the Use Javascript file, point that to the newly downloaded Reader.js
- Refresh the page and get ready to read thousands of feeds that you subscribed ;)
Enjoy ;)
Last edited: Wed 2007-01-17 @ 19:56 , by DaRen 3 time(s)
Installing Apache 2.2.3, PHP 5.1.4 and MySQL 5.0.24 on WindowsXP (SP2) - 6:05 pm
since when it's so hard to setup a simple LAMP?
Guides , PHP , Site Issue , SQL , Web Hosting - DaRen
Last revised: 2007.01.17
I've enough headache last night trying to figure out how to make Apache 2.2.3 and PHP 5.1.4 to work together on Windows XP. After several hours of tweaking and changing the settings, I finally gave up and search for help on the web. It seems it's not my fault that they can't work in harmony. Most of the tutorial on the web is not detailed enough and the readme from Apache and PHP is gay. I'm no expert or guru on both of them, but I'll write down the steps required to get them working and hope that one day I can make somebody's life easier if they encountered the same problem as me =)
Installing Apache
- Go to Apache HTTP server project website to download the binary for windows. This guide uses Apache 2.2.3.
- Open the file and follow the prompt. When it ask for the Network Domain and Server Name, use "localhost" if you're setting up a local server on your computer for development purpose, otherwise fill in the address and name according to your server. In the Administrator’s Email Address field, use any email address (e.g. "admin@localhost").
- Continue clicking next and choose the setup type and path to install and complete the installation.
- If Windows (SP2) firewall prompt to ask about the program, just click "Unblock".
- At this point installation is completed, Apache HTTP server should be running as a service if everything is ok. Open your browser, type in http://localhost/ in the URL bar. You should see "It works !" on the page.
- To customize the httpd.conf file (located in /conf in Apache folder), open with any text editor. Look for DocumentRoot, change the path if you want. For example:
DocumentRoot "C:/Documents and Settings/user/My Documents/My Website/localhost/www"
The default path will be pointing to /htdocs in your Apache folder.
- If you changed the DocumentRoot mentioned above, remember to scroll down and look for a line that looks like
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/...">
Change the path in the <Directory> tag to the same you set for DocumentRoot in above. For example:
<Directory "C:/Documents and Settings/user/My Documents/My Website/localhost/www">
If you don't change it, you'll get Permission Denied when you browse http://localhost
- Change any other settings to suit your server or for scricter security. The above is sufficient for normal static html hosting. See below if you need a script parser like PHP for dynamic page output.
Enable mod_rewrite for URL rewrite
See Enable mod_rewrite in Windows in another entry in my weblog.
Installing PHP
- Go to PHP website to download the binary for windows. This guide uses PHP 5.1.4.
- Please take note that if you followed the below steps and it's still not working with Apache, continue to read down to the section Another way to make Apache and PHP work together.
- Unzip the contents to the path you desire (eg. C:\php\).
- Go to Control Panel -> System -> Advanced tab -> Click on Environment Variables. In the System variables list, look for the variable name Path. Select it and click on Edit. Append
;C:\php
at the back of the variable value.
- Now go back to the PHP folder (eg. C:\php\), make a copy of the file php.ini-recommended and rename it to php.ini. Open the php.ini file with text editor. *Note* This guide uses php.ini-recommended file, you can use the php.ini-dist if you know what you're doing.
- If you changed the value of DocumentRoot in httpd.conf file mentioned above (Installing Apache, Step 6), you need to change the doc_root value to , for example:
doc_root = C:/Documents and Settings/user/My Documents/My Website/localhost/www
- Save the php.ini. Now open the Apache httpd.conf file, look for the "LoadModule" section. At the bottom of the LoadModule block, insert the following lines:
# For php5 module
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
# Configure the path to php.ini
PHPIniDir "c:/php"
You can add another optional line if you know what you're doing:
AddType application/x-httpd-php .php-source .phps
*Updated 2007-01-17*
If you found a DLL file named php5apache2_2.dll in the PHP build you downloaded, change
LoadModule php5_module "c:/php/php5apache2.dll"
to
LoadModule php5_module "c:/php/php5apache2_2.dll"
- This step is optional. Scroll down a bit and look for something like
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Made changes to the DirectoryIndex and add index.php. The modified one should looks like
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
- Save the file and restart your computer (dont ask, just restart).
- Create a text file in your document root (eg. C:/Documents and Settings/user/My Documents/My Website/localhost/www), insert
<?php phpinfo(); ?>
into the file, save it and rename it to phpinfo.php.
- Start the Apache server as a service if it's not. Apache should be able to load the PHP module and start running. To check if everything is working, open your browser and type in http://localhost/phpinfo.php. You should get a page containing information on your installation of PHP and its settings. If you don’t, try restarting Apache. If Apache says it can't load the php5apache2.dll or it says that the module can't be found refer to Another way to make Apache and PHP work together section below
To manipulate the Apache web server via command line, open a command prompt in Windows, navigate to the folder /bin in your Apache folder and try the following commands.
Some useful command for Apache web server
| Command |
Description |
| httpd -k install |
Install Apache as a Windows service |
| httpd -k uninstall |
Remove Apache as a Windows service. If you didn't install Apache using windows installer and you want to uinstall it, it's better you call this command before you remove the folder manually. |
| httpd -k start |
Tell Apache to start |
| httpd -k restart |
Tell Apache to do a graceful restart |
| httpd -k stop |
Tell Apache to shutdown |
Installing MySQL
- Go to MySQL website to download the binary for windows. This guide uses MySQL 5.0.24.
- Extract the zip file and run the Setup file.
- You should choose the Custom installation, to allow you to select an installation path. Click Next to continue and install it.
- When you're asked register with MySQL, Skip it if you don't have time for it. Once the installation is complete, tick the option to launch the MySQL Configuration Wizard and finish it.
- On the configuration wizard, select the Standard Configuration option on the first screen and click Next.
- On next screen, leave the 2 checkbox in default, check the 2nd one (include Bin Directory in Windows Path) if you want to enter MySQL commands from the command prompt without first having to navigate to the MySQL \bin directory.
- On next screen, you can leave the password field blank for root user for you can assign a password for it. Depends on you but I strongly recommend you assign a password.
- Click Execute on the next screen to finish the installation. Restart your computer.
- After rebooting, to check if MySQL is running properly or not, open a command prompt and type the following command:
mysql -u root -p
You need to navigate to \bin in your MySQL folder if you didn't ask MySQL to setup the Path variable during installation. If you didn't setup the password for root user, just remove the -p in the above command.
If you get "Can't connect to MySQL server on 'localhost'" error message, that means MySQL server is not started yet. Go to Control Panel -> Administrative Tools -> Services and look for MySQL entry. Right click and select Start. Once it's started, you can make a connection to the server using the command stated above.
Alternatively, you can invoke MySQL by calling the following command:
mysqld-nt --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" MySQL
- Once you're connected to server using the root user account, type the following command:
mysql> show schemas;
You should get the following results:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.26 sec)
- Now you need to get PHP to talk to MySQL. Open the php.ini look for "Paths and Directories" section and find extension_dir, change it to:
extension_dir = "c:/php/ext"
- Scroll down and look for ;extension=php_mysql.dll. You need to uncomment it by removing the ';' (semi-colon). It should looks like
extension=php_mysql.dll
- This step is optional. Uncomment the ;extension=php_mbstring.dll if you need multibyte string functions (eg. to process unicode data)
- Save the file and start/restart Apache.
- *Hint* I strongly suggest that you should download the MySQL Administrator here and MySQL Query Browser here. MySQL Administrator has powerful functions that allows you to manage/browse/backup your MySQL server/database in GUI. MySQL Query Browser is a replacement for MySQL Control Centre. It's a GUI-based program that allows you to test/execute your SQL queries. Install the MySQL Query Browser first before you install the MySQL Administrator.
Isn't life's good when you do all the things just using your mouse ? =)
Voilà ~~~ ! There you go, everything should be working now. You shouldn't have any problem setup and run MySQL server. However, if everything goes that smooth, I wouldn't have to waste hours yesterday trying to figure out where it goes wrong. I can't get Apache to load PHP module, that's nasty and stupid problem.
Alright, If Apache says it can't load the php5apache2.dll or it says that the module can't be found then the below steps might save you... or not...
Another way to make Apache and PHP work together
- *Note* This section of guide assumes that you already install PHP. If not, please complete the steps in Installing PHP section before continue the steps below.
- *Updated 2007-01-17* On newer version of PHP (I tested with 5.2.0) you should able to find a DLL file name called php5apache2_2.dll. Now refering to Installing PHP - Step 7, change
LoadModule php5_module "c:/php/php5apache2.dll"
to:
LoadModule php5_module "c:/php/php5apache2_2.dll"
That should solved the problem and you can skip the steps below. If you're using older version of PHP build, please skip this step and follow the steps below.
- If you have Apache installed and you're stuck, uninstall it and remember to delete the folder manually for left overs (windows installer sometimes does not delete the config files, you need to clean it yourself). If you deploy Apache via a ZIP file instead of windows installer, you better do a httpd -k uinstall to uninstall the service then only you delete the folder manually.
- Download and install Visual C++ 2005 Redistributable Package from Microsoft. It can be downloaded at the link below:
Microsoft
- Download httpd-2.2.3-win32-x86-ssl.zip (binary by Steffen) from Apache Lounge or use the direct link below:
http://www.apachelounge.com/download/binaries/httpd-2.2.3-win32-x86-ssl.zip
*Note* This binary is build with VC 2005, that's why you need Visual C++ 2005 Redistributable Package.
- The Apache binary is in ZIP file, there is no windows installer for this build. Unzip and place it to your C:\Program Files\Apache 2.2.3\
- Repeat the steps in Installing Apache section to configure your Apache server.
- Download php5apache2.dll-php5.1.x.zip from Apache Lounge or use the direct link below:
http://www.apachelounge.com/download/mods/php5apache2.dll-php5.1.x.zip
- Unzip the file. Read the Readme First.txt.
- Copy & replace the php5apache2.dll to your php folder (eg. c:/php). Backup the original one if you feel to do so.
- Copy httpd.exe.manifest to /bin in your Apache folder.
- Open the httpd.conf file from /conf in your Apache folder. Look for ServerRoot and change the path to where you unzip the newly downloaded Apache binary. For example:
ServerRoot "C:/Program Files/Apache 2.2.3"
- Scroll down and look for
<IfModule alias_module>
...
...
...
ScriptAlias /cgi-bin/ ...
</IfModule>
Make sure the ScriptAlias is set to the correct path. For example:
ScriptAlias /cgi-bin/ "c:/Program Files/Apache 2.2.3/cgi-bin/"
- Scroll down and look for
# "c:\..." should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "c:\...">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Make sure the <Directory> tag has the correct path. For example:
<Directory "c:/Program Files/Apache 2.2.3/cgi-bin">
- Start your MySQL server and hit your Apache server. Your Apache should be able to load the php5apache2.dll now. For extra info, see also : http://www.apachelounge.com/forum/viewtopic.php?t=570
Hope this helps. By the way, I spent another 1/2 hr trying to locate another problem after I get the LAMP up (finally). The problem is that the raw source code of the PHP script is dumped out to my browser instead of excution output from the script. The cause of this problem is because one of the required php file starts with <? instead of <?php ... doh ! How strange, they worked in previous version of PHP5 I installed last time...
*EDIT 2006.08.30*
-- Hide the Visual C++ 2005 Redistributable Package actual link because the long url without spacing will not be wrapped by FireFox 1.5.0.6 during page rendering causing the page become "wide"
*EDIT 2006.09.19*
-- Added a how-to link to "Enable mod_rewrite in Windows"
*EDIT 2007.01.17*
-- Load php5apache2_2.dll instead of php5apache2.dll in newer version of PHP
Tutorial: PHP simple access control - 10:37 pm
Guides , PHP , Security - DaRen
Found a great PHP tutorial written by Harry Fuecks on SitePoint that shows you how to build a site with access control. The tutorial focus mainly on user authentication, user permission and user registration that builds on solid foundation. The tutorial is not in depth but it is simple and easy to understand and it comes with codes that's practical. Suitable for beginners that needs a little bit more than simple security.
Link: The PHP Anthology Volume 2, Chapter 1 - Access Control
*Note* The tutorial uses example of database function class from The PHP Anthology Volume I, Chapter 3 - PHP and MySQL
Enable mod_rewrite in Windows - 7:21 pm
Apache's module - mod_rewrite
Computing , Guides - DaRen
A quick tip to enable Apache's module, mod_rewrite, for Windows. You need the extra step 4 & 5 if you're still unable to enable the mod_rewrite in Windows.
- Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
- Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
- Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.
- Then, find the the below section in httpd.conf
DocumentRoot "C:/www/public_html"
#
# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# permissions.
#
- Now modify the option for AllowOverride to look like this:
<Directory />
Options All
AllowOverride All
</Directory>
Note:
The AllowOverride None in <Directory "C:/www/public_html" > scope will still disable url rewrite even though you got AllowOverride All in the scope of <Directory />. So be sure to check the AllowOverride options for every directory scope.
It's always convenient to use Options All but not a so-good-idea for stricter security. See Apache 2.0 directives for more info.
ps: Just to say "Woohoo ~~" for my weblog to hit over 100 entries =)
How to tie a tie - 11:03 pm
Step by step guide for dummies
Guides - DaRen
Found this when I'm clearing the files on my desktop - Step by step guide on how to tie a tie. Useful for guys (or female Avril Lavigne's fans).
Thought it might be useful for someone else so I post it out.
|
|
|
|
|