v Install: LAMP web server and Drupal 7 in Ubuntu ~ WebsiteSupport

March 13, 2011

Install: LAMP web server and Drupal 7 in Ubuntu

Installing a web server is very easy in Ubuntu (I use ubuntu10.10), just enter a few lines in the terminal: There is no need to install and configure each part of a LAMP (Linux-Apache-MySQL-PHP) installation individually. You can also install other programs this way. The downside is that all components are installed automatically, and not reviewed by you. But as long as you only use the web server locally (localhost or 127.0.0.1), and don't open up for access from the Internet, it should be safe.

Installing LAMP web Server

To install a LAMP web server, enter this command in a terminal and enter your password:
sudo tasksel install lamp-server

After a while the installation process will prompt you for a password for the MySQL server. Make sure that the CAPS Lock button is not activated! If all goes well, the installation will return to the terminal, and the web server is installed. Test this by going to your browser and enter http://localhost/ in the address bar. If the installation was successful, you will see an "It works!" message.


Update php.ini - allow big files, avoid memory issues

To allow importing large sql dumps through phpmyadmin, and avoiding time outs during demanding requests, it is also necessary to update the php.ini file of the Apache server. To open up the php.ini in gedit, enter this in your terminal:

gksudo gedit /etc/php5/apache2/php.ini

...and update the values five places, where it says:

max_execution_time = 120
max_input_time = 90
memory_limit = 96M
post_max_size = 150M
upload_max_filesize = 150M
session.gc_maxlifetime = 14400


Fix Apache Error "Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName"

Open the httpd.conf file:

sudo gedit /etc/apache2/httpd.conf

The httpd.conf file is blank, so add the following to the file, and then save it:

ServerName localhost
Create a MySQL database

To create a database in the MySQL database, log in to the MySQL shell:

mysql -u root -p

Create a database, for a Drupal installation in this example, type in the MySQL shell:

CREATE DATABASE drupal7;

and leave the shell:

quit

If you typed in the password(in this example, "ROOT") accidentally with caps lock on, this is how you change it to something safer. "root" is NOT recommended as password. From the terminal:

mysqladmin -u root -p'ROOT' password 'yournewpassword'
Install phpmyadmin

You can also create and administer your MySQL databases through phpmyadmin:

sudo apt-get install phpmyadmin

Administer your databases at http://localhost/phpmyadmin/
Install and enable mod_rewrite

Install mod_rewrite, to get nice URL's:

sudo a2enmod rewrite

Enable mod_rewrite:

gksudo gedit /etc/apache2/sites-available/default

...and change "AllowOverride None" to "AllowOverride All", around line 11:


Options Indexes FollowSymLinks MultiViews
AllowOverride All

Restart the Apache web server:

sudo /etc/init.d/apache2 restart

Installing Drupal 7
1. Start nautilus up with this command:

gksudo nautilus

...and navigate to the /var folder, right-click on the www folder, click 'Permissions' and set owner and group to your own user name. This will prevent problems with automatically created folders in the future.

2. Download and extract Drupal 7 from http://drupal.org/. Rename the folder to drupal7 and move it to /var/www/ where the web sites of the Apache web server reside. Result: /var/www/drupal7

3. Create the files folder, like this: /var/www/drupal7/sites/default/files. Right-click the 'files' folder, select 'Properties' -> 'Permissions' and under 'Others', set 'Folder Access' to 'Create and delete files'

4. Make a copy of the default.settings.php file in /var/www/drupal7/sites/default and rename it to settings.php. Right-click settings.php, select 'Properties' -> 'Permissions' and under 'Others', set 'Folder Access' to 'Create and delete files'

NOTE: Add an exception in Firefox, if you have disabled "Accept cookies from sites" and unblock the new site if you have a script blocker activated in your browser.

If all went well, you should now be able to enter http://localhost/drupal7 and install Drupal.

Setting up a virtual host


To set up a virtual host, allowing you to enter just http://drupal7/ in stead of http://localhost/drupal7/:

sudo gedit /etc/hosts

...and add:

127.0.0.1 drupal7

To define where the Apache web server should be looking for the files:

gksudo gedit /etc/apache2/httpd.conf

...and add:


DocumentRoot /var/www/drupal7
ServerName drupal7


As always, when you change the set up of the Apache server, restart it:

sudo /etc/init.d/apache2 restart

Move apache webroot from /var/www to your /home directory and move MySQL folder

For back up reasons and to have a more "normal" work flow when adding files to your web site, you can move the apache webroot from /var/www to /home/USERNAME/.www -- the .www folder will be hidden until you press Ctrl+H to unhide it:

gksudo gedit /etc/apache2/sites-available/default

Change DocumentRoot /var/www to DocumentRoot /home/USERNAME/.www

If you have set up a virtual host:

gksudo gedit /etc/apache2/httpd.conf

...and change to: DocumentRoot /home/USERNAME/.www
From http://gullele.wordpress.com/2010/08/27/changing-default-apache-webroot-in-ubuntu/

Likewise, to move MySQL from /var/lib/mysql to /home/USERNAME/.mysql follow this guide: http://ubuntuforums.org/showthread.php?t=897354
 
Install Drush

With Drush you can install modules and update Drupal from the command-line: http://drupal.org/project/drush

wget http://ftp.drupal.org/files/projects/drush-6.x-3.3.tar.gz
tar xvzf drush-6.x-3.3.tar.gz
sudo chmod 555 drush/drush
sudo chown -R root:root drush
sudo mv drush /usr/local/
sudo ln -s /usr/local/drush/drush /usr/local/bin/drush
sudo drush dl drush_make

If you get an "exec: 53: php: not found" error after running the last line ("sudo drush dl drush_make") you might have to install the PHP command line interface, with

sudo apt-get install php5-cli

Great work !! If there is any problem then do post the problems below. I will try to answer your problem.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes

HTML Hit Counter