Sriram Natarajan's Weblog
- All
- General
- OpenSolaris
- Personal
- Sun
- Web Server
- Web Stack
Getting Started with Web Stack - Apache, MySQL, PHP and Ruby on Open Solaris
If you had recently tried out OpenSolaris 2008.05 and are wondering, where to find Apache, MySQL or PHP components within this installation, please check out our Getting Started Guide . Originally, this guide is supposed to live under here - but for some reason it didn't happen. Hopefully, learn link within OpenSolaris will be updated soon to reflect thisPosted at 02:25PM May 09, 2008 by natarajan in Web Stack | Comments[0]
Famous 5 minute installation of Wordpress with OpenSolaris 2008.05
So, if I had to setup a blogging web site, where would I go other than the favorite - WordPress. I followed their famous 5 minute installation steps within OpenSolaris 2008.05 and here we go.
* OpenSolaris 2008.05 is a LiveCD based distribution . So, if you need a AMP stack, you can get this on demand by running the following command
[sriramn@sriram-laptop]: pfexec pkg install amp
* Now, you can initialize and configure Apache and MySQL service by doing something like
[sriramn@sriram-laptop]: pfexec /usr/sbin/svccfg import /var/svc/manifest/application/database/mysql.xml
[sriramn@sriram-laptop]: pfexec /usr/sbin/svccfg import /var/svc/manifest/network/http-apache22.xml
[sriramn@sriram-laptop]: pfexec /usr/sbin/svcadm enable network/http:apache22
[sriramn@sriram-laptop]: pfexec /usr/sbin/svcadm enable database/mysql:version_50
* Now, let us configure a Wordpress database within MySQL database. So, let us do something like
[sriramn@sriram-laptop]: pfexec /usr/mysql/bin/mysql -u root
here is a sample output that you would expect to see...
[sriramn@sriram-laptop]: pfexec /usr/mysql/bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Now , let us create a new database and assign a user to this.
mysql> create database wordpress;
mysql> select database wordpress;
mysql> grant all privileges on wordpress.* to wp@localhost identified by 'wp';
mysql> flush privileges;
mysql> quit;
* At this point, we have created a new database 'wordpress' with a user 'wp' and with password 'wp' assigned to manage this database. Well, not a whole lot secure but a good starting point though.
* Now, you can download WordPress 2.5.1 from here unpack it to /var/apache2/2.2/htdocs - default apache document root directory.
* Now, copy /var/apache2/2.2/htdocs/wordpress/wp-config-sample.php to /var/apache2/2.2/htdocs/wodpresswp-config.php and edit the first four lines of the file to reflect the just now configured database name , user name and password.
[sriramn@sriram-laptop]: cd /tmp
[sriramn@sriram-laptop]: wget http://wordpress.org/latest.zip
[sriramn@sriram-laptop]: cd /var/apache2/2.2/htdocs/w
[sriramn@sriram-laptop]: pfexec unzip /tmp/wordpress-2.5.1.zip
[sriramn@sriram-laptop]: pfexec cp wordpress/wp-config-sample.php wordpress/wp-config.php
pfexec vi wordpress/wp-config.php and edit this file - first four lines and provide your database name, user name and password . In my case, wordpress/wp-config.php file looks something like
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'wp'); // Your MySQL username
define('DB_PASSWORD', 'wp'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
* That's it . you are now ready to host your blog site . You should be able to reach your blog site by accessing http://localhost/wordpress
Simple, huh . Ah , one last thing - If you would like to take this site into production, you might want to enable to APC cache - which is integrated within OpenSolaris Web(AMP) Stack but not enabled as default. You could do this by editing /etc/php5/5.2.4/conf.d/apc.ini and for more APC related settings , please refer here.
Note: Once you enable APC, please remember to restart Apache service for this change to take into effect
[sriramn@sriram-laptop]: pfexec /usr/sbin/svcadm restart network/http:apache22
Hope, you find this useful. Feel free to ping me back if you have any suggestions or issues. Alternatively, you could visit OpenSolaris forum
Posted at 02:01PM May 05, 2008 by natarajan in Web Stack | Comments[1]
Getting Ruby or AMP (Apache, MySQL and PHP) on OpenSolaris 2008.05
Today, Sun officially released a distribution - OpenSolaris 2008.05 based on a 3 year long open source effort happening with Solaris at Open Solaris web site. You can catch more on this release from here.
Now, if you are web developer interested in figuring out how it is useful to you, here is what you might like
* Ruby binaries can be downloaded and installed with the single command
Open a command line terminal window and run the following command
pfexec pkg install ruby
Now, you can Ruby specific components by doing some thing like
pfexec /usr/ruby/1.8/bin/gem install <component name>
* MySQL or PHP developers can get their binaries (again from a command line window) by doing some thing like
pfexec pkg install amp
The Apache, PHP and MySQL binaries are available under /usr/apache2 , /usr/php5 and /usr/mysql directories respectively. The corresponding configuration files are found under /etc/apache2 , /etc/mysql and /etc/php5 directories respectively.
* Once you have successfully install MySQL or Apache , you will need to initialize the SMF service. The following command does the initialization job for you.
pfexec /usr/sbin/svccfg import /var/svc/manifest/network/http-apache22.xml
pfexec /usr/sbin/svccfg import /var/svc/manifest/application/database/mysql.xml
If in case, you wonder what is SMF - you might wanna check out Service Management Facility project page for more information on how this is useful to you.
* Now, you can start these Apache and MySQL services by doing something like
pfexec /usr/sbin/svcadm enable network/http:apache22
pfexec /usr/sbin/svcadm enable database/mysql:version_50
Similarly, the way to stop these services, if you need to , you would do
pfexec /usr/sbin/svcadm disable network/http:apache22
pfexec /usr/sbin/svcadm disable database/mysql:version_50
* PHP runtime is configured by default within default Apache Service. So, you should be able to deploy PHP applications by simply writing a PHP application within Web Server document root directory - /var/apache2/2.2/htdocs.
That is all you need to do to get your web site up and running. If you want to do Joomla or MediaWiki, you can simply unpack these tar ball within the web server document root directory (/var/apache2/2.2/htdocs) and hit their index page . This is all you need to get them up and running.
Does this sound simple enough for you to try it out ?
Now, if you need to read more information on this , please check out the Getting Starting Guide from here . Kindly, give OpenSolaris 2008.05 a spin and let us as to what you think and how we can improve it
Posted at 12:49PM May 05, 2008 by natarajan in Web Stack | Comments[0]
Drupal on Open Solaris
In my previous blog, I mentioned the availability of components like Apache, PHP and MySQL/PostgreSQL within Open Solaris and also how to setup a wiki site like Media Wiki on Open Solaris . So, here is a very much related one - setting up a content management site like Drupal on Open Solaris.
Installing / Configuring Web Stack within Open Solaris
If you haven't already, you might want to download and install Open Solaris Developer Express 01/08 .
To simplify the initialization and configuration steps required for Apache and MySQL within Open Solaris, engineers within Web Stack project like Ludovic Champenois have done an amazing job of creating a a 'initialize' script so as to successfully setup the Web Stack Environment within couple of minutes. Here is a screen snap shot of the Web Stack Initialize 'script' posted in Ludovic Champenois's Blog
Once the Web Stack 'initialize' script completes successfully, you are now ready to start Web Stack Apache 2 and MySQL service as shown here . This is pretty much all is needed to host your web site and start developing and deploying PHP scripts.
However, to use PHP 5.2.4 database shipped within Open Solaris, we will need this below temporary work around to force PHP runtime to use MySQL 5.0 based client library.
Open a terminal and become root from your Open Solaris box and run the following command (as a temporary work around)
| root> ln -sf /usr/mysql/5.0/lib/mysql/libmysqlclient.so.15.0.0 /usr/mysql/5.0/lib/mysql/libmysqlclient.so.12 |
Note: The above mentioned work around is needed only for Open Solaris Developer Express and Open Solaris Developer Preview 2. This issue has been resolved in recent builds of Open Solaris and this temporary work around is not needed if you are using Nevada build 83 or above.Installing Drupal
Now, you might want to download the latest version of Drupal from their web site and unpack the downloaded tar ball to Apache 2.2 document root location.These below commands show how to unpack and set up under Apache 2.2's document root.
root> cd /var/apache2/2.2/htdocs
root> /usr/sfw/bin/gtar zxvf <location of the downloaded tar ball>
Let us go ahead and create a symbolic link of the unzipped drupal tar ball to a valid name
root> ln -sf drupal-6.0 drupal
Configuring Apache for Drupal
Drupal actively uses '.htaccess' file within its installation. However, default apache configuration file, as part of security measure, has disabled the '.htaccess' file support. So, let us go ahead and create a drupal specific configuration.
Note: We will need to create a drupal specific apache configuration file at '/etc/apache2/2.2/conf.d/drupal.conf' so that Apache can load Drupal specific configuration after system restart as well. So, using a command line terminal window become root so as to save the below contents into /etc/apache2/2.2/conf.d/drupal.conf' as shown here.
root> cat > /etc/apache2/2.2/conf.d/drupal.conf
<Directory /var/apache2/2.2/htdocs/drupal>
AllowOverride All
RewriteEngine on
RewriteBase /drupal
</Directory>
<After pasting the above lines into your terminal window, press CTRL-D to save the above contents into drupal.conf>Configuring PHP for Drupal
Drupal requires PHP configuration to have support to include the current directory in the include path. So, let us edit the default /etc/php5/5.2.4/php.ini and make the following change
Open a command line terminal window and edit /etc/php5/5.2.4/php.ini file. Note: You will need to either edit this file as 'root' or use 'pfexec' command to ensure that you have the privilege to edit this file
Now search for 'include_path = ' in this file and edit this line to reflect like below. Note: This should be the line that doesn't have ';' in the front.
include_path = "./:/usr/php5/5.2.4/include/php"
Finally, restart Apache Service from the command line. This ensures that PHP runtime, loaded within Apache, is now aware of the changes that we just did within the 'php.ini' and 'drupal.conf' file.
root> /usr/apache2/2.2/bin/apachectl restart
Configuring MySQL for DrupalDrupal requires a separate database to be created and available for its use. For more information on how to configure this database, please check out the INSTALL.mysql.txt file found under
<drupal installation location> (For example, in our case, the file is under /var/apache2/2.2/htdocs/drupal-6.0/INSTALL.mysql.txt).
Please note that within Open Solaris, MySQL 5 is located under /usr/mysql/5.0/bin/ directory. You will need to be either as root as login as 'mysql' user to successfully create this database.
Configuring DrupalFinally, proceed to configuring Drupal and complete the rest of the Drupal configuration by visiting http://localhost/drupal . For more information on this configuration, also refer to 'INSTALL.txt' file found under /var/apache2/2.2/htdocs/drupal directory.
Technorati Tags: opensolaris, webstack, php, drupal
Posted at 04:39AM Feb 19, 2008 by natarajan in Web Stack | Comments[2]
Hardening PHP applications within Open Solaris
I thought, you might be interested in knowing that PHP binaries included within Open Solaris, also includes Suhosin , a useful php extension. Hmm... So, if you wonder as to what is Suhosin - please check out from their web site on Why Suhosin and its features. Note: Currently, PHP runtime / core integrated within Open Solaris is not patched with any patch like Hardening-PHP patch . We are still investigating on the various aspects of this patch. So, if you have any thoughts on the pros and cons of this patch, please write to us.
How to enable Suhosin extension within Open Solaris -
Un-comment the following line within /etc/php5/5.2.4/conf.d/suhosin.ini
;extension=suhosin.so
Please note that default configuration should be good enough for most of the customers. If in case, you would like to fine tune or customize your security settings, please visit Suhosin configuration page for more configuration options. You can edit '/var/php5/5.2.4/conf.d/suhosin.ini' to customize your suhosin setup.
Finally, you will need to restart Apache Web Server for this change to take into effect by doing some thing like
svcadm restart network/http:apache22
Posted at 03:30PM Feb 15, 2008 by natarajan in Web Stack | Comments[0]
Web Stack File layout
If you are new to Open Solaris and trying to deploy webtier technologies like Apache2, PHP/Ruby with PostgreSQL/MySQL then you might find the file layout of these components to be very different from what you would find on Linux or Windows. So, do check out File Layout section within 'Getting Started Guide' to get a quick walk through of the current file layout of these components.
Now, if you wonder as to why we included the version number of these components and not simply bundle these binaries under /usr/bin as is the case on Linux then here is the motivation - Most of the open source web tier technologies are in active development and these components provide no guaranteed compatibility from one release over the other. Hence, you will notice that the file layout include the version number of these components so as to allow co-existence of multiple versions, if deemed necessary.
Technorati Tags: opensolaris webstack
Posted at 04:16PM Feb 10, 2008 by natarajan in Web Stack | Comments[2]
Deploying MediaWiki on OpenSolaris (Developer Express)
As I mentioned earlier, Apache 2.2, MySQL and PHP has now been integrated within Open Solaris. If you haven't already, check out Solaris Developer Express 01/08 and let us know with your comments.
Here is a step by step instruction on how to deploy a Web 2.0 site like MediaWiki on Open Solaris using Apache 2.2, MySQL 5.0 and PHP 5.2.4 . Probably, for the first time in Solaris history, we can now deploy a Web 2.0 site in such a short time.
Download and Install Open Solaris Developer Express 01/08 .
To simplify the initialization and configuration steps required for Apache and MySQL within Open Solaris, engineers within Web Stack project like Ludovic Champenois has done an amazing job of creating a a 'initialize' script so as to successfully setup the Web Stack Environment within couple of minutes. Here is a screen snap shot of the Web Stack Initialize 'script' posted in Ludovic Champenois's Blog
Once the Web Stack 'initialize' script completes successfully, you are now ready to start Web Stack Apache 2 and MySQL service as shown here . This is pretty much all is needed to host your web site and start developing and deploying PHP scripts.
However, to use PHP 5.2.4 database shipped within Open Solaris, we will need this below temporary work around to force PHP to use MySQL 5.0 based client library. Note: Going forward, PHP build process has been modified to look for MySQL 5.0 based client libraries as well.
- Open a terminal and become root from your Open Solaris box
- Run the following command (as a temporary work around)
-
root> ln -sf /usr/mysql/5.0/lib/mysql/libmysqlclient.so.15.0.0 /usr/mysql/5.0/lib/mysql/libmysqlclient.so.12
Now, you will need to download MediaWiki tar ball from here and unpack the downloaded tar ball to Apache 2.2 document root location. Now, let us follow the instructions on how to configure MediaWiki as mentioned under 'Installation Instructions' within MediaWiki web site.
- These below commands show how to unpack and set up under Apache 2.2's document root.
root> cd /var/apache2/2.2/htdocs
root> /usr/sfw/bin/gtar zxvf <location of the downloaded tar ball>
Let us go ahead and create a symbolic link of the unzipped media wiki tar ball to a valid name
root> ln -sf mediawiki-1.11.1 mediawiki
Finally, proceed to configuring MediaWiki and complete the rest of the MediaWiki configuration by visiting http://localhost/medawiki as mentioned under 'Further Configuration' section within MediaWiki web site.
Technorati Tags: webstack,opensolaris,mysql,php,mediawiki
Posted at 08:06PM Feb 05, 2008 by natarajan in Web Stack | Comments[0]
P in SAMP stack is now part of Open Solaris
In addition to my day time job with Sun Web Server 7 development, I have recently got myself involved with Web Stack project that is responsible for integrating / improving the open source web tier technologies like PHP for Open Solaris. As part of this project, we have now successfully integrated PHP(version 5.2.4) with Open Solaris (Nevada) build 79b - aka known as Solaris Developer Express 01/08. Finally, with SXDE 01/08, I believe that we are now one step closer to facilitate our customers choose SAMP stack for their development and production requirements.
So, what is cool with this integration ? -
- Includes tighter and built-in support for Apache 2 pre-fork MPM
- Simply enabling Apache 2 SMF service is all is now required for developing PHP applications with your Web Server
- For example
- svcadm enable network/http:apache22
- tighter integration with PHP NetBeans IDE and also includes popular 3rd party PHP extensions like APC, XDebug and DTrace.
- Includes out of the box support for commonly used PHP extensions like LDAP, SSL, SOAP, JSON, MySQL, PostgreSQL, PDO, XML, Zlib
- PHP is compiled with Sun Studio compiler and includes necessary compiler optimizations to derive the best performance on Solaris.
And what is not so cool ...
- With the current integration, popular PHP extensions like IMAP, MCrypt are still missing. We are very hopeful of integrating the currently missing PHP extensions integrations , in the order of user popularity, in the next coming months.
- We all know that Open Solaris Developer Express 01/08 includes MySQL 5.0 database as well. However, due to a build issue, PHP is still looking for MySQL 4.0 client libraries instead of the default MySQL 5.0 client libraries. This issue is now resolved with Nevada build 83. So, for now, here is a temporary work around to work around this issue
- Open a terminal and become root from your Open Solaris box
- Run the following command
-
ln -sf /usr/mysql/5.0/lib/mysql/libmysqlclient.so.15.0.0 /usr/mysql/5.0/lib/mysql/libmysqlclient.so.12
We very much want to hear your thoughts on what we did right and how we can improve. So, please consider joining Web Stack discussion forum.
If this interests you, do give Solaris Developer Express 01/08 a spin and let us know. Instead of a stable build, if you would prefer to try out the latest and greatest, you can also check out - Open Solaris Community Express - (recent milestone build) .
Technorati Tags: webstack,opensolaris,php
Posted at 12:05PM Feb 05, 2008 by natarajan in Web Stack | Comments[0]
Friday May 09, 2008
