WikiMedia, PHP, MySQL, and Apache in Solaris 10

Screenshot of main Wiki page The following are notes on how to enable MediaWiki, PHP, MySQL, and Apache in Solaris 10. MediaWiki enables a Wiki using the same software as the WikiPedia encyclopedia that anyone can view and edit online.

MediaWiki requires a PHP-enabled webserver and MySQL. Stock Solaris 10 comes with Apache and MySQL. PHP is installed from the Solaris Software Companion CD. MediaWiki consists of downloaded PHP scripts that use MySQL. The following details each step.

MySQL

MySQL is part of Stock Solaris 10. If not installed, install packages SUNWmysqlr, SUNWmysqlt, and SUNWmysqlu. To enable, see file /etc/sfw/mysql/README.solaris.mysql. Here's what I did:
# /usr/sfw/bin/mysql_install_db
# groupadd mysql
# useradd -g mysql -d /var/mysql mysql
# chgrp -R mysql /var/mysql
# chmod -R 770 /var/mysql
# /usr/sfw/bin/mysqladmin -u root password pw # <--SET password (don't use root's)

# Highly-recommended for security for local access (no DB or code changes required):
# echo skip_networking >>/etc/mysql/my.cnf

Start and test:
# /usr/sfw/sbin/mysqld_safe --user=mysql &
# cd /usr/sfw/mysql/mysql-test; ./mysql-test-run

OpenSolaris or Solaris 10 Update automatic start:
svcadm enable mysql

Older Solaris 10 FCS automatic start and stop of mysql daemon at boot and shutdown:
# ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc0.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc2.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rcS.d/K00mysql


PHP

PHP is available on the "Solaris Software Companion" CD under category Development/Languages as package SFWmphp. Install and enable following instructions at /etc/apache/httpd.conf-php-example. Basicaly, run post-install script /opt/sfw/apache/x_postinstall

Apache

Screenshot of php test page Solaris comes with both Apache. If you don't have Apache installed, install packages SUNWapachd, SUNWapchr, and SUNWapchu.

To enable Apache, copy /etc/apache/httpd.conf-php-example to /etc/apache/httpd.conf. Edit httpd.conf. At minimum you need to change the "ServerName" line. I also change the "User" and "Group" lines to "User apache" and "Group apache" after adding an apache group and apache user:

# groupadd apache
# useradd -g apache -d /var/apache
The web documents live in /var/apache/htdocs.

Start Apache the first time with "/etc/init.d/apache". See if the httpd process is running, check the error log at /etc/apache/logs/error_log, and access with your web browser. On subsequent reboots, Apache will restart automatically if httpd.conf is present.

Verify PHP is enabled by going to http://localhost/phpinfo.php where localhost is the hostname of your system.

MediaWiki

There is no Solaris package for MediaWiki. Just download the PHP scripts from http://www.mediawiki.org/wiki/Download and follow the installation instructions at http://meta.wikimedia.org/wiki/Help:Installation Untar the files to /var/apache/htdocs/wiki such that you have file /var/apache/htdocs/wiki/index.php (you will need to move the files up a directory level). Then fix permissions as follows:
# cd /var/apache/htdocs/wiki
# chown -R apache:apache \*
# chmod -R o-rwx \*
# chmod -R g+rw config
Start the web browser and install and configure from there: http://localhost/wiki/config/ I kept the defaults for the database and sysop and set the password. The sysop and database password may be the same, but don't use root's password (as it's saved in cleartext in LocalSettings.php). After filling out the form click INSTALL. If you are successfully connected to the database, then copy and save the local settings:
cd /var/apache/htdocs/wiki
mv config/LocalSettings.php .
cp LocalSettings.php LocalSettings.php.original
I made these customizations to LocalSettings.php after creating a logo:
$wgLogo = "$wgScriptPath/images/logo.jpg";
$wgEnableUploads = true;
$wgUseImageResize = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/sfw/bin/convert";
Now test by going to the main wiki page: http://localhost/wiki/ (where localhost is your system's hostname)

After customizing, it's a good idea to backup your LocalSettings.php file and dump the database to a safe location:

cp /var/apache/htdocs/wiki/LocalSettings.php LocalSettings.php.backup
/usr/sfw/bin/mysqldump --user=wikiuser --password=YOURPWHERE wikidb |gzip -9 >wiki-mysql-dump.txt.gz

Security Considerations

As Apache and MediWiki is web-facing software, you should consider security, especially if it's on the public Internet. Keeping the software up-to-date is an important part of security. The following tips should help secure your site:

  • Edit /etc/mysql/my.cnf and add this line: "skip_networking" (without the quotes) and restart MySQL. This restricts database access to the localhost only (this is the usual case 99% of the time, even with web-hosted apps). No database or code changes are required to do this.
  • Remove or rename phpinfo.php, as it leaks valuable information about your web server.
  • Update your Apache and MySQL software with security patches, if any, from SunSolve. Solaris 10 uses Apache 1.3.3, MySQL 4.0.15, and PHP 4.3.2. For example, MySQL for Solaris 10 has a patch with several security fixes (patch 120292 SPARC or 120293 x86).
  • You may want to download and compile the latest PHP software from www.php.net. The command line used to configure PHP is given by the phpinfo.php script. For Solaris 10 it is:
    ./configure --disable-cli --with-apxs=/usr/apache/bin/apxs --with-config-file-path=/etc/apache --with-mysql --enable-track-vars --prefix=/opt/sfw
  • Monitor MediaWiki for security updates.

More information

For more customizations and information see

Technorati Tags:

<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
Comments:

Your blog is life savor! I followed your instruction and everything went well except for GD. My understanding is that GD is required for PHP to render graphics. ================== # pkginfo|grep gd system SFWgd gd - GD Graphics Library I uncommented “#extension=php_gd2.dll’ in php.ini and ran ‘x_postinstall’ ================== #extension=php_gd2.dll to: extension=php_gd2.dll Nonetheless, I cannot get GD to work. You seem to have the specialty in Solaris system. I’d really appreciate your comment.

Posted by Brian Kim on December 06, 2005 at 09:06 AM PST #

Brian, I don't use the GD library, but you may want to see Tom Boutell's GD FAQ which briefly discusses PHP and GD. Look for error messages in the apache log. The \*.dll configuration applies to Windows only, so remove that line.

Posted by Dan Anderson on October 31, 2006 at 02:51 AM PST #

Post a Comment:
Comments are closed for this entry.
About

Solaris cryptography and optimization.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today