How to Enable SSL on Xampp with Vhosts
If you need to enable SSL on Xampp whilst stilling using vhosts, follow the next few steps. It assumes that you already have vhosts enabled.
Open xampp/apache/conf/extra/httpd-vhosts.conf
Around line 19 you should see “NameVirtualHost *:80″, below this line add “NameVirtualHost *:443″ (without quotes)
Then add a new vhost site just like a normal one but with *443 instead on *80 and the following lines:
SSLEngine on SSLCertificateFile conf/ssl.crt/server.crt SSLCertificateKeyFile conf/ssl.key/server.key
An example of this is:
DocumentRoot "C:/xampp/htdocs/myproject/public" ServerName mysite.local ServerAlias mysite.local SSLEngine on SSLCertificateFile conf/ssl.crt/server.crt SSLCertificateKeyFile conf/ssl.key/server.key
Restart Xampp apache and everything should work fine.
Setting up a Cron with Plesk using a PHP File
I have a Server with a Plesk control panel and I wanted to automate a PHP script using a cron (or crontab). Within Plesk it’s called a scheduled task. The problem is its not that user-friendly (but like everything it’s very easy once you know how) so below is how to do it.
In the above screenshot you will see that the fields look pretty straight forward however there are a few tricks you need to know. To get a cron to run every minute, hour, day or month you need to use a asterisk (*).
Once you’ve set the frequency of the cron you need to call a command. For PHP files you need to do the following:
- Give the path to the php folder, (usually just php)
- Type in “-q” (this suppresses the HTTP header output)
- Finally, give the path to you php file
The example above runs the following script every day at 00:07 in the morning.
php -q httpdocs/crons/stats.php
If you just put the php file into the command it will throw an error.
Installing LAMP on Ubuntu
So I been getting rather annoyed with CentOs recently, mainly due to the lack of PHP support above 5.1.6, especially with all the cool features of 5.3. Also I always seem to have massive trouble installing anything like Mcypt or Memcache.
So I thought I’d give Ubuntu a go and I’m now a convert! Everything went smoothly, not one issue or problem. The support forums are brilliant and almost all questions have already been answered. I dont know whether I’ve just got lucky (I guess only time will tell) but Ubuntu is now my first port of call when setting up a new server.
Below is a line by line tutorial on how I got setup with Ubuntu 10.04 Lucid. I don’t go into too much details on how to edit the files using nano or vi but you can have a look on my previous posts or online, otherwise you can sftp in using root and change the files that way, (my preferred method).
Install Lamp on Ubuntu
sudo tasksel install lamp-server You will need to enter a root mysql password for mysql
Change Apache Default Web Location on Ubuntu
If you need to change the default root location from /var/www to something else you can do so in the following file location. This is useful for using frameworks such as Zend Framework.
/etc/apache2/sites-available/default
Create file and add Fully Qualified Domain Name to Apache config (auto adds all in conf.d)
Create a new file call fqdn in:
/etc/apache2/conf.d/
In the top of the file write the following where mydomain.com is the domain name pointing to this server.
servername mydomain.com
Enable mod_rewrite on Ubuntu
a2enmod rewrite
Edit “AllowOverride None” for default site (usually the first 2 found on line 4 and line 10). Change to the following
AllowOverride All
Found in:
/etc/apache2/sites-available/default
Disable Directory Listing on Ubuntu
Inside: /etc/apache2/sites-available/default Add "-" before the word IndexesOptions -Indexes
Restart Apache on Ubuntu
sudo /etc/init.d/apache2 restart
Install Memcached on Ubuntu
apt-get install memcached apt-get install php5-memcache
Install Mcrypt on Ubuntu
sudo apt-get install php5-mcrypt
Install APC on Ubuntu
apt-get install php-apc /etc/init.d/apache2 restart
When you get erros you need to type
apt-get install re2c apt-get install gawk
Restart Apache
sudo /etc/init.d/apache2 restart
Other Useful Info on Ubuntu
PHP.ini Location in Ubuntu
/etc/php5/apache2/php.ini
How to install Memcached on Xampp on Windows 7
For one of my Zend Framework web applications I’m going to install memcached. I am currently using file cache however think memcached is a much better way to go. This post is one in a series:
- Installing Memcached on Windows 7 and Xampp
- Setting up Memcached Cache in Zend Framework
- Installing Memcached on Centos 5.
Installing Memcached on Xampp and Windows 7
1a. Go to your php.ini file usually located in C:/xampp/php/php.ini
find this line:
;extension=php_memcache.dll
and replace it with:
extension=php_memcache.dll
1b. If you cannot find this line simply add the following line to below where all the ;extension= lines.
extension=php_memcache.dll
2. Add the following to just below the new line
[Memcache] memcache.allow_failover = 1 memcache.max_failover_attempts=20 memcache.chunk_size =8192 memcache.default_port = 11211
3. Download the necessary php_memecache.dll file from the following location.
http://downloads.php.net/pierre/
For windows 7 I used the following file:
http://downloads.php.net/pierre/php_memcache-cvs-20090703-5.3-VC6-x86.zip
4. Unzip the php_memcache.dll file and put it into your php ext folder. Usually C:/xampp/php/ext/
5. Download memcached for windows here (make sure it’s the win32 binary):
http://code.jellycan.com/memcached/
6. Unzip and put the memcache.exe file into a desired directory (e.g. c:/memcached/)
7. Open command line in Windows Administrator Mode.
Click start, type in ‘Search programs and Files’ box, wait for the program cmd.exe to appear, right hand click on the icon and select run as administrator
8. Install the memcache service
Type the following into the command line
c:\memcached\memcached.exe -d install
If you dont get any errors it means it’s worked.
9. Start memcached
Type the following into the command line
c:\memcached\memcached.exe -d start, or net start “memcached Server”
10. Restart Xampp Apache
11. Test Memcache
Create a php file and paste the following code. Then go to the page. If you do not see any errors then it has worked.
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or
die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)
<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
?>
12. Just in case it doesn’t work: One other thing I did was to run the C:/memcached/memcached.exe file as administrator. This opens the ports on the windows firewall which might solve some problems.
Enable mod_rewrite in xampp
For some reason my install of XAMPP didn’t have mod_rewrite automatically enabled? Not really sure why but basically below are the instructions on how to enable .htaccess mod_rewrite in xampp.
1. Go to the directory of installation <C:\xampp>\apache\conf
2. Open and edit httpd.conf in a text editor
3. Find the line which contains
#LoadModule rewrite_module modules/mod_rewrite.so
and (uncomment) change to
LoadModule rewrite_module modules/mod_rewrite.so
4. Find all occurrences of
AllowOverride None
and change to
AllowOverride All
I think it appears 2 or 3 times on the configuration file.
5. Restart xampp
That’s it you should be good to go.
Recent Posts
- Diary of a Startup: I’ve Just Applied to Seedcamp
- Diary of a Startup: Create a startup for £14
- Sendmail on Ubuntu
- Adobe Air with Netbeans
- Best Firefox Plugins for SEO aka Addons
- Setup Ubuntu as a Web Server
- Changing Plesk Fast CGI to Apache PHP with ZF
- How to Access PUT data in Zend Framework
- 30 minutes until 30!
- Google Analytics Benchmarking Newsletter July 2011
My External Links
Twitter Updates
- I'm at Earls Restaurant (229 Banff Ave, Wolf St, Banff) http://t.co/mYqKENLt 3 days ago
- New Local Dark Ale. Lovely @ Earl's - Banff http://t.co/otFtzHbQ 1 week ago
- I'm at Calgary International Airport (YYC) (2000 Airport Rd. N.E., Calgary) w/ 7 others http://t.co/IRI8zsHj 1 week ago
- I'm at BA Galleries Club Lounge South (at Terminal 5, LHR Airport, Heathrow) w/ 3 others http://t.co/FikQ8bSQ 1 week ago
- I'm at Terminal 5 (LHR Airport, 234 Bath Rd., Hounslow) w/ 8 others http://t.co/IbyWsNNf 1 week ago
- I'm at Yum Yum (5B Brewery Place, Brewery Wharf, Leeds) http://t.co/DKzTstpt 2 weeks ago
- RT @YahooFinance: The Case for a 21-Hour Work Week http://t.co/UFru9Pwy 3 weeks ago
- How Facebook's Expected $100 Billion IPO Breaks Down [INFOGRAPHIC] http://t.co/GxGMffP6 via @mashable 3 weeks ago
- I'm at Old Broadcasting House (Leeds Metropolitan University, at Civic Quarter, Leeds) w/ 4 others http://t.co/8M32KNy5 3 weeks ago
- Start 2012 by Taking 2 Minutes to Clean Your Apps Permissions. http://t.co/ltxMfrow 1 month ago





