利用 FreeBSD Ports 架設 Joomla3!

這裡大部份資料參考 Joomla3! 的官方網頁來翻譯,我配合我想要的 FreeBSD 的 OS 及軟體版本,稍微修改了一下。

https://docs.joomla.org/FreeBSD_Installation

Pre-requisites
  • Computer running FreeBSD.
  • Ports directory downloaded from CVSUP or Portsnap.
  • Knowledge on installing ports.
  • Desktop Environment installed.
  • Logged on to your DE as regular user.

Notes

  • This is just a quickstart guide; it does not deal with security settings, performance tuning, etc and therefore should not be used to set up a production server.
  • This will be a local install.
  • You MUST install via the ports because several packages lack vital settings.

Preperations

Open a terminal and log on as root.

Installing Apache Server

Execute the following commands to install your webserver.
cd /usr/ports/www/apache24
make config
Make any configuration changes you need to here. You need to enable MYSQL.
make install clean
Other options dialogs may pop up, make changes as you need. In most cases the defaults are just fine.
When done, add the following line to /etc/rc.conf
apache24_enable="YES"
And add the next line to /boot/loader.conf (if the file doesn't exist, create it)
accf_http_load="YES"
Next you need to modify your hosts file to reflect the hostname for your box. To find out the current hostname you can either read /etc/rc.conf and look for a line called hostname, or you can issue the command hostname. NOTE: the hostname MUST be a fully qualified name, e.g.
joomla-server1 is NOT OK <----- change it
joomla-server1.free.bsd is OK <---- leave it
Open /etc/hosts with the editor and change the lines starting with ::1 and 127.0.0.1 so that they become
::1 joomla-server1.free.bsd localhost
127.0.0.1 joomla-server1.free.bsd localhost
If you had to modify the hostname in /etc/rc.conf, you MUST reboot now. Otherwise you may start the apache server by issuing the following commands
kldload accf_http
/usr/local/sbin/apachectl start

Installing PHP

The following commands will install PHP5 to your computer.
cd /usr/ports/lang/php56
make config
Make any configuration changes you need here, You must enable APACHE
make install clean
When done, open /usr/local/etc/apache24/httpd.conf in a text editor and locate a line called <IfModule mime_module>. Then add the following lines (anywhere you like, yet above the first </IfModule>)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Locate a line called "DirectoryIndex index.html" and change it so that it becomes
DirectoryIndex index.php index.html

Installing Required PHP Extensions

Execute the following commands to install the required php extensions listed below.
cd /usr/ports/lang/php56-extensions
make config
In the options dialog make sure at least the following options are selected (as for the other options that are preselected, either leave them or turn them off, as desired).
  • JSON
  • MYSQL
  • SESSION
  • SIMPLEXML
  • XML
  • ZLIB
Then install the extensions.
make install clean

Installing mod_php56 php56-mysql php56-mysqli

利用 ports 安裝上述三項軟體.
cd /usr/ports/www/mod_php56
make install clean
.
cd /usr/ports/databases/php56-mysql
make install clean
.
cd /usr/ports/databases/php56-mysqli
make install clean

Installing MYSQL

Execute the following commands to install your MYSQL server.
cd /usr/ports/databases/mysql57-server
make install clean
cd /usr/ports/databases/mysql57-client
make install clean
The installation will fail if MYSQL is already installed (perhaps as a dependency). In this case uninstall and then reinstall MYSQL (both server and client).
make deinstall
make reinstall clean
Add the following line to /etc/rc.conf
mysql_enable="YES"
Start the server now by issuing this command
/usr/local/etc/rc.d/mysql-server onestart

或者改用如下指令
sudo service mysql-server start
Now that your MySQL database is running, you will want to run a simple security script that will remove some dangerous defaults and slightly restrict access to your database system. Start the interactive script by running this command:
sudo mysql_secure_installation
The prompt will ask you for your current root password (the MySQL admin user, root). Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing RETURN. Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions:
Enter current password for root (enter for none): [RETURN]
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorization.

Set root password? [Y/n] Y
New password: password
Re-enter new password: password
Password updated successfully!
For the rest of the questions, you should simply hit the RETURN key at each prompt to accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.
At this point, your database system is now set up and we can move on.


Configuring PHP

By default php does not create your php.ini for you, but it does give you examples
We will use these examples to create your php.ini
Execute the following commands to create your php.ini
cd /usr/local/etc/
During the install we will use the development example
cp php.ini-development php.ini
This creates a stock php.ini file, open it in your favourite text editor and modify it to your needs
Once you are done with this you can go to your website and install joomla

Installation of Joomla!


這裡我們還是利用 ports 來安裝 Joomla!

cd /usr/ports/www/joomla3
make install clean
新增 /usr/loca/etc/apache24/Includes/joomla.conf

Alias /joomla /usr/local/www/joomla3/
AcceptPathInfo On

<Directory /usr/local/www/joomla3>
AllowOverride None
Order Allow,Deny
Allow from all
# For Apache 2.4 add:
Require all granted
</Directory>

Post Joomla! Installation PHP Configuration

Now you will want to change your php.ini to the production one so run the following commands
cd /usr/local/etc/
mv php.ini php.ini-Dev-Configured
We name it php.ini-Dev-Configured you can use it again later without re-configuring it
cp php.ini-production php.ini
Now the poduction php.ini is installed so you need to configure it with your favourite text editor and you are done!
Again open your browser and point it to http://lyour_server_IP_address/joomla. You should now see the default Joomla! development site.

Troubleshooting

Most of the time problems arise from stale cookies and cached content. So delete your cookies and clean your cache. Otherwise,
restart the apache server
/usr/local/sbin/apachectl restart
restart the mysql server
/usr/local/etc/rc.d/mysql-server restart

留言

這個網誌中的熱門文章

電腦科評語

拔河技巧

三小時架好 FreeNAS 私有雲(3)