You are browsing the archive for Web Server Tutorials.

Apache virtual hosts on local machine

January 1, 1970 in Web Server Tutorials

Many of us run a local version of the WAMP stack either on a laptop or development desktop, I run a version of Moodle on mine so I can test (and break) things to my hearts content without disrupting the main production server.

Recently a collegue of mine required some assistance with setting up Apache Virtual Hosts on a production server. It had been a while since I had done this so I decided to practise on my laptop as not to break the server. It was then I realised I would have to set up domain names on my laptop so I could check the virtual hosts actually work from sub domains. This got me thinking, “Why would anyone need other domains on a localhost pc?” After all, I simply type http://localhost/moodle or http://localhost/moodle2 etc.. to test my dummy sites. But then I liked the idea of typing http://moodle or http://wordpress to access my test sites! So hence this tutorial was born.

Step 1

Edit the following file

C:\WINDOWS\system32\drivers\etc\hosts

And include the extra hosts you require:

127.0.0.1 localhost
127.0.0.1 moodle
127.0.0.1 wordpress

Step 2

Now edit your apache config file and uncomment the line

Include conf/extra/httpd-vhosts.conf

Step 3

Now create a new folder anywhere on your system, this is where your new virtual host web pages will reside

Edit the file

confextrahttpd-vhosts.conf

Paste the following below and edit to match the paths to your created folders and substitute server name with the names of your hosts you created.

NameVirtualHost *:80
VirtualHost *:80
ServerName localhost
DocumentRoot “C\:wamp\www\”

NameVirtualHost *:80
VirtualHost *:80
ServerName wordpress
DocumentRoot “C:\vhosts\wordpress”

Now restart apache and test your host names by typing them in your browser. In the example above if I type http://wordpress then my browser points to a new folder on my C drive called vhosts. If I type http://localhost it defaults to my WAMP installation.Have fun!

Speed up Moodle using indexes

January 1, 1970 in Web Server Tutorials

Creating an index on the mdl_log table against info speeds up a standard Moodle installation. Some users have reported huge performance increases, so much so that people have suggested that this be in the standard Moodle build by default.

So far I have noticed some improvements but nothing quite as fantastic as other users are reporting, having said that, maybe you may notice a speed increase to your site, try it leave me a comment here.

Installing ORACLE drivers with PHP

January 1, 1970 in Web Server Tutorials

Installing ORACLE drivers with PHP should be easy, but in reality it can be quite difficult.

Our Student Information System (EBS) runs on ORACLE and I needed Moodle to talk directly to it using ODBC for ORACLE. In theory, all one needs to do is enable oci.dll in PHP.ini and make sure the extension resides in the Ext folder…but that would be too easy.

Here is how to make it work.

1) Copy oci.dll and ociw32.dll to your php/bin folder

2) Copy php_oci8.dll to php/ext folder and to your windows/system32 folder and to your windows directory

3) Check that your Oracle client is referenced in your Windows system path. (click my computer > properties > advanced > variables > paths) Make sure msvcr71.dll is in the system32 folder. Oracle needs this function properly!

4) Uncomment php_oci8.dll from php.ini

5) Restart Apache

6) Check your php info

7) You should see the oci8 module listed

Now the tricky part, When you run phpinfo you will see oci8.dll listed . But when you run php.exe from dos you may see a message saying the oci.dll is not loaded. If this is the case make sure you have copied oci.dll and ociw32.dll to the php folder.

If it still doesn’t work download the latest ones from the Oracle Client 10 basic and copy the new ones to your Oracle client folder and to the php/bin folder. This is how I got it to work. But I realised it occasionally crashed Apache, then i found out that php5.2.1 doesn’t work as well as 5.2.6 when using oci8.

Also try and use version 10 of the Oracle client, it”s much more stable than 9.

Installing APC for PHP

January 1, 1970 in Web Server Tutorials

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. It works by caching web pages and can significantly improve server performance, especially Moodle.

Installation Steps

Download the PHP extension (php_apc.dll)

Copy this file to your php/ext folder

Edit php.ini to include these lines of code:

extension=php_apc.dll
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64
apc.optimization = 0
apc.num_files_hint = 1000
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = On
apc.slam_defense = 0
apc.file_update_protection = 2
apc.enable_cli = 0
apc.stat=1

Now restart Apache and check your page to check that APC has loaded correctly.

Installing Memcache for PHP

January 1, 1970 in Web Server Tutorials

To put it simply, memcache is great. If you want to increase the performance of your server then you will want to install memcache. And it’s supported by Moodle too!

Memcache works by alleviating the workload of your database server. It runs as a service and can be configured to run with PHP. I’m not going to get into the particulars of how it works, just Google “how memcache works” if you need to know more.

This article will focus on installing memcache for Windows and enabling it for Moodle.

Step 1 – Get memcache

Download memcache from http://code.jellycan.com/memcached/ (you will need the “win32 binary version”).

Step 2 - Installing memcache as a Windows service

Unzip the file and copy memcached.exe to say the C drive.
From Dos run enter this command, c:\memcached.exe -d install

Now start the service from Dos by typing this command:
net start “memcached Server”

Check your php/ext folder for the file “php_memcache.dll”

If you have it then move on, if not download it from http://pecl4win.php.net/ext.php/php_memcache.dll

Step 3 - Edit your php.ini file
Add this line to your php.ini file, or uncomment it if it”s already there:

extension=php_memcache.dll

Restart your webserver

Step 4 - Run php.info. If successful you should see memcache listed in your php.info page