Difference between revisions of "Ubuntu Quick Guides"
From Teknologisk videncenter
Computerkim (talk | contribs) |
Computerkim (talk | contribs) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 26: | Line 26: | ||
<li>You can now mount it to a path<br /><br /> | <li>You can now mount it to a path<br /><br /> | ||
</ol> | </ol> | ||
− | + | [http://www.howtoforge.com/linux_lvm Read more} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 84: | Line 47: | ||
− | <h1>Install | + | <h1>Install openssh-server (cli remote control)</h1> |
<ol> | <ol> | ||
<li>Install openssh server<br /><code>sudo apt-get install openssh-server</code><br /><br /> | <li>Install openssh server<br /><code>sudo apt-get install openssh-server</code><br /><br /> | ||
Line 90: | Line 53: | ||
</ol> | </ol> | ||
+ | <h2>Create your own certificate</h2> | ||
+ | <ol> | ||
+ | <li>Generate keys for the Certificate Signing Request (CSR)<br /><code>openssl genrsa -des3 -out server.key 2048</code><br /><br /> | ||
+ | <li>Now create the insecure key, the one without a passphrase, and shuffle the key names<br /><code>openssl rsa -in server.key -out server.key.insecure<br />mv server.key server.key.secure<br />mv server.key.insecure server.key</code><br /><br /> | ||
+ | <li>Create the CSR<br /><code>openssl req -new -key server.key -out server.csr</code><br /><br /> | ||
+ | <li>Create the self-signed certificate<br /><code>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</code><br /><br /> | ||
+ | <li>Install the certificate<br /><code>sudo cp server.crt /etc/ssl/certs<br />sudo cp server.key /etc/ssl/private</code><br /><br /> | ||
+ | </ol> | ||
− | <h1> | + | <h1>Use static ip</h1> |
<ol> | <ol> | ||
<li>Enter the /etc/network/interfaces file<br /><code>sudo nano /etc/network/interfaces</code><br /><br /> | <li>Enter the /etc/network/interfaces file<br /><code>sudo nano /etc/network/interfaces</code><br /><br /> | ||
Line 103: | Line 74: | ||
</ol> | </ol> | ||
− | + | <h1>Use static DNS</h1> | |
+ | <ol> | ||
+ | <li>Enter the /etc/resolv.conf file<br /><code>sudo nano /etc/resolv.conf</code><br /><br /> | ||
+ | <li>Edit the domain, search and nameserver to suit your needs<br /><br />Examble:<br /><samp>domain tekkom.local<br />search tekkom.local<br />nameserver 172.16.4.66<br />nameserver 172.16.4.77</samp><br /><br /><br /> | ||
+ | <li>Restart networkworking and that's it<br /><code>sudo /etc/init.d/networking restart</code> | ||
+ | </ol> | ||
Line 110: | Line 86: | ||
<li>To update your server, run this command<br /><code>sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade</code><br /><br /> | <li>To update your server, run this command<br /><code>sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade</code><br /><br /> | ||
</ol> | </ol> | ||
+ | |||
+ | <h1>Install dns server</h1> | ||
+ | <ol> | ||
+ | <li>Install bind9<br /><code>sudo apt-get install bind9</code><br /><br /> | ||
+ | <li>That was all, you can see how to configure it on help.ubuntu.com | ||
+ | </ol> | ||
+ | |||
+ | <h1>Install mediawiki</h1> | ||
+ | <ol> | ||
+ | <li>Install apache2, mysql-server, php5, php5-mysql and mediawiki. Run this command and follow the instructions<br /><code>sudo apt-get install apache2 mysql-server php5 php5-mysql mediawiki</code><br /><br /> | ||
+ | <li>Enter the /etc/mediawiki/apache.conf file<br /><code>sudo nano /etc/mediawiki/apache.conf</code><br /><br /> | ||
+ | <li>remove <kbd>#</kbd> from the line <kbd>#Alias /mediawiki /var/lib/mediawiki</kbd><br /><br /> | ||
+ | <li>Save and exit<br /><br /> | ||
+ | <li>Restart apache2<br /><code>sudo /etc/init.d/apache2 restart</code><br /><br /> | ||
+ | <li>go to http://<strong><server address></strong>/mediawiki and run the configuration<br /><br /> | ||
+ | <li>Rename the old configuration<br /><code>sudo mv /var/lib/mediawiki/LocalSettings.php /var/lib/mediawiki/LocalSettings.php.backup</code><br /><br /> | ||
+ | <li>Insert the new configuration<br /><code>sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php</code><br /><br /> | ||
+ | <li>You can now access your new mediawiki webpage by going to http://<strong><server address></strong>/mediawiki | ||
+ | </ol> | ||
+ | |||
+ | |||
+ | |||
Line 133: | Line 131: | ||
</ol> | </ol> | ||
+ | |||
+ | <h2>Enable https</h2> | ||
+ | <ol> | ||
+ | <li>Enable https<br /><code>sudo a2enmod ssl</code><br /><br /> | ||
+ | <li>Use default certificate<br /><code>sudo a2ensite default-ssl</code><br /><br /> | ||
+ | <li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br /> | ||
+ | <li>Https should now be enabled on your server. | ||
+ | </ol> | ||
− | < | + | <h3>Using your own certificate</h3> |
− | |||
<ol> | <ol> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
<li>Now we have to edit the https site to use your certificate, enter the https site.<br /><code>sudo nano /etc/apache2/sites-available/default-ssl</code><br /><br /> | <li>Now we have to edit the https site to use your certificate, enter the https site.<br /><code>sudo nano /etc/apache2/sites-available/default-ssl</code><br /><br /> | ||
<li>Change the following<br/>SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem<br />SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key<br />to<br />SSLCertificateFile /etc/ssl/certs/server.crt<br />SSLCertificateKeyFile /etc/ssl/private/server.key<br /><br /> | <li>Change the following<br/>SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem<br />SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key<br />to<br />SSLCertificateFile /etc/ssl/certs/server.crt<br />SSLCertificateKeyFile /etc/ssl/private/server.key<br /><br /> | ||
Line 149: | Line 149: | ||
<li>Your server should now use the certificate you have created. | <li>Your server should now use the certificate you have created. | ||
</ol> | </ol> | ||
+ | |||
+ | <h2>Make you http site redirect to your https site</h2> | ||
+ | <ol> | ||
+ | <li>Enter your site file<br /><code>sudo nano /etc/apache2/sites-available/default</code><br /><br /> | ||
+ | <li>Under the line<br /><VirtualHost *:80><br />insert the line<br />Redirect permanent / https://<server address>/<br /><br /> | ||
+ | <li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br /> | ||
+ | <li>Http requests should now be redirected to https | ||
+ | </ol> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <h2>Install php</h2> | ||
+ | <ol> | ||
+ | <li>Install php<br /><code>sudo apt-get install php5</code><br /><br /> | ||
+ | <li>PHP should now be installed. | ||
+ | </ol> | ||
+ | |||
+ | |||
+ | <h3>Install phpmyadmin</h3> | ||
+ | <ol> | ||
+ | <li>Install phpmyadmin<br /><code>sudo apt-get install phpmyadmin</code><br /><br /> | ||
+ | <li>You can now access phpmyadmin via http://<server address>/phpmyadmin | ||
+ | </ol> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <h1>Enable forwarding</h1> | ||
+ | <ol> | ||
+ | <li>Enter the /etc/sysctl.conf file<br /><code>sudo nano /etc/sysctl.conf</code><br /><br /> | ||
+ | <li>Remove the <kbd>#</kbd> from the line <kbd>#net.ipv4.ip_forward = 1</kbd><br /><br /> | ||
+ | <li>Save and exit<br /><br /> | ||
+ | <li>Activate<br /><code>sudo sysctl -p /etc/sysctl.conf</code> | ||
+ | </ol> | ||
+ | |||
Latest revision as of 12:04, 3 May 2012
Contents
- 1 Formating/mounting a new harddisk
- 2 LVM
- 3 Install samba file server (create network shares)
- 4 Install openssh-server (cli remote control)
- 5 Use static ip
- 6 Use static DNS
- 7 Update ubuntu
- 8 Install dns server
- 9 Install mediawiki
- 10 Install wordpress
- 11 Install apache (web server)
- 12 Enable forwarding
- 13 Common commands
Formating/mounting a new harddisk
- Find your harddisk
ls /dev/
Note: sd<letter> is harddisks, and sd<letter><number> is partitions.
- Enter your disk with fdisk
sudo fdisk /dev/sd<letter>
- Create your partitions
usem
for helpn
to create a partitionst
to change partition type
- When you have created your partition, exit with
w
to save and exit
- Format the new partition
mkfs -t <filesystem, eg. ext4> <device, eg. /dev/sdb1>
- Get the uuid of your partition
ls -l /dev/disk/by-uuid
- Add uuid and insert the path where to mount in /etc/fstab
sudo nano /etc/fstab
Examble:
UUID=2687047d-f506-40f0-8823-d753c1ef34cd /data ext4
- Mount the partitions
mount -a
LVM
- Install LVM2
sudo apt-get install lvm2
- Create at least 2 Linux LVM (8e) partitions with fdisk
- Create the LVM partitions
pvcreate <partition 1> <partition 2>
Note: more partitions can be added -pvcreate <partition 1> <partition 2> <partition 3>
- Create a volume group for the partitions
vgcreate <name> <partition 1> <partition 2>
- Create a logical volume for the volume group
lvcreate --name <name> --size <size, eg. 10G or 20M> <volume group name>
- Format the volume with a filesystem
mkfs -t <filesystem, eg. ext4> /dev/<volume group name>/<logical volume name>
- You can now mount it to a path
[http://www.howtoforge.com/linux_lvm Read more}
Install samba file server (create network shares)
- Install samba
sudo apt-get install samba
- Enter the sudo nano /etc/samba/smb.conf file
sudo nano /etc/samba/smb.conf
- Browse to the bottom and create a share
Example:
[Share]
comment = Guest access share
path = /path/to/dir/to/share
browseable = yes
read only = yes
guest ok = yes
- Save and exit
- Reload samba
sudo /etc/init.d/samba reload
Making shares open
- Enter the sudo nano /etc/samba/smb.conf file
sudo nano /etc/samba/smb.conf
- Find the line security = guest and replace it with security = share
- Save and exit
- Reload samba
sudo /etc/init.d/samba reload
Install openssh-server (cli remote control)
- Install openssh server
sudo apt-get install openssh-server
- You can now access your server via ssh (with eg. putty)
Create your own certificate
- Generate keys for the Certificate Signing Request (CSR)
openssl genrsa -des3 -out server.key 2048
- Now create the insecure key, the one without a passphrase, and shuffle the key names
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key
- Create the CSR
openssl req -new -key server.key -out server.csr
- Create the self-signed certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
- Install the certificate
sudo cp server.crt /etc/ssl/certs
sudo cp server.key /etc/ssl/private
Use static ip
- Enter the /etc/network/interfaces file
sudo nano /etc/network/interfaces
- Change iface eth0 inet dhcp to iface eth0 inet static
- Write your address, netmask and gateway
Example:
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
- Restart networkworking and that's it
sudo /etc/init.d/networking restart
Use static DNS
- Enter the /etc/resolv.conf file
sudo nano /etc/resolv.conf
- Edit the domain, search and nameserver to suit your needs
Examble:
domain tekkom.local
search tekkom.local
nameserver 172.16.4.66
nameserver 172.16.4.77
- Restart networkworking and that's it
sudo /etc/init.d/networking restart
Update ubuntu
- To update your server, run this command
sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade
Install dns server
- Install bind9
sudo apt-get install bind9
- That was all, you can see how to configure it on help.ubuntu.com
Install mediawiki
- Install apache2, mysql-server, php5, php5-mysql and mediawiki. Run this command and follow the instructions
sudo apt-get install apache2 mysql-server php5 php5-mysql mediawiki
- Enter the /etc/mediawiki/apache.conf file
sudo nano /etc/mediawiki/apache.conf
- remove # from the line #Alias /mediawiki /var/lib/mediawiki
- Save and exit
- Restart apache2
sudo /etc/init.d/apache2 restart
- go to http://<server address>/mediawiki and run the configuration
- Rename the old configuration
sudo mv /var/lib/mediawiki/LocalSettings.php /var/lib/mediawiki/LocalSettings.php.backup
- Insert the new configuration
sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php
- You can now access your new mediawiki webpage by going to http://<server address>/mediawiki
Install wordpress
- To install wordpress. Run this command and follow the instructions
sudo apt-get install apache2 mysql-server php5 php5-gd php5-mysql wordpress
- Make a symbolic link so that Apache2 knows where to find the installation folder
sudo ln -s /usr/share/wordpress /var/www/wordpress
- Then install WordPress using the supplied script
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost
- Add the line the line ServerName localhost to the file /etc/apache2/httpd.conf
sudo nano /etc/apache2/httpd.conf
- Restart apache
sudo /etc/init.d/apache2 restart
- Change the permissions of the wordpress folder
sudo chmod -R 777 /var/www/wordpress
- Delete the wordpress configuration file
sudo rm /var/www/wordpress/wp-config.php
- Run the wordpress configuration, open a webbrowser and go to http://<server address>/wordpress/wp-admin/install.php
Note: mysql user should be root
- You can now access your new wordpress webpage by going to http://<server address>/wordpress
Install apache (web server)
- To install apache2 run this command
sudo apt-get install apache2
- That's it! You can now create your webpage in the /var/www folder
Enable https
- Enable https
sudo a2enmod ssl
- Use default certificate
sudo a2ensite default-ssl
- Restart apache
sudo service apache2 restart
- Https should now be enabled on your server.
Using your own certificate
- Now we have to edit the https site to use your certificate, enter the https site.
sudo nano /etc/apache2/sites-available/default-ssl
- Change the following
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
to
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
- Save the changes
- Restart apache
sudo service apache2 restart
- Your server should now use the certificate you have created.
Make you http site redirect to your https site
- Enter your site file
sudo nano /etc/apache2/sites-available/default
- Under the line
<VirtualHost *:80>
insert the line
Redirect permanent / https://<server address>/
- Restart apache
sudo service apache2 restart
- Http requests should now be redirected to https
Install php
- Install php
sudo apt-get install php5
- PHP should now be installed.
Install phpmyadmin
- Install phpmyadmin
sudo apt-get install phpmyadmin
- You can now access phpmyadmin via http://<server address>/phpmyadmin
Enable forwarding
- Enter the /etc/sysctl.conf file
sudo nano /etc/sysctl.conf
- Remove the # from the line #net.ipv4.ip_forward = 1
- Save and exit
- Activate
sudo sysctl -p /etc/sysctl.conf
Common commands
sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade
Used to update ubuntu
sudo
Used to run commands as root
ls
Used to show files and folders in a directory
mkdir
Used to make a directory
cd
Used to change the directory you're working in
cp
Used to copy files/directories
rm
Used to delete files/directories
mv
Used to move/rename files/directories
locate
Used to find files/directories
adduser
Used to create a user
userdel
Used to delete a user
usermod
Used to modify a user
groupadd
Used to create a group
addgroup
Used to create a group
groupdel
Used to delete a group
delgroup
Used to delete a group
groupmod
Used to modify a group
chmod
Used to change permissions of a file/directory
chgrp
Used to change the group of a file/directory
chown
Used to change the owner of a file/directory
fdisk
Used to create partitions on a disk
mount
Used to mount partitions
blkid
Used to show where partitions are mounted
mkfs
Used to format a partition
vi
Text editor
nano
Text editor
ifconfig
Used to show interface configuration
man
Used to show the manual of a command