As a desktop, I have an iMac with Leopard. By default, Apache and PHP with MySQL extension are included with Leopard. And I develop applications that connect to MySQL, MsSQL and Oracle databases. Therefore, the "native" PHP is not enough for me. In addition, I need proxy_http_module for Apaches, which is also not out of the box.
Plus, PHP 5.3 came out, which I want to deliver.
What to do?
There are several options for solving this problem: using Fink, MacPorts, src.
I chose this option:
- Compile Apache from source.
- Compiling PHP from source.
- Install FreeTDS from ports.
- Install Oracle Instantclient from ports.
- Installing other necessary libraries (if necessary) from the ports. For example, I also installed freetype, jpeg, libpng, libmcrypt, curl, gettext
The installation algorithm will be as follows:
- Install MacPorts.
- Installation of FreeTDS from ports.
- Install Oracle Instantclient from ports.
- Install MySQL 5 from the ports.
- Installing other necessary libraries (if necessary) from the ports.
- Configuring and compiling Apache from source.
- Install Apache.
- Configuring and compiling PHP from source.
- Install PHP.
- Configure Apache / PHP / FreeTDS.
Itaks, let's get started.
')
1. Install MacPorts.
Downloading the dmg image of the latest ports from
www.macports.org . Run the installer. Most likely the installer will freeze by about 70%. Nothing terrible, it is worth waiting for 10-15 minutes in the hope that it will nevertheless be executed, and perhaps in the next releases this bug will be fixed.
Ports are put in / opt / local. To work with ports, use the port command. By the way for those who are not very close to the command line, there is a GUI application for working with ports -
Porticus .
First of all, after installation, we will update the ports themselves:
> sudo port selfupdate
2. Install FreeTDS.
We need FreeTDS to connect to Microsoft SQL Servers. Set FreeTDS with the following command:
> sudo / opt / local / bin / port -v install freetds
3. Install Oracle Instantclient.
Oracle Instantclient we need to connect to Oracle servers.
It is put similarly to freetds:
> sudo / opt / local / bin / port -v install oracle-instantclient
The only remark here is that the distraction machine will not download and it will be necessary to download them from the Oracle website with handles. However, when executing this command, it will be said about it and links will be given from where to download. After downloading distributions from the Oracle site, they will need to be put into / opt / local / var / macports / distfiles / oracle-instantclient /. After that, start the installation again.
4. Install MySQL 5.
We need a client part (libraries and headers) to connect to MySQL servers.
We also install from ports:
> sudo / opt / local / bin / port -v install mysql5
5. Installing other necessary libraries.
If you want to build PHP with support for any additional libraries, you may need to install these libraries.
In my case, I additionally put: freetype, jpeg, libpng, libmcrypt, curl, gettext, libiconv.
The whole installation is similar:
> sudo / opt / local / bin / port -v install freetype
> sudo / opt / local / bin / port -v install libmcrypt
> sudo / opt / local / bin / port -v install libpng
> sudo / opt / local / bin / port -v install curl
> sudo / opt / local / bin / port -v install gettext
> sudo / opt / local / bin / port -v install libiconv
6, 7. Configuring, compiling and installing Apache.
Downloading the Apache source from
www.apache.org . I installed the same branch that is in the system, 2.2.x. At the moment it is 2.2.11. Unpack and run the configuration:
> ./ configure --enable-layout = Darwin --enable-mods-shared = all - enable-proxy - enable-speling
Here we indicate which additional modules we want to build.
After that compile and install:
> make
> sudo make install
Apache is put in place of the one that was in the system.
8, 9. Configuring, compiling and installing PHP.
Well, the most important thing is to build and install PHP. It seems that everything should be simple, but there are some subtleties. One of them is that, for example, mysql puts libraries in / opt / local / lib / mysql5 / and header files in / opt / local / include / mysql5 / instead of / opt / local / lib / mysql / and / opt / local / include / mysql / respectively. But that's okay. Fix it by making the appropriate links:
> sudo ln -s / opt / local / lib / mysql5 / opt / local / lib / mysql
> sudo ln -s / opt / local / include / mysql5 / opt / local / include / mysql
Downloading PHP source
files from
www.php.net .
After that, you can run PHP configuration:
> ./ configure --prefix = / usr --sysconfdir = / etc --localstatedir = / var --mandir = / usr / share / man --with-openssl = shared --with-zlib --with-bz2 - -with-curl --enable-ftp --with-gd --with-gettext = / opt / local --enable-mbstring --with-mcrypt = / opt / local --with-mssql = / opt / local - -with-mysql = / opt / local --with-oci8 = instantclient, / opt / local / lib / oracle --with-png-dir = / opt / local --with-jpeg-dir = / opt / local - -with-freetype-dir = / opt / local --with-iconv = / opt / local --with-apxs2 = / usr / sbin / apxs --with-config-file-path = / private / etc / - enable-mod-charset
Here you should pay attention to the following points:
--with-oci8 = instantclient, / opt / local / lib / oracle
--with-apxs2 = / usr / sbin / apxs
and the fact that extensions refer to / opt / local.
After configuration, run the compilation and installation:
> sudo make install
10. Configure Apache / PHP / FreeTDS.
If everything went well, we just need to configure all the components.
- We are convinced that the corresponding modules are loaded into httpd.conf. In my case it is php5_module, proxy_module, proxy_ftp_module, proxy_http_module
- Customize freetds.conf
- Configure php.ini
11. Links to resources, however I think that they are already obvious, but just in case.
www.php.net
www.apache.org
www.macports.org
www.freetds.org
Porticus
It seems everything.
In no case do I pretend that this is a complete setup manual, but perhaps it will be useful to someone.
Comments and comments are welcome.