Posts tagged sudo

Mod Security for Apache – Web Server Smart Firewall

Mod security has features that go above and beyond a standard firewall. It will help to prevent denial of service attacks, and also can be used to block traffic based on realtime blackhole lists issued by Spamhaus and others. Mod security is apparently in the Debian repositories as well as Ubuntu. In the Ubuntu repos you will have to enable the third party applications and update the aptitude databases. Then install:

sudo apt-get install libapache2-mod-security

Then enable the module:

sudo a2enmod security

By default there is a configuration file installed. The default configuration will provide you a basic starting point for the various security options available by the module. Please refer to the document for more information about what can be done. This blog shows how to use mod security to hit realtime blackhole lists to block nasty offenders of various natures.

http://www.inliniac.net/blog/2007/02/23/blocking-comment-spam-using-modsecurity-and-realtime-blacklists.html

Apache2 Server Side Includes

Server side includes allow for external html documents to be injected into a page prior to it rendering on the client web browser. The benifit of this is eliminating the need to repetitiously repeat code over and over again. If you include the same scripts, on each of your website pages, you can create an external html document and inject it using a server side include with a single line of code. If your using virtual host containers, you can include the server parameters directly in the file. Add the following directory block and make the directory path that of the virtual host block’s document root:

<Directory /var/www/*>
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>

Make .shtml the extension of the files you are including. I think you can make it anything, I just used “.html”.

Then enable the module:

sudo a2enmod include

Reload apache2:

sudo /etc/init.d/apache2 restart

Then include external html files using:

<!-- #include virtual="/mrtg/file1.html" -->

Apache 2 Manage Modules and Sites – Configuration Structure

Apache2 implements a structured method of organizing and enabling/disabling modules and sites. The default apache2 host is automatically turned on in /etc/apache2/sites-enabled/, and it includes the virtual hosting option. Therefore, by default, virtual hosting is enabled. Create your virtual host containers in /etc/apache2/sites-available, and then enable them by issuing the command:

sudo a2ensite xxxxx.com

VirtualHost containers are easy to format, and can point to any directory. An example virtualhost container is:

<VirtualHost *>
DocumentRoot /www/example1
ServerName www.example1.com

</VirtualHost>

# Other directives here

I tend to place the document roots in my main users home directory. Then chmod the entire document root with owner and group as your username, and then chmod it 775. A permission of 775 will give the owner and group write permissions. Then add www-data, the user running apache2, to your group:

sudo adduser www-data username

Now www-data can write to the document root, which comes in handy for many php solution including blogging software.

Modules are also managed using the a2 command. Use a2enmod/a2dismod respectively. Although with some modules like php5, when you install it the module is loaded automatically:

sudo apt-get install libapache2-mod-php5

Apache2 changed how the configuration files are coordinated. It is much more neater than containing everything in the httpd.conf file. Now there is the ports.conf file, and the sites-available/mod-available, and sites-enabled/mods-enabled directories. Essentially no real modification is required in the new apache2.conf file. The default listening port is configured in /etc/apache2/ports.conf.

Reblog this post [with Zemanta]

Remote Server Management in Local Facility – LTSP

I’m using LTSP to manage a server remotely in a local facility. I setup an LTSP server on the host machine, and will place it in an air-conditioned room to preserve longevity. I configured a machine, of much lower power, to PXE boot from the server. There are several nuances to setting up an LTSP server. Once all is done you realize that it is less complicated that is can or needs to be. When things go right there is essentially three step in total. First:

sudo apt-get install ltsp-server-standalone

This installs the works. Then configured dhcp.

sudo nano /etc/ltsp/dhcpd.conf

Config the subnet to the same that you are using on your router. Clearly if your routers local ip is 192.168.0.1 your subnet would be 192.168.0.0. Then set a range. Make sure you turn off the dhcp servers in any and all routers connected to the network. You need the dhcp server on the machine to be the sole and only. Set the “next-server” option to the came local ip address of the server. Then set the rest of the options; domain, default gateway, dns…. Then reboot the server:

sudo /etc/init.d/dhcp3-server restart

Build the clients:

sudo ltsp-build-client

Thats really all there is to it. I’ve found that problems do arise, and instead of trying to fix them just purge all the installed applications and start over.

sudo apt-get remove --purge ltsp-server-standalone ltsp-server xinetd

One time I was stuck because there were two tftp inet servers, openbsd-inetd and inetd-hpa. They were conflicting. Then purge the autoremove function:

sudo apt-get --purge autoremove

Then start over installing ltsp-server-standalone. You can test your ltsp server using VirtualBox. Just like a real machine set the boot sequence to network as the first option. Now hook up a fancy monitor that can support 1920×1080 to the relatively low powered machine in the other room, and remotely manage your server from a pseudo local desktop environment.

Nvidia Driver on Linux – Easy, and Quick

Image representing NVidia as depicted in Crunc...
Image via CrunchBase

There is a buzz that installing the Linux based Nvidia accelerated graphics driver is complicated. I consider it rather straight forward. First install build-essential, and the headers for your kernel. Those may appear to be some bigs words in the previous sentence, but it is really one line in a terminal window. Build essential installs GCC and its dependencies:

sudo apt-get install build-essential linux-headers-$(uname -r)

Now download the latest and greatest Nvidia driver. Choose the correct build type for your architecture. Conveniently save the file to your desktop and rename it to nvidia.run. The change your tty to another. To change to tty2 press control-alt f2.

Shut down gdm, which will stop X11:

sudo /etc/init.d/gdm stop

Or if you are using the new process manager in Ubuntu 9.10 you can use also:

sudo service gdm stop

Then execute the Nvidia installation script. Login to the command prompt and navigate to the desktop:

cd Desktop
sudo sh nvidia.run

Basically answer yes to everything, let the driver compile, and then when it asks you to configure the xorg.conf file, let it. Nowadays the Nvidia driver basically works out of the box. In the past, with Ubuntu in particular, you had to comment out the included driver in Ubuntu’s modules package, otherwise the custom compiled driver would not load on startup. The open source driver used to be commented out in /etc/default/linux-restricted-modules-common (comment NV); note that this is not needed any more except in Hardy (8.04).

Then start your gdm session, which will take you back to the login window, or your desktop depending on your startup settings:

sudo /etc/init.d/gdm start

Reblog this post [with Zemanta]

Linux CUPS Configuration – Foomatic

First install all needed packages. Your going to need cups, and the client, and the foomatic and openprinting drivers.

sudo apt-get install cupsys cupsys-client

Then install everything in:

sudo apt-cache search foomatic

If its an HP printer your going to want that library. HP has an auto setup script. Install the package and run:

sudo hp-setup

Installing all the foomatic, openprinting, and hp drivers the hp-setup script will detect printers on the network and will give you options as to which driver to use. To manage everything I recommend webmin. Download webmin from sourceforge, and use dpkg to install it. It will say dependencies are needed so just run:

sudo dpkg --configure -a

Webmin will install and you will access it from:

https://localhost:10000

You can configure other printers (other than HP) from here. You should set the printer to static ip address then you will configure the printer to that IP and port 9100. Select the corresponding from from the CUPS menu at the bottom of the printer configuration page. Some printers need a driver straight from openprinting.com. Copy the ppd to a folder in /var/share/ppd/openprinting. Create a folder with the manufacturers name if need be. Install it the same way as other printers (through webmin), and select the corresponding ppd drivers, in the CUPS section, the add new printer configuration page.