How to Setup Ubuntu 12.10 Server with LAMP and SSH Access
By Shay Anderson on December 2012
In this article I include all the necessary steps for getting a Web (Apache) Server up and running on Ubuntu 12.10 with SSH access and Samba file server.
Installation
Install Ubuntu Server 12.10, during the install select to install OpenSSH, LAMP and Samba.
Add Root User
After installation I want to enable the root user by adding a password at command line: >> sudo passwd rootAfter the password is setup for root I can switch to the root user: >> su root
Setup Aliases
Next, I want to setup aliases that I use, so for that I edit the ‘/home/[user]/.bashrc’ file and add these lines by the other aliases: [...]
alias z=’ls -l’
alias zz=’ls -la’
alias a2r=’service apache2 restart’
alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
[...]The same steps can be used to setup the root user alias by editing the file ‘/root/.bashrc’ (must have root priviledges).
Setup Static IP
The next thing I want to do is setup a static IP address so I can access the server via SSH. So I edit the ‘/etc/network/interfaces’ file so it looks something like: auto eth0
iface eth0 inet static
address 192.168.1.110
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.1.1Save the file and restart networking with: >> service networking restartYou should be able to see your IP address with the command: >> ifconfigThis should display your new static IP address.
Now you should be able to connect to the server via the new static IP address and SSH.
Setup File Server
The next thing I want to do is enable file sharing on the new server. To do this I simply need to edit the Samba configuration file ‘/etc/samba/smb.conf’, first set the workgroup: workgroup = [your workgroup name]Then at the bottom of the file add your share directories, for example: [webserver]
comment = Linux Web Server
path = /var/www
browsable = yes
guest ok = yes
read only = no
create mask = 0755
force user = [user for share]
[svn]
comment = Subversion Repos
path = /home/svn
browsable = yes
guest ok = yes
read only = no
create mask 0755
force user = [user for share]Then restart the Samba service: >> service smbd restartYou should now be able to access your shared directories.
Downgrading PHP 5.4 to PHP 5.3
When I installed Ubuntu 12.10 I noticed that the it installed a version of PHP I didn’t want to use: >> php -v
PHP 5.4.6-1ubuntu1I want to use PHP 5.3, so first I need to check the packages that were included in the PHP 5.4 install: >> dpkg –list | grep php
ii libapache2-mod-php5 5.4.6-1ubuntu1 amd64 server-side, HTML-embedded scripting language (Apache 2 module)
ii php5-cli 5.4.6-1ubuntu1 amd64 command-line interpreter for the php5 scripting language
ii php5-common 5.4.6-1ubuntu1 amd64 Common files for packages built from the php5 source
ii php5-mysql 5.4.6-1ubuntu1 amd64 MySQL module for php5So I want to remove the PHP 5.4 packages: >> apt-get remove libapache2-mod-php5 php5-cli php5-common php5-mysqlThen run update: >> apt-get updateNext, create the file ‘/etc/apt/sources.list.d/precise.list’ and add these lines: # required for PHP 5.3
deb http://bg.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise main restricted
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe
deb http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://archive.canonical.com/ubuntu natty partner
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
deb http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partnerSave the file and re-run update: >> apt-get updateNow you can re-install PHP (5.3) using the precise list: >> apt-get -t precise install libapache2-mod-php5 php5-cli php5-common php5-mysqlVerify PHP version: >> php -v
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)PHP has been successfully downgraded to PHP 5.3. I also use the PHP GD Library and cURL PHP Library, so I also installed those: >> apt-get -t precise install php5-curl php5-gdThat will install both libraries.
Configure Apache Web Server
Next, edit the ‘/etc/apache2/apache2.conf’ file and at the bottom of the file add these lines: [...]
ServerName localhost
# turn off directory indexing
Options -Indexes
Include /var/www/www.httpd.confThen create the file ‘/var/www/www.httpd.conf’ file and you can now add virtual hosts like:
ServerName 0.0.0.0 # replace 0.0.0.0 with your server IP address
DocumentRoot /var/www
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName myexample.com
ServerAlias www.myexample.com
DocumentRoot /var/www/myexample.com
ErrorLog /var/log/www.myexample.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
>> a2enmod headersBecause I am using this server as a development server I want to display all PHP errors, warnings and notices – to do this I edit the ‘/etc/php5/apache2/php.ini’ file, and set these values: [...]
error_reporting = E_ALL | E_STRICT
[...]
display_errors = On
[...]
display_startup_errors = On
[...]
error_prepend_string = “
[...]
error_append_string = “
”
[...]Restart Apache:>> service apache2 restart
Setup MySQL Server
Next, I setup the MySQL server so that I can connect locally using the root user. First, edit the ‘/etc/mysql/my.cnf’ and comment out the bind-address so it looks like: [...]
;bind-address = 127.0.0.1
[...]Then we need to allow access for root, log into the MySQL server: >> mysql -h localhost -u root -pThen using MySQL command line run these commands: mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES(‘%’,’root’,PASSWORD(‘your-root-password’));
mysql> FLUSH PRIVILEGES;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quitNow restart MySQL: >> service mysql restartNow MySQL should be ready to use.
Install Subversion
I use subversion, so to install I use: >> apt-get install subversionYou can find how to Setup Subversion Server on Ubuntu 12.10 here.
Install Misc Packages
I also use the ‘tree -A’ command, so I install the tree package: >> apt-get install treeAlso, I install zip: >> apt-get install zip
http://www.shayanderson.com/linux/how-to-setup-ubuntu-1210-server-with-lamp-and-ssh-access.htm