How to Install a Web Server and More in Ubuntu Linux 07/26/11

I recently saw a comment on this blog, from Neville, where  he was having trouble getting FTP to operate as expected on his web server. Needless to say, this could be the result of several configuration issues. Suffice to say, I figured one thing I could do to help all of you reading this post, is simply to print out (below) the steps I took to install my last web dev/design Ubuntu box. Hopefully, there will be some goodies for most of you… I installed the following on Ubuntu 10.04.3 LTS.

Here’s what I did to get everything working (on an local web server that is NOT available to the public – To make it a public server, more security issues would have to be addressed):

I want to get some extra multimedia packages:

sudo wget –output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get –quiet update && sudo apt-get –yes –quiet –allow-unauthenticated install medibuntu-keyring && sudo apt-get –quiet update

For some reason, the above command did not install the mediabuntu key. When I updated aptitude, it threw some errors, and I noticed that Authentication tab in Software Sources (System >> Administration >> Software Sources) did not list Medibuntu as a trusted software provider.

sudo apt-get –force-yes install app-install-data-medibuntu apport-hooks-medibuntu

gpg –keyserver subkeys.pgp.net –recv 0C5A2783 && gpg –export –armor 0C5A2783 | sudo apt-key add -

sudo aptitude update

Install some packages and codecs:

sudo aptitude install w32codecs libavcodec-extra-52 mencoder mplayer mplayer-gui non-free-codecs aacgain gecko-mediaplayer

Get DVD playback working and some packages:

sudo aptitude install libdvdcss2 libdvdnav4 gxine libxine1-gnome libxine1-plugins libxine1-all-plugins vlc mozilla-plugin-vlc mplayer mplayer-gui

I like the ability to copy music off my CD’s:

sudo aptitude install sound-juicer

Also, RubyRipper:

sudo add-apt-repository ppa:aheck/ppa
sudo aptitude update
sudo aptitude install rubyripper
sudo aptitude install rubyripper-gtk

A package to enable modification of PDF files:

sudo add-apt-repository ppa:pdfmod-team/ppa
sudo aptitude update
sudo aptitude install pdfmod

A package for editing RAW images as well as a RAW converter and digital photo processing application:

sudo add-apt-repository ppa:rawtherapee/ppa
sudo aptitude update
sudo aptitude install rawtherapee

Get Skype:

sudo aptitude install skype

No video? Try this:

Install v4l2ucp and change the preview program with v4l2ucp to skype instead of mplayer. Start preview, Skype loads, and video works.

Get some more media related packages:

sudo aptitude install devede easytag phatch dia thoggen

sudo add-apt-repository ppa:stebbins/handbrake-snapshots
sudo aptitude update
sudo aptitude install handbrake-gtk

Some PDF related packages:

sudo aptitude install pdfshuffler pdfsam pdfchain pdfjam

Torrents:

sudo add-apt-repository ppa:transmissionbt/ppa
sudo aptitude update
sudo aptitude install transmission

Side note for those with printers:

To get printer available on the network: http://localhost:631
Go to the “Administration” tab, then select “Share printers connected to this system” and “Allow printing from the Internet”

Also… I like the ability to reprint old jobs:

sudo gedit /etc/cups/cupsd.conf

Now add this code:

#Save print jobs, but only save 100 of them
PreserveJobFiles Yes
MaxJobs 100

just underneath this code:

LogLevel warn
MaxLogSize 0
SystemGroup lpadmin
# Allow remote access
Port 631

Get some dev related packages:

sudo aptitude install build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev

sudo aptitude install quanta gmountiso httrack isomaster

sudo add-apt-repository ppa:kilian/trimage
sudo aptitude update
sudo aptitude install trimage

sudo add-apt-repository ppa:webupd8team/ubuntu-font-family
sudo aptitude update
sudo aptitude install ttf-ubuntu-font-family

Install another browser (Chrome) for front-end testing:

sudo add-apt-repository ppa:chromium-daily/ppa
sudo aptitude update
sudo aptitude install chromium-browser

Let’s get the WordPress Dev environment installed…

Let’s get ffmpeg related installs done:

sudo aptitude install flvtool2 yamdi

Install x264:

cd
git clone git://git.videolan.org/x264.git
cd x264
./configure
make
sudo checkinstall –pkgname=x264 –pkgversion “2:0.`grep X264_BUILD x264.h -m1 |
cut -d’ ‘ -f3`.`git rev-list HEAD | wc -l`+git`git rev-list HEAD -n 1 |
head -c 7`” –backup=no –default –deldoc=yes

Note: To uninstall:

dpkg -r x264

Install LAME:

sudo aptitude remove libmp3lame-dev
sudo aptitude install nasm
cd
wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz
tar xzvf lame-3.98.4.tar.gz
cd lame-3.98.4
./configure –enable-nasm –disable-shared
make
sudo checkinstall –pkgname=lame-ffmpeg –pkgversion=”3.98.4″ –backup=no –default
–deldoc=yes

Install libvpx (for VP8 video):

cd
git clone git://review.webmproject.org/libvpx.git
cd libvpx
./configure
make
sudo checkinstall –pkgname=libvpx –pkgversion=”`date +%Y%m%d%H%M`-git” –backup=no
–default –deldoc=yes

Install ffmpeg:

cd
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure –enable-gpl –enable-version3 –enable-nonfree –enable-postproc
–enable-libfaac –enable-libopencore-amrnb –enable-libopencore-amrwb
–enable-libtheora –enable-libvorbis –enable-libx264 –enable-libxvid
–enable-x11grab –enable-libmp3lame –enable-libvpx
make
sudo checkinstall –pkgname=ffmpeg –pkgversion “4:SVN-r`LANG=C svn info |
grep Revision | awk ‘{ print $NF }’`” –backup=no –default –deldoc=yes
hash x264 ffmpeg ffplay

Not: To uninstall:

dpkg -r ffmpeg

Finally, let’s install qt-faststart, so that H.264 video can start playing almost immediately:

cd ~/ffmpeg
make tools/qt-faststart
sudo checkinstall –pkgname=qt-faststart –pkgversion “4:SVN-r`svn info | grep Revision |
awk ‘{ print $NF }’`” –backup=no –default –deldoc=yes install -D -m755
tools/qt-faststart /usr/local/bin/qt-faststart

Note: To uninstall:

dpkg -r qt-faststart

We need MySQL for the databases:

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

Important: Don’t forget to keep a record of your MySQL root user password! If not, phpMyAdmin will not be able to login later!

One quick Firefox tweak. I prefer Firefox tabs to open at the end (like the used to). Here’s the fix:

Open Firefox
In the address bar type:

about:config

In the “Filter” textbox, type:

browser.tabs.insertRelatedAfterCurrent

Double click “browser.tabs.insertRelatedAfterCurrent” that you see under “Preference Name” so that the “Value” says “False”.

Sometimes it helps to be able to record any sound piped through your soundcard, cam, etc.:

sudo add-apt-repository ppa:osmoma/rec-applet
sudo aptitude update
sudo aptitude install rec-applet

Install the Apache web server:

sudo aptitude install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Let’s edit the hosts file, to make it a bit easier for the web server (Apache) to reliably determine the FQDN – So that it won’t use 127.0.0.1:

sudo gedit /etc/hosts

Here is what my hosts file now looks like:

127.0.0.1    localhost
127.0.1.1    asgard
192.168.1.107    asgard.localdomain

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Restart Apache:

sudo /etc/init.d/apache2 restart

Let’s get some of the plugins we’ll need (ffmpeg-php, for example):

sudo aptitude install libapache2-mod-php5 libapache2-mod-ruby libapache2-mod-python php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-ffmpeg php5-json php5-ps

Enable some mods:

sudo a2ensite defaut-ssl
sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod include

We’d like to enable the WebDAV feature:

sudo a2enmod dav_fs
sudo a2enmod dav

Restart Apache:

sudo /etc/init.d/apache2 restart

Let’s get an FTP server working:

sudo aptitude install proftpd ucf menu

Side note: I selected “standalone” for the proftpd installation.

Let’s edit our Apache config (because I noticed that overrides are not working):

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

Changed it to look like this:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory “/usr/lib/cgi-bin”>
AllowOverride all
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ “/usr/share/doc/”
<Directory “/usr/share/doc/”>
Options Indexes MultiViews FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Restart apache:

sudo /etc/init.d/apache2 restart

Warning message?

apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

Fix:

sudo gedit /etc/apache2/httpd.conf

The page will be empty, add this:

ServerName localhost

Restart Apache

sudo /etc/init.d/apache2 restart

Now to install phpMyAdmin:

sudo aptitude install phpmyadmin

(Obviously select “apache2″ as the server).

Don’t forget the password you selected!

Now we need to get the databases that were on the old system’s hard drive (only if you need to do something like this). First, make a backup of the current (clean) MySQL:

sudo cp -Rp /var/lib/mysql /home/roger/Downloads/backups-mysql/mysql.backup

Note: To restore…

sudo cp -Rp /home/roger/Downloads/backups-mysql/mysql.backup /var/lib/mysql

I previously zipped, uploaded to an FTP server, and then downloaded the archive to my desktop. Now I want to restore the unzipped databases:

sudo cp -Rp /home/roger/Desktop/MySQL/dirs/mysql /var/lib

Restart MySQl:

sudo /etc/init.d/mysql restart

Sometimes the import of WordPress content (xml files) is over 2MB. Let’s increase this limitation so that we can import larger file:

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

Find:

upload_max_filesize = 2M

and change to say:

upload_max_filesize = 20M

Save the edited file and restart Apache:

sudo /etc/init.d/apache2 restart

I often record screen activity so that clients can see how to do something, or learn about issues of value to them. In particular, it’s most beneficial to be able to use the desktop screen activity, the web cam and the microphone to better explain or demonstrate something. Here’s how I set this up:

sudo aptitude istanbul ubuntu-restricted-extras pavucontrol

sudo add-apt-repository ppa:webupd8team/gtk-recordmydesktop
sudo aptitude update
sudo aptitude install gtk-recordmydesktop

sudo aptitude install subtitleeditor

A simple GUI video converter:

sudo aptitude install winff

Note: RecordMyDesktop (Applications >> Sound & Video >> Desktop Recorder) will record in .ogv format. After installing ffmpeg, the conversion to flv becomes a simple command:

ffmpeg -i input_file.ogv -sameq output_file.flv

The above makes very large file sizes. To keep them smaller (and maintain a balance with quality, try the following command):

ffmpeg -i input_file.ogv -ab 256 -vb 400 output_file.flv

The -sameq flag instructs ffmpeg to keep the same quality as the original.

Enable the 3D editing:

sudo aptitude install blender

Need to edit title features in your OpenShot (installed after this) videos?

sudo aptitude install inkscape

Let’s get a simpler video editor:

sudo add-apt-repository ppa:jonoomph/openshot-edge
sudo aptitude update
sudo aptitude install openshot openshot-doc

Ability to transcode into other formats?

sudo aptitude install arista

Back to the server, let’s enable some remote administrative features:

sudo aptitude -y install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl apt-show-versions libapt-pkg-perl

libmd5-perl seems to be missing?

sudo apt-cache policy libmd5-perl reports the package cannot be found. We’ll have to get it from Debian.

I went to Debian’s FTP: http://ftp.debian.org/pool/main/libm/libmd5-perl/

so the command would be:

wget http://ftp.debian.org/pool/main/libm/libmd5-perl/libmd5-perl_2.03-1_all.deb

Now let’s install that package:

sudo dpkg -i libmd5-perl_2.03-1_all.deb

Let’s look for webmin verions:

http://sourceforge.net/projects/webadmin/files/

1.520 is the most recent as of this post. Therefore we should be able to get it via:

wget http://downloads.sourceforge.net/project/webadmin/webmin/1.520/webmin_1.520_all.deb

Now we can install the package:

sudo dpkg -i webmin_1.520_all.deb

Now access the interface via:

https://<domain_name>:10000/ or https://<ip_address>:10000/

Note: The usr and pwd will be the same as your current credentials.

I sometimes work with PHPmotion, and it (unfortunately) requires that phpshield be installed.

First, we need to learn and confirm some information:

PHP version.
Thread Safety should be disabled.
enable_dl should be on (by default it’s normally off).
The path to the extention directory.
The path to php.ini

You can download and use the following file: phpinfo.php.gz (Just extract the phpinfo/php file, upload it to your web server and then call it in a browser).

Here’s what mine looks like:

PHP version = 5.3.2
Thread Safety = Disabled
enable_dl = Off
Extention directory path = /usr/lib/php5/20090626+lfs
Path to php.ini = /etc/php5/apache2

I need to turn “enable_dl” on:

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

Find enable_dl Off

and change it to:

enable_dl On

Restart Apache:

sudo /etc/init.d/apache2 restart

Let’s use root credentials:

sudo su

cd /root

Create a directory to download the phpshield loaders:

mkdir phpshield
cd phpshield

From the URL http://phpshield.com/loaders/ I see that I need the Linux 32-bit version as: ixed4.lin.x86-32.zip

wget http://phpshield.com/loaders/ixed4.lin.x86-32.zip

unzip ixed4.lin.x86-32.zip

Several .lin files will be extracted and we need to copy them to our extension directrory.

the ls command showed me there is a version:

ixed.5.3ts.lin
ixed.5.3.lin

5.3 matches the installed 5.3 version of PHP.

cp ~/phpshield/ixed.5.3.lin /usr/lib/php5/20090626+lfs
cp ~/phpshield/ixed.5.3ts.lin /usr/lib/php5/20090626+lfs

We don’t need to be root anymore:

exit

Now we’ll add these extensions to the PHP configuration:

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

Under the section that says “Dynamic Extensions”, add the following:

extension=ixed.5.3.lin
extension=ixed.5.3ts.lin

Restart Apache:

sudo /etc/init.d/apache2 restart

The phpinfo.php file will now display something like the following:

SourceGuardian Loader Support     enabled
SourceGuardian Loader Version     8.2
SourceGuardian Loader Build Number     0×00000011
phpSHIELD Support     enabled

Some administrative features:

sudo aptitude install mysql-admin
sudo aptitude install phpmyadmin

Oops… FTP access is unable to upload files to/var/www. The fix:

sudo chown -R www-data:www-data /var/www

Ubuntu Dropbox user?

sudo apt-key adv –keyserver pgp.mit.edu –recv-keys 5044912E
sudo aptitude install nautilus-dropbox

Install VLC 1.1.2:
sudo add-apt-repository ppa:gnome-media-player-development/development
sudo aptitude update
sudo aptitude install vlc mozilla-plugin-vlc

Install VLMC:
sudo add-apt-repository ppa:falk-t-j/lucid-latest
sudo aptitude update
sudo aptitude install vlmc frei0r-plugins

Install GUVCview:

Online communications & chat:

sudo aptitude install xchat-gnome
sudo aptitude install telepathy-sofiasip telepathy-butterfly telepathy-idle libtelepathy-farsight0 python-tpfarsight

sudo add-apt-repository ppa:telepathy/ppa
sudo aptitude update
sudo apt-get dist-upgrade # I suppose “apt-get install empathy” works as well

For me at least, the above pretty much gets the job done. Have anything to add…? Feel free to voice your comments!

 

Update Aug. 14, 2011:

Install QRencode to create QR codes for mobile users:

sudo aptitude install qrencode


You can leave a response, or trackback from your own site.

4 Responses to this article

 
Neville Cox July 27, 2011 Reply

Thanks for your reply
I have had no problem installing Ubuntu server 11.04, I downloaded the ios burnt to cd and booted the pc from cd all ok, during the install i had the option to add software, so I added LAMP.
When install finnished I checked the ip address of the server (192.168.1.197) all ok then I set the root password with # sudo passwd root and entered in the password all ok.
Next get updated
So i entered in
# apt-get update all ok
# apt-get upgrade all ok
Next I installed Telnet
# apt-get install telnetd all ok
restarted server # shutdown -r now all ok
Switched to another Pc on the network and telneted to the server 192.168.1.197 ok
The next thing I did was to install proftpd
# apt-get install proftpd all ok
The next thing was to configure the shell file so that when I add users to the server they wont be able to telnet to the server, so I typed from root as SU # cd /etc
Then # vi shells
at the bottom of that file I added a line
/bin/false Saved it and exited vi
typed in # cat shells to check if the changes were saved, all ok
Next I added a web user
# cd /var/www
# mkdir bill
# Useradd bill –p “my root password” –d /var/www/bill –s /bin/false
# chown bill bill
# passwd bill
I was asked for password so I entered it in
the next thing was ti install Webmin
# wget http://www.webmin.com/download/deb/webmin-current.deb
Waited for that to finnish
# sudo dpkg -i webmin-current.deb
waited for that to finnish
got some errors but the next command fixed that
# sudo apt-get -f install
So i went to my browser and went to
http://192.168.1.197:10000 and loged with my root password XXXXXX all ok
next I installed Webalizer
# apt-get install webalizer all ok
I had to go in and make in the webalizer config file of whick would enable wealized to analyz apache web server log file, so I used vi to edit the webalizer config file by removing the “.1” from the end of the logfile entery.
Then I went to Webmin via https://192.168.1.197:10000 from an other Pc, the clicked on “Scheduled Cron Jobs”, then clicked “Creat A New Schedule Cron Job”, then choose to execute the job as root .
The commant toexecute is /usr/bin/webalizer, click on”times and Dates Selected below”, under the minutes select and chooes 0,15,30 and 45 for hours, days, months and weeknnds, select “all”
Thisi all seemed to be ok
Next I installed phpmyadmin
# sudo apt-get install phpmyadmin
When i was asked what web server I was using, Ichose apache2 all ok
So I was all done, it’s great every thing worked but I couldn’t connect to the server via ftp, so I could’t upload files to the web page.
So I started again a fresh install this time I installed VSFTPD inseted if PROFTPD, Great I now can connect but now I still can not load files, It seems that thers is no public_html folder.
How do I fix this?
Your post is good but it looses me, I’m only a newbee HELP!!!

 
 
UbuntuLinuxHelp July 27, 2011 Reply

@Neville

One of the things many (including myself) don’t do, is select LAMP. Why? Because it pre-installs a generic LAMP server. Instead, it’s better to install a base server and then add the LAMP components as per requirements. ;)

Better to use aptitude when possible (instead of apt-get). Better to install SSH instead of Telnet.

Better to add/change users AFTER you’ve installed and got things working. ;) Keeps things less complicated, this way when you have something working, make a change and things don’t work, then you can always go back a step to where everything was working.

If you cannot upload files, this means that vsftpd is not working as expected (you indicate it’s working?). Have you checked file/directory permissions (chmod)? Have you checked file/directory ownership (chown)?

When you change ownership of /var/www to ‘bill’, you knocked out the www-data, did you? :(

You’re correct, there is no “public_html”, instead the path is: /var/www/…

 
 
UbuntuLinuxHelp July 27, 2011

@neville

Also…

Question: Did you edit your /etc/hosts file? It’s hard to tell (I’m not sitting at your server), maybe your FTP app cannot find the server via the hostname you use>
Question: When you first installed proFTPD, did you: sudo aptitude install proftpd ucf menu? (Did you select “standalone”?)

I had a similar issue, I could not upload files to the web server (/var/www). I realized that I needed to change the ownership to the correct group www-data so: sudo chown -R www-data:www-data /var/www

 
Neville Cox July 29, 2011 Reply

What I have done now is start a hole new clean install, and yes I did install LAMP at the same time. So lets start with Lamp, so what I have done is uninstall LAMP folling an other tutorial and it seemed to work, so now I don’t have lamp.
So now what is the correct way ti install LAMP ?

When it comes to my FTP server I installed VSFTPD and I added users into var/www then I enabled public_html and I don’t know if I had done that the correct way, I think I did it also in the var/www directy like this.
# mkdir ~/public_public
Then I enabled the user directory
# ln -s ../mods-available/userdir.conf usredir.conf
# ln -s ../mods-available/userdir.load userdir.loda

Then restarted Apache
# /etc/init.d/apache2 restat

I must say I lost now

So as I said above New install with lamp but I have now uninstalled lamp, so if you can help me with this it would be great

Leave a Reply

close comment popup

Leave A Reply