Installing Apache 2.4, MySQL 5.6, PHP 5.6 on FreeBSD 10.3
This article explains how to install the FAMP (FreeBSD, Apache, MySQL, PHP) stack using FreeBSD 10.3 as your base system. Please start with a freshly-built system to avoid bugs and conflicts.1. Preliminary steps
Perform an update on your system by using the following commands:freebsd-update fetch
freebsd-update install
2. Install and configure Apache 2.4
Let's install Apache 2.4 first. You may do so by running the following command:pkg install apache24
On
a brand-new system, you may get a message asking you to install the
package management tool. If so, just enter "y" here because you will
need this tool to complete the tutorial.When asked to proceed with installing apache24 (and several other packages), enter "y" here as well.
Next, edit /etc/rc.conf with the editor of your choice and add the following line to start Apache on reboot:
apache24_enable="YES"
Now start Apache with the following command:service apache24 start
Navigate
to your IP address in your browser and you should see the default "It
works!" Apache page indicating the installation was successful.Apache 2.4 is now installed on your system. The next step is to install MySQL 5.6.
Tip: Your site files are located in /usr/local/www/apache24/data/ . This is where you'll also find the default "It works!" Apache page.
3. Install and configure MySQL 5.6
The next step to install is MySQL 5.6. Do that now by running the following command:pkg install mysql56-serverWhen asked to proceed with installing mysql56-server (and a few other packages, including mysql56-client), enter "y" here.
Edit /etc/rc.conf again and add the following line to start MySQL on reboot:
mysql_enable="YES"
Now you may start MySQL with:service mysql-server start
At
this point you will need to make some security modifications to your
MySQL installation, particularly setting a root password and removing
test and anonymous data. Do that with the following command:mysql_secure_installation
- Press "Enter" at Enter current password for root (enter for none)
- Enter "y" at Set root password? [Y/n]
- Now enter a new secure password for the root MySQL user
- At Remove anonymous users? [Y/n], enter "y"
- Enter "y" at Disallow root login remotely? [Y/n]
- Remove the test database by entering "y" at Remove test database and access to it? [Y/n]
- g. Reload the privilege tables so your changes take effect by entering "y" at Reload privilege tables now? [Y/n]
mysql -u root -p
That
command should drop you into the MySQL shell. Congratulations, you've
successfully installed MySQL 5.6 on FreeBSD 10.3! Now it's time to
install PHP 5.6.4. Install and configure PHP 5.6
Again, we will use the pkg tool to install PHP 5.6. Do so with the following command:pkg install mod_php56 php56-mysql php56-mysqliEnter "y" when asked to proceed with installing the php56 packages.
Now edit /usr/local/etc/apache24/httpd.conf; the PHP file handler needs to be added and DirectoryIndex should contain index.php.
Locate the following block in httpd.conf:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Change it to the following if you want Apache to serve index.php first (swap them if you want Apache to prefer index.html):<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
At the end of httpd.conf, add the following lines then save and exit the file:<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
Now restart Apache so your changes to httpd.conf take effect:service apache24 restart
Test
that PHP is working correctly by creating a PHP file in
/usr/local/www/apache24/data/. Create a file there called "index.php"
and paste in the following code:<?php
echo "Hello world!";
?>
Reload your IP address in your browser and you should see
"Hello world!" instead of the default "It works!" Apache message from
earlier in the tutorial.You may need to restart Apache one last time if you still see "It works!" with:
service apache24 restartThat's it! You now have a fully functioning FAMP server ready to host your website.
For more reference and troubleshooting check link below
https://forums.freebsd.org/threads/43891/
No comments:
Post a Comment