Εγκαταστάσεις σε Unix/Mac OS X

Αυτή η ενότητα περιέχει σημειώσεις και υποδείξεις συγκεκριμένες για εγκαταστάσεις της PHP στον Mac OS X Server.

Χρησιμοποιώντας πακέτα

Υπάρχουν μερικές pre-packaged και pre-compiled εκδόσεις της PHP για το Mac OS X. Αυτές μπορούν να σας βοηθήσουν να ρυθμίσετε μια κανονική εγκατάσταση, αλλά αν χρειάζεστε ένα διαφορετικό σύνολο από χαρακτηριστικά (όπως ένα secure server, ή ένα διαφορετικό database driver), μπορεί να χρειαστεί να κάνετε build την PHP ή και τον webserver σας. Αν δεν είστε εξοικειωμένοι στην διαδικασία του building και compiling του δικού σας λογισμικού, μπορεί να αξίζει να ψάξετε αν κάποιος έχει ήδη κάνει build ένα πακέτο με την έκδοση της PHP και με τις ρυθμίσεις που χρειάζεστε.

Κάνοντας compile για τον OS X server

Υπάρχουν δύο ελαφρά διαφορετικές εκδόσεις του Mac OS X, η client και η server. Τα παρακάτω ισχύουν για τον OS X Server.

Παράδειγμα 3-2. Εγκατάσταση στον Mac OS X server

1. Get the latest distributions of Apache and PHP
2. Untar them, and run the configure program on Apache like so.
    ./configure --exec-prefix=/usr \ 
    --localstatedir=/var \ 
    --mandir=/usr/share/man \ 
    --libexecdir=/System/Library/Apache/Modules \ 
    --iconsdir=/System/Library/Apache/Icons \ 
    --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \ 
    --enable-shared=max \ 
    --enable-module=most \ 
    --target=apache 

4. You may also want to add this line: 
    setenv OPTIM=-O2 
    If you want the compiler to do some optimization. 
    
5. Next, go to the PHP 4 source directory and configure it. 
    ./configure --prefix=/usr \ 
    --sysconfdir=/etc \ 
    --localstatedir=/var \ 
    --mandir=/usr/share/man \ 
    --with-xml \ 
    --with-apache=/src/apache_1.3.12 

    If you have any other additions (MySQL, GD, etc.), be sure to add
    them here. For the --with-apache string, put in the path to your 
    apache source directory, for example "/src/apache_1.3.12". 
6. make
7. make install    
    This will add a directory to your Apache source directory under
    src/modules/php4.
    
8. Now, reconfigure Apache to build in PHP 4.
    ./configure --exec-prefix=/usr \ 
    --localstatedir=/var \ 
    --mandir=/usr/share/man \ 
    --libexecdir=/System/Library/Apache/Modules \ 
    --iconsdir=/System/Library/Apache/Icons \ 
    --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \ 
    --enable-shared=max \ 
    --enable-module=most \ 
    --target=apache \ 
    --activate-module=src/modules/php4/libphp4.a 

    You may get a message telling you that libmodphp4.a is out of date.
    If so, go to the src/modules/php4 directory inside your apache
    source directory and run this command: 

    ranlib libmodphp4.a 

    Then go back to the root of the apache source directory and run the
    above configure command again. That'll bring the link table up to
    date. 

9. make

10. make install

11. copy and rename the php.ini-dist file to your "bin" directory from your
    PHP 4 source directory:
    cp php.ini-dist /usr/local/bin/php.ini 

    or (if your don't have a local directory) 

    cp php.ini-dist /usr/bin/php.ini

Κάνοντας compile για τον MacOS X client

Αυτές οι υποδείξεις δόθηκαν ευγενικά από τον Marc Liyanage.

Το PHP module για τον Apache web server περιλαμβάνονται στον Mac OS X. Αυτή η έκδοση περιλαμβάνει υποστήριξη για τις MySQL και PostgreSQL βάσεις δεδομένων.

Σημείωση: Δώστε προσοχή όταν το κάνετε αυτό, μπορεί να χαλάσετε τις ρυθμίσεις του Apache web server σας!

Κάντε τα εξής για να εγκατασταθεί:

Τώρα γράψτε "sudo open -a TextEdit /etc/httpd/httpd.conf" το TextEdit θα ανοίξει με το web server configuration αρχείο. Βρείτε αυτές τις δυο γραμμές προς το τέλος του αρχείου: (Χρησιμοποιείστε την εντολή Find)
#AddType application/x-httpd-php .php 
   #AddType application/x-httpd-php-source .phps
Αφαιρέστε τις δύο hash marks (χαρακτήρες δίεσης) (#), αποθηκεύστε το αρχείο και κλείστε το TextEdit.

Τέλος, γράψτε "sudo apachectl graceful" για να επανεκκινήσετε (restart) τον web server.

Η PHP πρέπει τώρα να είναι ενεργή και να τρέχει. Μπορείτε να το ελέγξετε αυτό αφήνοντας ένα αρχείο στον κατάλογο "Sites" που να λέγεται "test.php". Μέσα σε αυτό το αρχείο γράψτε αυτή τη γραμμή: "<?php phpinfo() ?>".

Τώρα ανοίξτε το 127.0.0.1/~your_username/test.php μέσα στον web browser σας. Θα πρέπει να δείτε έναν πίνακα με πληροφορίες για το PHP module.