Practice
Task: the well-known LAMP stack (whose first letter stands for Linux) needs to be set up on FreeBSD. A sort of FAMP, if you will )))
Let's get started.

MySQL
First, let's install the MySQL server.
MySQL doesn't ask you for any configuration during the build - it just installs. Let's be patient - building a database server takes a while.
After the installation is done, let's also install the scripts:
Add the following line to the /etc/rc.conf file:
And start the MySQL server:
Now let's run the security script, where we set the root password (by default the password is empty) and answer "yes" to the remaining questions.
Apache
Next up - installing the Apache web server.
And here we're already offered a configurator to choose a number of options. Most of them are "mods" - mod_.
I won't give the full list here - it can be a bit different for everyone. I'll just say that, in addition to the default options, I recommend enabling:
And be sure to check that mod_rewrite (rewrite) is enabled - one of the tastiest bits of Apache: the Rewrite Engine - and also check that SSL is enabled, just in case you end up using a secure channel for some sites.
Apache also takes a while to install.
Now let's add the following line to the /usr/local/etc/apache22/httpd.conf file:
where instead of MyWebServer you specify the name of this server (whatever you want the server to be called in Apache's messages and the pages it generates).
After the installation, add the following to the /etc/rc.conf file:
And let's start the server (still with a bare configuration):
Installing PHP 5.3.x
Now let's install the latest available version of PHP (on FreeBSD, new versions appear fairly promptly).
Note. The "php5" directory contains the latest version - PHP 5.3; the "php52" directory contains the latest version of the 5.2 branch - 5.2.17.
In the configurator, we select the "Apache" option so that the PHP installer automatically adds its module for loading into Apache, and continue the installation.
Installing PHP extensions
PHP alone isn't enough - most sites use its additional modules (no need to look far - our own site uses them). For example, even iconv, gd, or imagick... the list goes on.
So, let's install the PHP extensions.
Here's a list of what I recommend enabling. Besides this, of course, you can add whatever you need on your server (on my servers the list is longer):
Webmasters and developers will certainly ask for whatever's missing for PHP, but the suggested list is a sort of universal starter kit - not complete, but no longer empty either.
That's it, click OK and install.
It installs even longer than MySQL, constantly pestering the admin with questions about the configuration of accompanying packages (from dependencies). So don't rush off for a coffee or tea break - it'll still put your brain through the wringer.
Finishing Apache's configuration for PHP
Even though we enabled the "Apache" option when building PHP, we still need to tweak the httpd.conf config file a little, located at:
/usr/local/etc/apache2/httpd.conf
Now let's find the section:
and just before the closing "" we insert the following lines:
Also, at the end of the configuration file, add the directive:
After which come the site descriptions, like:
(this, of course, is just an example)
And let's restart Apache:
SSL for Apache on FreeBSD
Comments