Setup virtualhost in Apache on Solaris 10

apache No Comments

This one took a long time, There are loads and loads of examples out there but not all of them will work for your solution depending largely on what OS and version of Apache you are using. I am using Solaris 10 U4 and Apache 2.0.58.

You only need to amend 2 files. /etc/hosts and your Apache’s httpd.conf, which in my case is /usr/local/apache2/conf/httpd.conf.

In /etc/hosts add the ip address and fqdn of the apache2 servers. So on my host anouk, which has an ip address of 192.168.0.23 i would add the following:

192.168.0.23 anouk.dynalias.com
192.168.0.23 elthamauskick.dynalias.com

Next is the httpd.conf file. Vi and shift-g to scroll to the end of the file, which is the virtualhost section. This is what i added:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /work
</VirtualHost>

<VirtualHost *:80>
Servername anouk.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html
DirectoryIndex index.html index.php
Redirect /index.html http://anouk.dynalias.com/mgblog
</VirtualHost>

<VirtualHost *:80>
Servername elthamauskick.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html/auskick
DirectoryIndex index.html index.php
</VirtualHost>

And from here you could add as many virtualhosts as you would like. Note that inside each virtualhost you can add almost any Apache directive, but directives listed in other parts of the httpd.conf will be ignored if a virtualhost is found. The top virtualhost in the above example is used to capture any requests that fall out of the two virtualhost domains, so it displays an error message contained in /work.

With all the options available you will undoubtedly require the documentation, here is the link: http://httpd.apache.org/docs/2.0/vhosts. Google, as always, is your friend.  One last little tip, use the /usr/local/apache2/bin/httpd -S if you are having trouble, it will provide you with parsing info on the httpd.conf file.

List files out of DocumentRoot and password protect it using Apache

apache No Comments

To list the files in a directory with apache is very simple. All you have to do is add a directory alias to httpd.conf file. So if i want to add an alias called aliastest to directory /test i would add the following line:

alias /aliastest /test

Then i would go to my url:

http://myurl.com/aliastest

and i would see all files listed in /test directory (of course provided the permissions are set correctly). If i want to password protect it so that i can only see the files if i enter a username and password i add this to the directory section of httpd.conf;

<Directory “/test”>
Options Indexes MultiViews
AllowOverride AuthConfig
AuthName “test”
AuthType Basic
AuthUserFile /test/.htpasswd
AuthGroupFile /dev/null
require user test
Order allow,deny
Allow from all
</Directory>

Don’t forget to add a user;

# /usr/local/apache2/bin./htpasswd -c .htpasswd test
New password:
Re-type new password:
Adding password for user test

Then ensure the settings in the /Directory such as AuthUserfile is correct, restart apache and you’re good. There are many, many options for securing apache and this is very basic, so don’t go hiding sensitive information using this method.

crontab -e does not allow editing of cron

Solaris Admin No Comments

I see this one a fair bit these days, so i thought i would write it up. On most machines when i edit crontab i get the following:

amstel:/ # crontab -e
320

And i have to CTRL-D to get out of it. Note that that 320 can be any number, doesn’t matter. The point is you cannot edit cron.

All you have to do is add this line;

EDITOR=/usr/bin/vi;export EDITOR

To /etc/profile or /.bashrc or /.bash_profile etc.

Setup dual framebuffer (on Sunray server)

Solaris Framebuffers No Comments

I recently acquired a second monitor, which i just couldn’t get to talk to me. Because my work station is also the Sunray server for the demo Sunray clients in the office the /etc/dt/config/Xservers file reverts after reboot or dtlogin restart. After stopping the Sunray server with # /etc/init.d/utsvc stop the changes stayed.

Let’s look at the changes required to add a 2nd monitor, whether you’re on a Sunray server or not. If /etc/dt/config directory does not exist you will have to manually create it first.

# cp /usr/dt/config/Xservers /etc/dt/config/Xservers

#cp /usr/dt/config/Xconfig /etc/dt/config/Xconfig

Then you will have to change /etc/dt/config/Xservers line from:

:0 Local local_uid@console root /usr/X11/bin/Xserver :0 -nobanner

to (in my case at least - check your framebuffer type with fbconfig -list):

:0 Local local_uid@console root /usr/openwin/bin/Xsun +xinerama -dev /dev/fbs/pfb0a -dev /dev/fbs/pfb0b

To make the changes take effect you can either reboot or restart dtlogin using the following method. Logout, and at the welcome screen click on ‘command line logon’. Login, stop and start dtlogin using /etc/init.d/dtlogin stop then /etc/init.d/dtlogin start. Exit the command line session and wait for the welcome screen again. You should now have both monitors running in xinerama mode. If you don’t want xinerama mode just remove the +xinerama bit.

Don’t forget to restart your Sunray if you have one. # /etc/init.d/utsvc start.

GOTCHA: If you reboot your system you will have to stop Sunray services again, or the Xservers file will be replaced with the default.  Also, xinerama is a cpu hog, at times more than doubling the amount of cpu resources required if you ran dual monitor without xinerama.  Unfortunately my ex-manager that arranged this system was cheap and only put 1 cpu in.

« Previous Entries