Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, October 4, 2008

Installing LAMP on Ubuntu

Installing LAMP. If you want to use apt-get install the LAMP layer,

$ sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server

Or you can use one taskseltry command:

$ sudo tasksel install lamp-server

Configuring MySQL. Set password for MySQL. tasksel will ask you for root password during installation.

$ mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('lamepassword');

Creating database and user

mysql> CREATE DATABASE lamedatabase; mysql> GRANT ALL PRIVILEGES ON lamedatabase.* TO 'lameuser'@'localhost' IDENTIFIED BY 'anotherlamepassword'; mysql> FLUSH PRIVILEGES;

Configuring Apache. If you get following error when you start apache2 server,

apache2: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

you need to add ServerName localhost in apache2 configuration file.

Wednesday, February 20, 2008

Ubuntu Apache Virtual hosts

Virtual Hosts in Ubuntu. The easiest way to create new virtual host is to create a configuration file in /etc/apache2/sites-enabled. In this directory, you should see a symbolic link to the default virtual host located on /etc/apache2/sites-available/ if default host is enabled.

Usually, you want to do

  1. cd /etc/apache2/sites-available
  2. sudo vim virtualdomain.conf
  3. Write or copy virtual host configuration (see example below)
  4. sudo vim /etc/hosts
  5. Point virtual domain to localhost. For example:
    127.0.0.1 localhost virtualdomain
  6. sudo a2ensite virtualdomain.conf
  7. sudo /etc/init.d/apache2 reload

a2ensite is a script that creates the symlink to /etc/apache2/sites-available/virtualdoain.conf in /etc/apache2/site-enabled directory. This allows to allows quickly disable or enable the virtual host without deleting or moving the configuration file.

Example of virtual host using IP and Port Note that if the server is not listen to port 81, you need to put Listen 81.

Listen 81 NameVirtualHost 192.168.12.2:81 <VirtualHost 192.168.12.2:81> ServerAdmin webmaster@localhost DocumentRoot /home/auser/public_html <Directory /> Options FollowSymLinks AllowOverride None </Directory> ErrorLog /home/auser/log/apache2/error.log LogLevel warn CustomLog /home/auser/log/apache2/access.log combined ServerSignature On </VirtualHost>

Tuesday, February 12, 2008

Ubuntu Apache ServerName Warning

ServerName Warning. If you get following warning message:

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Make sure to add ServerName theservername in /etc/apache2/apache2.conf.

If ServerName directive is not set, then the default virtual host will respond to all request. Hens, the web site will work but the apache2 will return warning message during /etc/init.d/apache2 restart.

Tips. If you want your server to respond to with/without www. prefix, try ServerAlias directive.

Ubuntu Apache Alias directive warning

I noticed this warning message after Ubuntu update the Apache2.

[warn] The Alias directive in /etc/apache2/apache2.conf at line 240 will probably never match because it overlaps an earlier Alias.
It is dude to /icons/ alias was defined in both /etc/apache2/apache2.conf and /etc/apache2/mods-enabled/alias.conf. All you have to do to do is comment out one of them and restart the apache.