![]() |
Services | Software | Partners | Articles | Contact |
Installing a dedicated server or a VPS with Ubuntu Server 8.04 LTS (Hardy Heron) for Drupal 6.xBesides its success on the desktop, Ubuntu has become a popular server distribution as well. With the release of Hardy Heron 8.04, Canonical is making this release a Long Term Support (LTS) version, with 5 years support on servers. Many hosting companies offering dedicted and virtual private servers (VPS) offer Ubuntu as an option. That is not a surprise, because Ubuntu provides all the benefits that Debian provides: community maintained, vast repository of software packages, and superior dependency management, with more up to date packages. Drupal runs best on the LAMP stack (Linux, Apache, MySQL, PHP). This article describes how to setup Ubuntu Server 8.04 LTS for use with Drupal, making sure all the required software is configured, with special tweaks for performance and development. The article assumes that this is either a dedicated server, or a VPS. The usage of the server can be either a live server, or a development machine. Installing Ubuntu ServerIf you are on a VPS provided by a hosting company, they would have installed Ubuntu for you from images they maintain. Therefore, you can skip this section if you are using a VPS. Install Ubuntu normally using the installation instructions on Ubuntu's web site. When you reach the stage of selecting a Package Task, only select OpenSSH server. Do not select LAMP server nor Mail server. We will do those manually later, in order to control exactly what gets installed. Configuring a Static IP addressNote: If you are on a VPS, skip this section. In fact, you can lose access to your server inadverently if you make a mistake here. When the system reboots, you need to assign a static address to it if it is a live server. Edit the file /etc/network/interfaces to be as follows. Replace the IP address in the address and gateway with the correct values. auto eth0 Restart the networking stack. # /etc/init.d/networking restart If this is a remote server, with no console access, then it is best if you double check the settings and reboot instead of restarting the network. Update to the latest packagesIf you are installing from a CD, then the repository would have updated packages that are more recent than the ones on your CD. Before we install any software, let us make sure that we have the latest packages # aptitude update && aptitude dist-upgrade If the upgrade includes new kernel versions, we need to reboot now, so that we don't have to do it later. # shutdown -r now Install Apache, MySQL and PHP5We now proceed with installing Apache, MySQL and PHP5 (the AMP part of the LAMP software stack). For a mail server, we first install postfix as a personal preference. Ubuntu provides exim4 by default. If you are more comfortable with exim4 as a mail server, then skip this step. Ubuntu will install exim4 as part of the LAMP stack automatically. # aptitude install postfix When prompted, select "Internet site". Then we install Apache2: # aptitude install apache2 apache2-threaded-dev After that we install the MySQL database server: # aptitude install mysql-server When asked for a root password for MySQL, just hit Enter. And then we follow that by PHP5, PHP5's image handling (gd) and its connection to MySQL: # aptitude install php5 php5-gd php5-mysql Finally, we install a few packages that would allow us to install things from PHP's PECL and PEAR repositories. This would make installing apc and xdebug far easier than doing that from source. # aptitude install php5-dev php-pear make Optional: Install APCIf this is a live server, it is recommended that you install APC to boost PHP's performance. # pecl install apc Create a config file for it named /etc/php5/conf.d/apc.ini Put the following lines in it: extension=apc.so Optional: Install XCacheAlternatively, you can use the XCache op-code cache. # aptitude install php5-xcache For more details check our article on configuring XCache. Optional: Install XdebugIf this is a development server, you may want to install Xdebug if you are using a development environment that supports it. It helps with debugging and profiling PHP applications. Different IDEs like Komodo, Eclipse and even vim have support for Xdebug. # pecl install xdebug We have an article on using vim and Xdebug for debugging Drupal that you may want to check. Increase the memory for PHPUbuntu has changed the default for PHP's maximum memory size for scripts often. It used to be 8MB, then was pushed to 128MB with 7.10, and now with 8.04, it is back to 16MB. While this is adequate for Drupal's core, installing several contributed modules will often exhaust that. So start with 32MB by editing the file /etc/php5/apache2/php.ini and change the memory_limit line to: memory_limit = 32M Configure Apache's mod_rewriteDrupal's Clean URLs are a very useful feature. It requires the Apache mod_rewrite. First, enable the Apache module by executing this command: # a2enmod rewrite Then, edit the file /etc/apache2/sites-enabled/000-default, and change this section: <Directory /var/www/> So the line will be: AllowOverride All More Apache ConfigurationThere are a few Apache modules that are not really needed. We better disable them to save some memory. # a2dismod cgi We may also get better performance if we compress the HTML before we send it to the browser. For this we enable the deflate module. # a2enmod deflate Finally, restart Apache # /etc/init.d/apache2 restart Download and Extract DrupalFirst download Drupal by doing this: # cd /tmp/ Then extract the tarball # cd /var/www/ Move the files to the web root of the server # mv drupal-6.2/* /var/www And don't forget the hidden file ... # mv drupal-6.2/.htaccess /var/www Remove the file index.html, so Drupal's index.php will be the one that is executed by Apache # rm index.html Then change the permissions of the directory to the user that Apache runs as: www-data # chown -R www-data:www-data /var/www Create the Drupal databaseThe following command will create a database for Drupal: # mysqladmin create db Then grant privileges to it: # mysql Installing DrupalWe are now ready to install Drupal. Point your browser to the server (e.g. http://example.com) and you should be greeted by Drupal's installer. You will need to use the following values: Database name: db Database user name: user Database password: something Enjoy ... |


Great Guide
A great guide, especially useful are the parts for clean urls and increasing memory usage.
phpmyadmin
Thanks for great tutorial! I got through it first time installing linux server. Hell lot easier then doing it on the Windows or Mac OS X (10.3.9)! Wow, I haven't used a non GUI server for since college almost 15 years ago.. really brings back some old memories haha.
ok, I decided to use phpmyadmin b/c it was too much just command lining the thing.
I made a root password beforehand after installing MySQL.
(install phpmyadmin)
# aptitude install phpmyadmin
(note: phpmyadmin is installed in /usr/shared/phpmyadmin)
(make a symlink (symbolic link) to the web root folder: /var/www/)
# ln -s /usr/shared/phpmyadmin /var/www/phpmyadmin
(note: don't make a folder /var/www/phpmyadmin beforehand or the link will end up inside the folder. Also, you don't have to name it 'phpmyadmin')
there you go.. just point to the http://[yoursite.com]/phpmyadmin
ALSO, as far as permissions for database, make a separate user and give it these permissions:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER
according to drupal's tutorial:
http://drupal.org/getting-started/6/install/create-database
all privileges?
Certainly not "GRANT ALL PRIVILEGES".
Much better:
Right?