![]() |
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 iface eth0 inet static address 192.168.0.240 netmask 255.255.255.0 gateway 192.168.0.1 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). This configuration assumes that you will be using mod_php to run PHP as an Apache module. This is suitable for most regular traffic sites. For a more high performance option for higher traffic sites, you may want to run Apache with PHP as fcgid. 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 and put the following lines in it: extension=apc.so apc.shm_size=40 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 creating a new file /etc/php5/conf.d/local.ini and put the following 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/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> 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 # a2dismod autoindex 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/ # wget http://ftp.osuosl.org/pub/drupal/files/projects/drupal-6.14.tar.gz Then extract the tarball # cd /var/www/ # tar xzf /tmp/drupal-6.14.tar.gz Move the files to the web root of the server # mv drupal-6.14/* /var/www And don't forget the hidden file ... # mv drupal-6.14/.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 all the Drupal files to be owned by something other than the user Apache runs as: www-data # chown -R root:root /var/www Then, create a files directory that is owned by the www-data user, so Drupal can write images, pictures and uploaded files there. Note that if you have a multi site install, you will need to create one files directory for each site, e.g. /var/www/sites/example.com/files: # mkdir /var/www/sites/default/files # chown -R www-data:www-data /var/www/sites/default/files Create the Drupal databaseThe following command will create a database for Drupal: # mysqladmin create db Then grant privileges to it: # mysql Then enter the following two lines at the MySQL prompt: GRANT ALL PRIVILEGES ON db.* TO user@localhost IDENTIFIED BY 'something'; FLUSH PRIVILEGES; 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 ... |



Error instaling APC
I get an error
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
ERROR: `phpize' failed
I'm trying this on my Virtual Box.
apc.shm_size now uses M/G suffixes
Just a little update to this.
apc.shm_size=40
Should be
apc.shm_size=40M
Or you get the M/G suffixes error.
Issues with drupal installation on Slicehost
I installed Drupal on Slicehost (1GB slice) and have an issue. The Drupal home page is not being displayed. I've posted this issue on slicehost and drupal forums but haven't had much luck in terms of response and so was searching on the web if someone has a similar issue, when I came across your post. I seem to have done exactly the same thing that you have mentioned except that I perfomed the Drupal install using aptitude instead of fetching the tar files and moving them to the var/www folder. Infact I have even created a vhost file with the following directives
DocumentRoot /usr/share/drupal6
DirectoryIndex index.php
Still no luck. Not sure what is wrong. I expected to see the Drupal homepage the moment I completed the Drupal install just like it happened on my local host. Any help would be appreciated.
Best regards
Sridhar
Thanks for this excellent
Thanks for this excellent write-up. I just got an ubuntu vps at slicehost for Drupal, and this was great help in getting APC running.
For a flexible multi-site setup, I'd recommend looking at the Drubuntu docs on groups.drupal.org
apc.shm_size
I am wondering; I have a small 256 slice at slicehost. What would be a good size for apc.shm? Guess I can make it too big?
Yes
Yes, you can make it too big. The default is 30MB, and that is sufficient in many cases. However, if you have many modules, and/or many sites that do NOT share the same code base (i.e. not a multi-site install), then 30MB may not be enough.
The best way is to use the apc.php that comes with APC, and see how your shared memory is used.
--
2bits -- Drupal consulting
mysql cache - add for performance
Great guide, it jogged my memory about something I needed to fix. Something I have found to be really important for speed is mysql query caching - and probably the single most effective speed fix out there for active sites.
Thanks again!
Todd
Systems and Development Team
InMotion Hosting, Inc.
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?
no. Drupal is not going to
no. Drupal is not going to work without 'lock' and 'create temporary tables' privileges. So 'grant all' is correct.
It's best to avoid using
It's best to avoid using GRANT ALL PRIVILEGES for security reasons. Note that the CREATE TEMPORARY TABLE and LOCK TABLES permissions are no longer required for Drupal 6 since Nov 2007: http://drupalcode.org/viewvc/drupal/drupal/INSTALL.mysql.txt?view=log&r1=1.10&pathrev=DRUPAL-6#rev1.10
Drupal no GUI
Please I need help, How can you configure a website without GUI? How can you use Drupal to set a website without GUI for it? Am I missing anything here? Or what?
please help
thanks
configuring Drupal from commandline? ...
...try drush. The drupal shell.