Configuration with WAMP

On my first blog, I introduced how to install WAMP server, but I didn’t say much about the configuration except changing default WAMP “www” directory. There are many detailed blogs on Internet about illustration of meaning of parameters in WAMP configurations. And documents are accessible through searching on Google. I just want to introduce some basic configuration after the complete of installation. Illustration about some configure parameters will be included.
Before we start, let’s have a look at WAMP directory:

• bin: contains binaries for Apache, MySQL, and PHP, in their respectively sub-directory. For each component, you can install multiple versions and select one of them in operation.
• apps: contains server-side tools such as PhpMyAdmin, SQL Buddy, and WebGrind.
• tools: contains client-side tool such as xdc (XDebug Client).
• www: is the apache server’s root directory.
• logs: contains apache access and error logs; and mysql log files.
• alias: contains the the apache’s alias configuration for PhpMyadmin, SQL Buddy and WebGrind.
• scripts: contains php files about WAMP server configuration.
• lang: language package
• tmp: temporary files

WAMP as a web server environment contains three parts of Apache, PHP and MySQL configuration. But first of all, it should be allowed by operating system to access localhost. I have added few lines to hosts file in Windows 7.
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost

Tips:

One should run editors like notepad, ultraedit as an administrator role to modify hosts file, or it is not allowed to be modified.

Apache configuration

Authority configuration should also be added in Apache. In httpd.conf file, the default authority setting should be looked like this:

#
# 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
# features.
#

Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
And I have change it as follows.

Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

So Apache are accessible in its website root directory. If you specify Indexes, Apache will list the directory contents of folders which have no index file (index.html, default.html, index.php, default.asp, etc). Otherwise you will likely get an error 403 – forbidden. FollowSymLinks tells Apache to show and follow symbolic links from this directory. There are other neat options, and having AllowOverride in the httpd.conf allows you to specify which of these options can be overridden with an .htaccess file.
Order denotes which way around these rules should be applied. Order Deny,Allow tells Apache that you will specify which IP addresses to deny before specifying who has permission to access these files.
You can essentially turn on any directory options from here that you might normally include in the directories definition in the httpd.conf. This is one of the main reasons I find it helpful and most people will do to run with AllowOverride all.
At last but not least, two lines have to make sure to be uncommented which indicates the location of PHP directory.

LoadModule php5_module “[WAMPSERVER_HOME]/bin/php/php5.4.3/php5apache2_2.dll"
PHPIniDir ="[WAMPSERVER_HOME]/bin/php/php5.4.3"

Tips:

One thing should be noted that the DLL file for Apache 2.2 is named php5apache2_2.dll rather than php5apache2.dll and is available only for PHP 5.2.0 and later.

[Click here to learn more about Apache on Windows]
Using Apache HTTP Server on Microsoft Windows

PHP configuration

The PHP’s configuration file “php.ini” is located at “[WAMPSERVER_HOME]\bin\apache\Apache2.2.xx\bin”. But if php.ini has other copies, the system will check php.ini file in “C:/Program Files[x86]/” first, and then in “C:/Windows/”. And the file will take into effect immediately as the system find one in those locations. DO MAKE SURE WHICH COPY IS USING before you start up your website by loading php file of with following content.
<!--?php phpinfo();

Besides that, to connect to a MySQL server, PHP needs a set of MySQL functions called “MySQL extension”. Usually, it is not necessary to load too many extensions. But two extensions are required.

extension=php_mysql.dll
extension=php_mysqli.dll

And you should run WAMP server homepage to confirm that.

MySQL configuration

MySQL configuration should be taken carefully since it will affect the success of WAMP start up. The configuration file “my.ini” is located at “[WAMPSERVER_HOME]\bin\mysql\mysql5.5.xx”. I have already introduced parts of it in my previous blog of WAMP installation.
[Click here to see more introductions of my.ini parameters]MySQL:: Using Option Files
Finally, I want to introduce phpMyAdmin configuration which is a free software tool written in PHP, intended to handle the administration of MySQL over the World Wide Web. The default WAMP setting is not allowed to access phpMyAdmin. One has to edit its configuration file of phpmyadmin.conf that is located under [WAMPSERVER_HOME]\alias directory. And added same lines of as we did in httpd.conf.
Tips: How to import big sql file?

phpMyAdmin provides convenient way to immigrate to another database by importing and exporting .sql.zip/.gz files. If you are not the first creator of your blog, you may need to import sql file to get your blog run. The truth is sometimes the sql file may be too big to import. I once successfully uploaded over 360MB file which if be extracted will reach more than 1.4GB. When try to import big sql file, one may get notice like
“Script timeout passed, if you want to finish import, please resubmit same file and import will resume.”
If you look at phpMyAdmin documentation, they say you have to check three parameters of upload_max_filesize, memory_limit and post_max_size in the php.ini to see if they are larger than the size you want to upload (1.16 I cannot upload big dump files (memory, HTTP or timeout problems), retrieved from http://localhost/phpmyadmin/Documentation.html#faq1_16). And the changed parameter will appear on phpMyAdmin web page. But that’s not enough. You also need to add few lines in config.inc.php file to set timeout setting to unlimited. The default value for that is 300 second.
$cfg[‘ExecTimeLimit’] = 0;
Another way supposed can make it work is to import sql file though mysql command line by inputting command, which require no importing time limit.
mysql -u username -p databasename < mysqlfile.sql
But I never make it out. Some weird notice may come out after zip file be extracted. And I don’t recommend that way.

Φ
[Click here to learn more about phpMyAdmin configuration] phpMyAdmin 3.5.1 Documentation
[Other optional WAMP configuration topics]
PHP Short Open Tag: Convenient Shortcut or Short Changing Security?
WordPress and “You do not have sufficient permissions to access this page.”
How to change the date.timezone value in PHP?

Why I can’t start my WAMP service?

It will be a frustrating problem if one cannot start WAMP server since nothing will appear on Apache error log. When I was dealing with my project with WAMP server, one day I noticed my WAMP server cannot start up. Normally, after clicking on WAMP icon, it will first be red, and then turn brown. At last, it will be green if everything works fine. Mine was stuck onto brown for quite a long time. Two things I have to make sure first. One is to check if my TCP/IP port of 80 was occupied by other applications. To make sure this, I opened my command line window, and input as follows:

  1. –netstat –ano
  2. Get the PID of the process that is taking the TCP/IP port of 80.
    1. Kill the process
    2. Redefine WAMP listening port

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

But it turned out that no process has occupied the port. Then I started to search if I have invalid file path or directory in httpd.conf file. Then I remembered I used to put my project on a portable hard drive which has changed to another drive letter recently. After I fixed this problem I searched online, this error mostly happens because 80 port was being occupied by some software like skype, but some configuration mistake may also lead to startup failure.

WordPress With PHP 5.4

Tips:

How to fix: PHP 5.4 – Feedwordpress plugin error “Call-time pass-by-reference has been removed”?

After the step of importing sql into my database, I got the error notice. It’s not hard to find the solution online. And it is easy to solve by editing two files of admin-ui.php and syndicatedlink.class.php which are under wp-content/plugins/feedwordpress folder. (see more on http://www.networkpanda.com/ngis/2011/12/how-to-fix-php-5-4-feedwordpress-plugin-error-call-time-pass-by-reference-has-been-removed/)

This problem was reported at end of last year. But not long after that its official website release its PHP 5.4 COMPATIBILITY to fix that problem, “This release has been audited to fix potential problems with deprecation notices or fatal errors under recent versions of PHP. In particular, all uses of run-time pass-by-reference have been eliminated from the code; if you were seeing a fatal error reading ‘Call-time pass-by-reference has been removed …’ then upgrading to this release should fix the problem (WordPress.org, see more on http://wordpress.org/extend/plugins/feedwordpress/changelog/).”
Φ

WordPress User Authority

WordPress keeps the users’ data in two tables: wp_users and wp_usermeta. If we look into the schema of these two tables, we can conclude that wp_users is used to hold a limited and finite amount of data about each user. Some of them are required and mostly used by the WordPress core, themes or plugins like the login, password, email and nice name (also nickname). But it’s not the case for the user_url field, for example. This field could fit in the wp_usermeta table since it’s not required. Continue reading

WAMP installation

WAMPServer is a Windows web development environment. It allows me to create web applications with Apache2, PHP and a MySQL database. Alongside, PhpMyAdmin allows easy management of databases.

WAMP offers an easy way for installation. Basically, the process contains four steps:

  1. Download and install WAMPServer
  2. How to use your local (localhost) web server
  3. Set up PHP configuration settings
  4. Managing the local MySQL database Continue reading