Difference between revisions of "XAMMP - Apache/MySQL/PHP5/Perl"

From AwkwardTV
Jump to: navigation, search
(Enabling using the AppleTV installation)
m
 
(38 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[http://www.apachefriends.org/en/xampp.html XAMPP] is a simple, most practical and most complete webserver solution. The [http://www.apachefriends.org/en/xampp-macosx.html XAMPP for OS X] distribution provides an Apache 2 web server,  
 
[http://www.apachefriends.org/en/xampp.html XAMPP] is a simple, most practical and most complete webserver solution. The [http://www.apachefriends.org/en/xampp-macosx.html XAMPP for OS X] distribution provides an Apache 2 web server,  
integrated with the latest builds of MySQL, PHP (both 4 and 5) and Perl. It requires no dependencies.
+
integrated with MySQL, PHP and Perl. It requires no dependencies.
  
If you are an experienced web developer or a Mac enthusiast who needs to run a webserver, create dynamic webpages or use databases, this is your lucky day!
+
This is an alternative to enabling the [[enable Apache|Mac OS Apache server]] and installing [[install Perl CPAN|Perl CPAN]] which can be ported from a Mac running V10.4 "Tiger".
 +
 
 +
=Note=
 +
The XAMPP package gets installed in <code>/Applications</code> which is in the partition <code>/dev/disk3</code> (named <code>OSBoot</code>) and requires it to be mounted with write permissions.
 +
 
 +
In contrast, the <code>/Users</code> folder is linked to <code>/mnt/Scratch/Users</code> and as such is in the partition <code>/dev/disk4</code> (named <code>Media</code>) which is mounted on <code>/mnt/</code>. This allows the system to be located on a read-only partition and as such to be more immune to unproper power off.
 +
 
 +
If you want to keep the OSBoot mounted read-only, shutdown XAMPP and move the Applications folder to <code>/mnt/Scratch</code> and symlink the folder on root.
 +
 
 +
Anyway: once you've installed SSH on the AppleTV, you've decided to make a server out of it and you're going to treat it the right way.
  
 
=Prerequisites=
 
=Prerequisites=
  
 
=== XAMPP package===
 
=== XAMPP package===
The XAMPP package can be downloaded from their [http://www.apachefriends.org/en/xampp-macosx.html|XAMPP website].
+
The XAMPP package can be downloaded from their [http://www.apachefriends.org/en/xampp-macosx.html website].
 
Choose the <code>tar</code> version.
 
Choose the <code>tar</code> version.
  
 
===Unzip binaries===
 
===Unzip binaries===
Unzip binaries will be used on your AppleTV to extract the XAMPP package.
+
Unzip binaries will be used on your AppleTV to extract the XAMPP package, but aren't found on the AppleTV base installation.
  
 
* Download the binary Darwin for Intel distribution from the [http://www.opensource.apple.com/darwinsource/images/|Apple Opensource pages].<br>This contains many useful files.
 
* Download the binary Darwin for Intel distribution from the [http://www.opensource.apple.com/darwinsource/images/|Apple Opensource pages].<br>This contains many useful files.
Line 28: Line 37:
 
  mv /Users/frontrow/Documents/* /usr/bin/
 
  mv /Users/frontrow/Documents/* /usr/bin/
 
  chown root:wheel /usr/bin/*
 
  chown root:wheel /usr/bin/*
 +
 +
You might want to install further binaries...
  
 
=Installing XAMPP on the Apple TV=
 
=Installing XAMPP on the Apple TV=
Line 33: Line 44:
  
 
===On your Mac===
 
===On your Mac===
* Copy the <code>.tar.gz</code> file to your Apple TV (the way you prefer, AFP, SCP, etc...).<br>[http://rsug.itd.umich.edu/software/fugu/ Fugu] provides a graphical interface for this purpose.
+
* Copy the <code>.tar.gz</code> file to your Apple TV (the way you prefer, AFP, SCP, etc...).<br>[http://rsug.itd.umich.edu/software/fugu/ Fugu] provides a graphical interface for this purpose.<br>Having installed a [[Enable_SAMBA_server |Samba service]] on the AppleTV is another option.
  
 
* Open a SSH connection to your Apple TV.
 
* Open a SSH connection to your Apple TV.
 +
ssh frontrow@AppleTV.local
  
 
===On the AppleTV===
 
===On the AppleTV===
* Navigate to the download folder
+
* Navigate to the download folder.
  
 
* Get the required privileges:
 
* Get the required privileges:
Line 58: Line 70:
 
  XAMPP for MacOS X started.
 
  XAMPP for MacOS X started.
  
* Try your installation with the link http://AppleTV.local and choose a language.<br>Tip - If you get PHP errors, it's because you didn't extract it with the 'p' parameters. Re-extract it with the exact command.
+
* Try your installation by surfing to http://AppleTV.local and choose a language.<br>Tip - If you get PHP errors, it's because you didn't extract it with the 'p' parameters. Re-extract it with the exact command.
  
 
* Assuming it's working, it's time to secure your XAMPP installation.
 
* Assuming it's working, it's time to secure your XAMPP installation.
Line 74: Line 86:
  
 
You can modify the location of the web pages in <code>httpd.conf</code> and put your files at the proper location.
 
You can modify the location of the web pages in <code>httpd.conf</code> and put your files at the proper location.
 +
 +
=Configuring ProFTPD=
 +
Find the ProFTPD configuration file:
 +
find /Applications/xampp/ -iname proftpd.conf
 +
Mine is <code>/Applications/xampp/etc/proftpd.conf</code>
 +
 +
Once the configuration file has been modified, ProFTPD has to be restarted:
 +
/Applications/xampp/xamppfiles/mampp restart
 +
 +
=Using Perl=
 +
Using Perl scripts with the usual shebang
 +
#!/usr/bin/perl
 +
will start the already existing version of Perl.
 +
 +
If you want to use the one coming with xampp, you will have to:
 +
export PATH=/Applications/xampp/xamppfiles/bin:$PATH
 +
and use the following shebang in the Perl scripts
 +
#!/usr/bin/env perl
  
 
=Enabling at boot time=
 
=Enabling at boot time=
Line 80: Line 110:
 
Apple provides a page on [http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/StartupItems.html#//apple_ref/doc/uid/20002132-CJBBHDII how to create a Startup Item].
 
Apple provides a page on [http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/StartupItems.html#//apple_ref/doc/uid/20002132-CJBBHDII how to create a Startup Item].
  
===Enabling using the AppleTV installation===
+
===Enabling using the AppleTV base installation===
  
The AppleTV already ships with an Apache startup file: <code>/System/Library/StartupItems/Apache/Apache</code> which will need some modifications
+
The AppleTV already ships with an Apache startup file: <code>/System/Library/StartupItems/Apache/Apache</code> which will need some modifications.
  
 
If not done already, get the required privileges:
 
If not done already, get the required privileges:
Line 92: Line 122:
 
  scutil --set LocalHostName NewName
 
  scutil --set LocalHostName NewName
  
Edit the file <code>/System/Library/StartupItems/Apache/Apache</code>:
+
Make your root partition to be mounted read/write at startup (XAMPP requires this):
* replace <code>apachectl</code> with <code>/Applications/xampp/xamppfiles/mampp</code>
+
touch /.readwrite
 +
 
 +
Edit the file <code>/System/Library/StartupItems/Apache/Apache</code> and add the following lines after the line <code>. /etc/rc.common</code>
 +
export PATH="/Applications/xampp/xamppfiles/bin:$PATH"
 +
alias apachectl='/Applications/xampp/xamppfiles/mampp'
  
Edit the file <code>/etc/hostconfig</code>:
+
Edit the file <code>/etc/hostconfig</code> and
 
* replace <code>WEBSERVER=-NO-</code> with <code>WEBSERVER=-YES-</code>
 
* replace <code>WEBSERVER=-NO-</code> with <code>WEBSERVER=-YES-</code>
 +
 +
Test it:
 +
SystemStarter restart "Web Server"
 +
 +
and surf to http://AppleTV.local
  
 
===Enabling with the help of AFP===
 
===Enabling with the help of AFP===
Line 103: Line 142:
 
  /Applications/xampp/xamppfiles/mampp start
 
  /Applications/xampp/xamppfiles/mampp start
  
To the file <code>/System/Library/StartupItems/AppleShare/AppleShare</code> after the <code>If</code> statement in the <code>StartService</code> function, and then XAMPP will startup at boot time.
+
to the file <code>/System/Library/StartupItems/AppleShare/AppleShare</code> after the <code>If</code> statement in the <code>StartService</code> function, and then XAMPP will startup at boot time.
  
 
'''Adding XAMPP to the AppleShare startup item is not recommended.'''
 
'''Adding XAMPP to the AppleShare startup item is not recommended.'''
Line 109: Line 148:
  
 
[[Category:How-to]]
 
[[Category:How-to]]
 +
[[Category:2.0]]
 +
[[Category:2.0.1]]
 +
[[Category:2.0.2]]

Latest revision as of 02:50, 28 September 2008

XAMPP is a simple, most practical and most complete webserver solution. The XAMPP for OS X distribution provides an Apache 2 web server, integrated with MySQL, PHP and Perl. It requires no dependencies.

This is an alternative to enabling the Mac OS Apache server and installing Perl CPAN which can be ported from a Mac running V10.4 "Tiger".

Note

The XAMPP package gets installed in /Applications which is in the partition /dev/disk3 (named OSBoot) and requires it to be mounted with write permissions.

In contrast, the /Users folder is linked to /mnt/Scratch/Users and as such is in the partition /dev/disk4 (named Media) which is mounted on /mnt/. This allows the system to be located on a read-only partition and as such to be more immune to unproper power off.

If you want to keep the OSBoot mounted read-only, shutdown XAMPP and move the Applications folder to /mnt/Scratch and symlink the folder on root.

Anyway: once you've installed SSH on the AppleTV, you've decided to make a server out of it and you're going to treat it the right way.

Prerequisites

XAMPP package

The XAMPP package can be downloaded from their website. Choose the tar version.

Unzip binaries

Unzip binaries will be used on your AppleTV to extract the XAMPP package, but aren't found on the AppleTV base installation.

  • Download the binary Darwin for Intel distribution from the Opensource pages.
    This contains many useful files.
  • Untar the file (Double click in Mac OS X)
  • Mount the disk image (Double click in Mac OS X)
  • In the Terminal:
scp /Volumes/Darwin8_i386/usr/bin/zip frontrow@AppleTV.local:/Users/frontrow/Documents
scp /Volumes/Darwin8_i386/usr/bin/unzip frontrow@AppleTV.local:/Users/frontrow/Documents
scp /Volumes/Darwin8_i386/usr/bin/gzip frontrow@AppleTV.local:/Users/frontrow/Documents
scp /Volumes/Darwin8_i386/usr/bin/gunzip frontrow@AppleTV.local:/Users/frontrow/Documents
scp /Volumes/Darwin8_i386/usr/bin/bzip2 frontrow@AppleTV.local:/Users/frontrow/Documents
scp /Volumes/Darwin8_i386/usr/bin/bunzip2 frontrow@AppleTV.local:/Users/frontrow/Documents
ssh frontrow@AppleTV.local
sudo -s
mount -uw /
mv /Users/frontrow/Documents/* /usr/bin/
chown root:wheel /usr/bin/*

You might want to install further binaries...

Installing XAMPP on the Apple TV

To Install the XAMPP package on the Apple TV follow this steps :

On your Mac

  • Copy the .tar.gz file to your Apple TV (the way you prefer, AFP, SCP, etc...).
    Fugu provides a graphical interface for this purpose.
    Having installed a Samba service on the AppleTV is another option.
  • Open a SSH connection to your Apple TV.
ssh frontrow@AppleTV.local

On the AppleTV

  • Navigate to the download folder.
  • Get the required privileges:
sudo -s
mount -uw /
  • Extract the downloaded file:
tar -xvzpf xampp-macosx-0.7.2.tar.gz -C /
  • Start your XAMPP:
/Applications/xampp/xamppfiles/mampp start

You should see the following:

Starting XAMPP for MacOS X 0.7.2...
XAMPP: File permissions are being checked... this may take a while.
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for MacOS X started.
  • Try your installation by surfing to http://AppleTV.local and choose a language.
    Tip - If you get PHP errors, it's because you didn't extract it with the 'p' parameters. Re-extract it with the exact command.
  • Assuming it's working, it's time to secure your XAMPP installation.
/Applications/xampp/xamppfiles/mampp security

Tip - If you give an SQL root password, the demos won't work any more.

Configuring Apache

Find the Apache configuration file:

find /Applications/xampp/ -iname httpd.conf

Mine is /Applications/xampp/etc/httpd.conf

Find the location of the web pages:

cat /Applications/xampp/etc/httpd.conf | grep ^ServerRoot

Mine is /Applications/xampp/xamppfiles/htdocs/

You can modify the location of the web pages in httpd.conf and put your files at the proper location.

Configuring ProFTPD

Find the ProFTPD configuration file:

find /Applications/xampp/ -iname proftpd.conf

Mine is /Applications/xampp/etc/proftpd.conf

Once the configuration file has been modified, ProFTPD has to be restarted:

/Applications/xampp/xamppfiles/mampp restart

Using Perl

Using Perl scripts with the usual shebang

#!/usr/bin/perl

will start the already existing version of Perl.

If you want to use the one coming with xampp, you will have to:

export PATH=/Applications/xampp/xamppfiles/bin:$PATH

and use the following shebang in the Perl scripts

#!/usr/bin/env perl

Enabling at boot time

Enabling the Apple way

Apple provides a page on how to create a Startup Item.

Enabling using the AppleTV base installation

The AppleTV already ships with an Apache startup file: /System/Library/StartupItems/Apache/Apache which will need some modifications.

If not done already, get the required privileges:

sudo -s
mount -uw /

Optional: set new host name

scutil --set ComputerName NewName
scutil --set LocalHostName NewName

Make your root partition to be mounted read/write at startup (XAMPP requires this):

touch /.readwrite

Edit the file /System/Library/StartupItems/Apache/Apache and add the following lines after the line . /etc/rc.common

export PATH="/Applications/xampp/xamppfiles/bin:$PATH"
alias apachectl='/Applications/xampp/xamppfiles/mampp'

Edit the file /etc/hostconfig and

  • replace WEBSERVER=-NO- with WEBSERVER=-YES-

Test it:

SystemStarter restart "Web Server"

and surf to http://AppleTV.local

Enabling with the help of AFP

Assuming you have enabled AFP (AppleShare) to start at boot, you can add the line:

/Applications/xampp/xamppfiles/mampp start

to the file /System/Library/StartupItems/AppleShare/AppleShare after the If statement in the StartService function, and then XAMPP will startup at boot time.

Adding XAMPP to the AppleShare startup item is not recommended.