Ubuntu:Edgy ja/Servers

From

Contents

サーバ

Ubuntu Edgy LAMP Server

  • Ubuntu Edgy LAMP Server Installation with Screenshots Simple Step by Step Installation Guide for Ubuntu Users

アンチウィルスサーバ

ClamAV AntiVirus Server をインストールするには

sudo clamscan -r /location_of_files_or_folders

How to automatically scan files/folders for viruses

e.g. Automatically scan files/folders for viruses at midnight everyday
* * * * * means minute hour date month year
 export EDITOR=gedit &&  sudo crontab -e


*Append the following line at the end of file


00 00 * * *  sudo clamscan -r /location_of_files_or_folders
  • Save the edited file

Monitoring Server

If you want to monitor your Ubuntu servers and clients like memory usage,CPU usage,Load average,Disk usage,Mysql monitoring, Network Monitoring,Processes Monitoring this is for you Monitor your Ubuntu Servers and Clients using Munin

プリントサーバ(cupsd)

cupsdをインストールするには

cupsdは通常インストール時に自動的にインストールされるはずです。"/etc/init.d/cupsys"というファイルがあるか点検してください。手動でインストールしたい場合は、以下を実行します。
 sudo apt-get install cupsys*

How to add a printer

  • Go to System -> Administration -> Printing.
  • Choose "Add printer".
  • "Add printer wizard" should start and tell you what to do.

How to print on remote Ubuntu machine from another Ubuntu machine

  • Make sure your local printer is well configured.
  • Enable local printer sharing - System -> Administration -> Printing -> Global Settings menu -> Share printers
  • Server ip address: 192.168.0.1
  • Client ip address: 192.168.0.23
  • Server configuration
 sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.backup
 gksudo gedit /etc/cups/cupsd.conf
find the block
<Location />
  ...
  Allow localhost
  ...
</Location>
and add the following line into it.
 Allow 192.168.0.23
Restart cups.
 sudo /etc/init.d/cupsys restart
  • Client configuration
 sudo cp /etc/cups/client.conf /etc/cups/client.conf.backup
 gksudo gedit /etc/cups/client.conf
And add the following line into it.
 ServerName 192.168.0.1
Restart cups.
 sudo /etc/init.d/cupsys restart
Now try "lpq" and you should see something like
 vitek@lightfox:~$ lpq
 HPLJ6P is ready
 no entries

WindowsマシンからリモートのUbuntuマシンで印刷するには

Sambaサーバ

ファイル/フォルダ共有サービスのためにSambaサーバをインストールするには

sudo apt-get install samba smbfs

ネットワークユーザを追加/編集/削除するには

sudo smbpasswd -a system_username
gksudo gedit /etc/samba/smbusers
  • 以下を新しいファイルに書き込んでください。
system_username = "network username"
  • 編集したファイルを保存してください。

ネットワークユーザを編集するには

sudo smbpasswd -a system_username
  • ネットワークユーザを削除するには
sudo smbpasswd -x system_username

認証を有効にして、ホームフォルダを読み込み専用で共有するには

sudo cp /etc/samba/smb.conf /etc/Samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = user
  username map = /etc/samba/smbusers
sudo testparm
sudo /etc/init.d/samba restart

認証を有効にして、ホームフォルダを読み書きできるように共有するには

sudo cp /etc/samba/smb.conf /etc/Samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = user
  username map = /etc/samba/smbusers
  • このセクションを見つけてください。
...
# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
  writable = no
...
  • 以下と置き換えてください。
# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
  writable = yes
sudo testparm
sudo /etc/init.d/samba restart

認証を有効にして、グループフォルダを読み込み専用で共有するには

sudo mkdir /home/group
sudo chmod 777 /home/group/
sudo cp /etc/samba/smb.conf /etc/Samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
 security = user
 username map = /etc/samba/smbusers
  • 以下をファイルの最後に追加してください。
[Group]
  comment = Group Folder
  path = /home/group
  public = yes
  writable = no
  valid users = system_username1 system_username2
  create mask = 0700
  directory mask = 0700
  force user = nobody
  force group = nogroup
sudo testparm
sudo /etc/init.d/samba restart

認証を有効にして、グループフォルダを読み書きできるように共有するには

sudo mkdir /home/group
sudo chmod 777 /home/group/
sudo cp /etc/samba/smb.conf /etc/Samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = user
  username map = /etc/samba/smbusers
  • 以下をファイルの最後に追加してください。
[Group]
  comment = Group Folder
  path = /home/group
  public = yes
  writable = yes
  valid users = system_username1 system_username2
  create mask = 0700
  directory mask = 0700
  force user = nobody
  force group = nogroup
sudo testparm
sudo /etc/init.d/samba restart

認証を有効にして、パブリックフォルダを読み込み専用で共有するには

sudo mkdir /home/public
sudo chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = user
  username map = /etc/samba/smbusers
  • 以下をファイルの最後に追加してください。
[public]
  comment = Public Folder
  path = /home/public
  public = yes
  writable = no
  create mask = 0777
  directory mask = 0777
  force user = nobody
  force group = nogroup
sudo testparm
sudo /etc/init.d/samba restart

認証を有効にして、パブリックフォルダを読み書きできるように共有するには

sudo mkdir /home/public
sudo chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = user
  username map = /etc/samba/smbusers
  • 以下をファイルの最後に追加してください。
[public]
  comment = Public Folder
  path = /home/public
  public = yes
  writable = yes
  create mask = 0777
  directory mask = 0777
  force user = nobody
  force group = nogroup
sudo testparm
sudo /etc/init.d/samba restart

認証を無効にして、パブリックフォルダを読み込み専用で共有するには

sudo mkdir /home/public
sudo chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = share
  • 以下をファイルの最後に追加してください。
[public]
  comment = Public Folder
  path = /home/public
  public = yes
  writable = no
  create mask = 0777
  directory mask = 0777
  force user = nobody
  force group = nogroup
  • 編集したファイルを保存してください。
sudo testparm
sudo /etc/init.d/samba restart

認証を無効にして、パブリックフォルダを読み書きできるように共有するには

sudo mkdir /home/public
sudo chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • 以下の行を探してください。
...
;  security = user
...
  • 以下と置き換えてください。
  security = share
  • 以下をファイルの最後に追加してください。
[public]
  comment = Public Folder
  path = /home/public
  public = yes
  writable = yes
  create mask = 0777
  directory mask = 0777
  force user = nobody
  force group = nogroup
  • 編集したファイルを保存してください。
sudo testparm
sudo /etc/init.d/samba restart

Samba経由でリモートのUbuntuマシンで印刷するには

  • #プリントサーバ(cupsd)を読んでください。
  • Ubuntuのプリンタが適切に設定されていることを確認してください。
 sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
 gedit /etc/samba/smb.conf
以下の行を見つけます。
 ...
 # printing = cups
 # printcap name = cups
 ...
この部分のコメントを外します。
 printing = cups
 printcap name = cups
cupsサーバを再起動します。
 sudo /etc/init.d/cupsys restart
これでUbuntuマシンで稼働するプリンタがSamba経由でアクセスできるはずです。

Samba Web Administration Tool (SWAT)

INETD Superserver をインストールするには

 sudo apt-get install netkit-inetd

SWAT for Samba daemon をインストールするには

 sudo apt-get install swat
  • Open inetd daemon configuration
 sudo gksu gedit /etc/inetd.conf
  • If string is:
 <#off#> swat            stream  tcp     nowait.400      root    /usr/sbin/tcpd  /usr/sbin/swat
  • Change to:
 swat            stream  tcp     nowait.400      root    /usr/sbin/tcpd  /usr/sbin/swat
  • Restart daemon
 sudo /etc/init.d/inetd restart
  • http://localhost:901/

SSHサーバ

リモート管理サービスのためにSSHサーバをインストールするには

sudo apt-get install ssh

リモートのUbuntuマシンにSSHで接続するには

例: リモートのUbuntuマシンにSSHサーバサービスがインストールされているとします。
#リモート管理サービスのためにSSHサーバをインストールするにはを参照してください。
リモートのUbuntuマシン: 192.168.0.1

ssh username@192.168.0.1

リモートのUbuntuマシンから、ローカルのマシンにファイル/フォルダをコピーするにはどうすればいいですか(scp)?

例: リモートUbuntuマシンにはSSHサーバサービスがインストールされているとします。
#SSHサーバをリモート管理サービスのためにインストールするにはを参照してください。
リモートのUbuntuマシン: 192.168.0.1
リモートのファイル/フォルダの場所: /home/username/remotefile.txt
ローカルマシンでの保存場所: . (カレントディレクトリ)
scp -r username@192.168.0.1:/home/username/remotefile.txt .

ローカルのマシンから、リモートのUbuntuマシンにファイル/フォルダをコピーするにはどうすればいいですか(scp)?

*例: リモートUbuntuマシンにはSSHサーバサービスがインストールされているとします。
#SSHサーバをリモート管理サービスのためにインストールするにはを参照してください。
ローカルのファイル/フォルダの場所: localfile.txt
リモートUbuntuマシン: 192.168.0.1
リモートUbuntuマシンでの保存場所: /home/usrname/
scp -r localfile.txt username@192.168.0.1:/home/username/

リモートのUbuntuマシンから、自分のマシンにファイル/フォルダをコピーするにはどうすればいいですか(rsync)?

*例: リモートUbuntuマシンにはSSHサーバサービスがインストールされているとします。
#SSHサーバをリモート管理サービスのためにインストールするにはを参照してください。
リモートUbuntuマシン: 192.168.0.1
リモートのファイル/フォルダの場所: /home/username/remotefile.txt
ローカルマシンでの保存場所: . (カレントディレクトリ)
rsync -v -u -a --delete --rsh=ssh --stats username@192.168.0.1:/home/username/remotefile.txt .

自分のマシンから、リモートのUbuntuマシンにファイル/フォルダをコピーするにはどうすればいいですか(rsync)?

*例: リモートUbuntuマシンにはSSHサーバサービスがインストールされているとします。
#SSHサーバをリモート管理サービスのためにインストールするにはを参照してください。
ローカルのファイル/フォルダの場所: localfile.txt
リモートUbuntuマシン: 192.168.0.1
リモートUbuntuマシンの保存場所: /home/username/
rsync -v -u -a --delete --rsh=ssh --stats localfile.txt username@192.168.0.1:/home/username/

How to mount remote folders into local Ubuntu machine (sshfs)

e.g. Assumed that remote machine has installed SSH Server service
#How to install SSH Server for remote administration service を読んでください。
Remote machine: 192.168.0.1
Remote machine folder location: /media/music
  • Install sshfs
sudo apt-get install sshfs
  • Load kernel driver for sshfs
sudo modprobe fuse
  • Join the 'fuse' user group
sudo adduser your_user_name fuse
  • Logout and login for this to take effect.
  • Create local mountpoint in your home directory
mkdir ~/remote_music
  • Mount the remote folder into ~/remote_music
sshfs 192.168.0.1:/media/music ~/remote_music

Windowsマシンから、リモートのUbuntuマシンにSSHで接続するには

例: リモートUbuntuサーバにはSSHサーバサービスがインストール済みであるとします。
#リモート管理サービスのためにSSHサーバをインストールするにはを読んでください。

WindowsマシンとリモートのUbuntuマシンの間でファイルやフォルダをコピーするにはどうしたらいいですか?

例: リモートUbuntuサーバにはSSHサーバサービスがインストール済みであるとします。
#リモート管理サービスのためにSSHサーバをインストールするにはどいうすればいいですか?を読んでください。
  • FileZillaをここからダウンロードしてください。

リモートからSSH接続できるユーザアカウントを制限するには

例: SSHサーバを利用可能にすると、有効なアカウントを持つすべてのユーザがリモートから接続可能になります。
これはセキュリティリスクを招く恐れがあります。なぜなら、ありふれたユーザ名とパスワードの組み合わせを試すことで、リモートパスワードを不正奪取するツールが存在するからです。
  • SSHサーバの設定ファイルのバックアップをとります。

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIGINAL

  • 設定ファイルを編集します。

gksudo gedit /etc/ssh/sshd_config

  • パラメータのPermitRootLoginyesからnoへ変更します。スーパーユーザがリモートから直接接続できてはいけません。
  • Add the parameter AllowUsersというパラメータを追加し、リモート接続可能なユーザ名を(スペースで区切って)指定します。
  • DenyUsersを用いて、ユーザをきめ細かく選別することも可能です。
  • opensshサーバを有効にしつつ、今のところリモート接続を許可したくない場合、AllowUsers nosuchuserhereを追加して、誰も接続できなくすることもできます。

Using SSH to Port Forward

e.g. Assumed that remote machine has installed SSH Server service
#How to install SSH Server for remote administration service を読んでください。

If is possible to create secure SSH tunnels between multiple sites. Imagine two sites (home and office). If you have an SSH server available in the office available via the Internet, you can tunnel across to this server and communicate with any local PC in the office from home.

  • Example: Make Port 80 (Web Server) on 10.0.2.10 in the office available locally on Port 81

From home:

ssh -L 81:10.0.2.10:80 user@office.net

Once logged in, you can now browse to http://localhost:81 which is really a secure tunnel to the web server in your office. You can setup multiple port forwardings.

ssh -L 81:10.0.2.10:80 -L 82:10.0.2.20:80 -L 83:10.0.2.30:80 user@office.net

Now, port 81 locally forwards to port 80 on 10.0.2.10, port 82 forwards to port 80 on 10.0.2.20 and port 83 forwards to port 80 on 10.0.2.30 For example, http://localhost:81 connects you to port 80 on 10.0.2.10 (computer at remote location) Specify port with -p?? if SSH Server on office.net does not run on default port 22. Explanation:

ssh -L <local port>:<remote computer>:<remote port> <user>@<remote ip>

DHCPサーバ

IPアドレスを自動的に割り振るためにDHCPサーバをインストールするには

例:"eth0"がネットワークカードのインターフェースとします。
IPアドレスレンジ: 192.168.0.100 to 192.168.0.200
サブネットマスク: 255.255.255.0
DNSサーバ: 202.188.0.133, 202.188.1.5
ドメイン: tm.net.my
ゲートウェイアドレス: 192.168.0.1
sudo apt-get install dhcp3-server
sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup
gksudo gedit /etc/default/dhcp3-server
  • 以下の行を探してください。
...
INTERFACES=""
  • 以下と置き換えてください。
INTERFACES="eth0"
  • 編集したファイルを保存してください。
sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup
gksudo gedit /etc/dhcp3/dhcpd.conf
  • このセクションを見つけてください。
...
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;


default-lease-time 600;
max-lease-time 7200;
...
  • 以下と置き換えてください。
# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;


#default-lease-time 600;
#max-lease-time 7200;
  • このセクションを見つけてください。
...
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
...
  • 以下と置き換えてください。
# A slightly different configuration for an internal subnet.
subnet 192.168.0.0 netmask 255.255.255.0 {
 range 192.168.0.100 192.168.0.200;
 option domain-name-servers 202.188.0.133, 202.188.1.5;
 option domain-name "tm.net.my";
 option routers 192.168.0.1;
 option broadcast-address 192.168.0.255;
 default-lease-time 600;
 max-lease-time 7200;
}
  • 編集したファイルを保存してください。
sudo /etc/init.d/dhcp3-server restart

データベースサーバ

MYSQL Database Server をインストールするには

sudo apt-get install mysql-server
  • MySQL initially only allows connections from the localhost (127.0.0.1). We'll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf
gksudo gedit /etc/mysql/my.cnf
  • Find the line bind-address = 127.0.0.1 and comment it out
...
#bind-address           = 127.0.0.1
...
  • MySQL comes with no root password as default. This is a huge security risk. You'll need to set one. So that the local computer gets root access as well, you'll need to set a password for that too. The local-machine-name is the name of the computer you're working on. For more information see here
mysqladmin -u root password your-new-password
mysqladmin -h root@local-machine-name -u root -p password your-new-password
sudo /etc/init.d/mysql restart

MySQL Database backup using AutoMySQLBackup

  • #全体に共通する注意事項 を読んでください。
  • #拡張リポジトリを追加するには を読んでください。
  • #How to install MYSQL Database Server を読んでください。
  • AutoMySQLBackup is a script to take daily, weekly and monthly backups of your MySQL databases using mysqldump.
  • AutoMySQLBackup Script Features
    • Backup mutiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperately)
    • Backup all databases to a single backup file or to a seperate directory and file for each database.
    • Automatically compress the backup files to save disk space using either gzip or bzip2 compression.
    • Can backup remote MySQL servers to a central server.
    • Runs automatically using cron or can be run manually.
    • Can e-mail the backup log to any specified e-mail address instead of “root”. (Great for hosted websites and databases).
    • Can email the compressed database backup files to the specified email address.
    • Can specify maximun size backup to email.
    • Can be set to run PRE and POST backup commands.
    • Choose which day of the week to run weekly backups.
  • Download from here
  • AutoMySQLBackup Requirements

The AutoMySQLBackup script only requires mysqldump (A standard utility provided with the mysql client) and gzip or bzip2 for compression of the backup files. If you would like to have the log emailed to you then you will need to have permission to execute the “mail” program. If you want the compressed backup files mailed to you then Mutt must be available on the server. Finally you will need a bash shell and the standard system tools and utilities (all these requirements should be the default on most linux system.)

  • What AutoMySQLBackup does

Every day AutoMySQLBackup will run (if setup in /etc/cron.daily) and using mysqldump and gzip will dump your specified databases to the /backups/daily directory, it will rotate daily backups weekly so you should never have more than 7 backups in there.. Every Saturday AutoMySQLBackup will again backup the databases you have chosen but they will be placed into /backups/weekly, these will be rotated every 5 weeks so there should never be more than 5 backups in there.. Every 1st of the month AutoMySQLBackup will create a backup of all databases and place them into /backups/monthly. These will never be rotated so it will be up to you to do your own house keeping. I would suggest taking a copy of this offline every month or two so that if you have a hard drive failure you will be able to restore your database

  • AutoMySQLBackup Installation

The install is as simple as editing a few variables in the AutoMySQLBackup file. The full setup is documented in the AutoMySQLBackup script file below the variables section.

  • Download automysqlbackup.sh and place it into your /etc/cron.daily directory or your home directory.
  • Edit (at least) the following lines :
...
USERNAME=dbuser 
PASSWORD=password DBNAMES=”DB1 DB2 DB3″
...
  • Note:The user must have at least select privileges to the databases and make sure to keep the quotes ” ” otherwise it won’t work
  • Make the file executable :
sudo chmod u+rwx
  • Create the following directory
./backups
  • That’s it...Now you can run it using the command line “./automysqlbackup.sh” or if it is in /etc/cron.daily it will run each day when cron

MYSQL Administratorをインストールするには

sudo apt-get install mysql-admin

MySQL Query Browser (SQL Client) をインストールするには

sudo apt-get install mysql-query-browser

Oracle Database XEをインストールするには

deb http://oss.oracle.com/debian unstable main non-free
  • apt-getを用いてソフトウェアをインストールしてください。
sudo apt-get update
sudo apt-get install oracle-xe
  • 'dba'グループにログイン名を追加してください。(ログイン名のところはusernameになっています)
sudo usermod -G dba -a username

Apache HTTPサーバ

Apache HTTPサーバをHTTP(Web)サーバサービスのためにインストールするには

sudo apt-get install apache2
  • http://localhost

Apache HTTPサーバ用にPHPをインストールするには

PHP4をインストールするには
sudo apt-get install php4
sudo apt-get install libapache2-mod-php4
sudo /etc/init.d/apache2 restart
  • php4が正しくインストールされたかテストするには
gksudo gedit /var/www/testphp.php
  • この新規ファイルに以下を挿入してください。
<?php phpinfo(); ?>
  • 編集したファイルを保存してください。
  • http://localhost/testphp.php
  • テスト後にファイルを消すことを忘れないでください。ファイルはセキュリティリスクを招くことがあります。
PHP5 をインストールするには
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
  • To test if php5 installed correctly
gksudo gedit /var/www/testphp.php
  • (Optional) Insert the following line into the new file
<?php phpinfo(); ?>
  • Save the edited file
  • http://localhost/testphp.php
  • Be sure to remove the file afterwards, as it may pose a security risk
  • (Optional) Install recommended PHP5 modules
sudo apt-get install php5-xsl
sudo apt-get install php5-gd
sudo apt-get install php-pear
  • Restart Apache
sudo /etc/init.d/apache2 restart

Many PHP applications use XSLT technology as well as server-side graphic manipulation (via GD). Also, PEAR provides access to PHP's module repository.

pear help

Apache HTTPサーバ用にMYSQLをインストールするには

sudo apt-get install libapache2-mod-auth-mysql
  • どのバージョンのPHPをインストールしたかに応じて、php4-mysqlかphp5-mysqlのいずれかを選択してください。
sudo apt-get install php<バージョン>-mysql
sudo apt-get install phpmyadmin
  • PHPをMySQLと連携させるには、以下でファイルを開いてください。(<バージョン>のところは、どのPHPをインストールしたかに応じて4か5のいずれかです)
gksudo gedit /etc/php<バージョン>/apache2/php.ini
  • ";extension=mysql.so"の行のコメントを外す必要があります。するとこのようになります。
...
extension=mysql.so
...
  • ファイルを保存して終了してください。
sudo /etc/init.d/apache2 restart
  • http://localhost/phpmyadmin

Python for Apache 2 をインストールするには

sudo aptitude install python
sudo aptitude install libapache2-mod-python

How to map URLs to folders outside /var/www/

gksudo gedit /etc/apache2/conf.d/alias
  • Insert the following lines into the new file
Alias /URL-path /location_of_folder/


<Directory /location_of_folder/>
  Options Indexes FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
  • Save the edited file
sudo /etc/init.d/apache2 restart
  • http://localhost/URL-path
  • When you get "403 - Permission denied", you might try:
chmod o+x /location_of_folder/
  • If that doens't work, the following might help:
chmod o+r,o+x /location_of_folder/

Apache HTTPサーバのデフォルトポート番号を変更するには

例: 新しいポート番号が78だとします。
sudo cp /etc/apache2/ports.conf /etc/apache2/ports.conf_backup
gksudo gedit /etc/apache2/ports.conf
  • 以下の行を探してください。
Listen 80
  • 以下と置き換えてください。
Listen 78
  • 編集したファイルを保存してください。
sudo /etc/init.d/apache2 restart
  • http://localhost:78

Apache HTTPサーバのためにRSSをPHPへパースするには

例: RSSはDistroWatch.com - Newsとします。
wget -c http://easylinux.info/uploads/magpierss-0.71.1.tar.gz
sudo mkdir /var/www/feeds
sudo tar zxvf magpierss-0.71.1.tar.gz -C /var/www/feeds/
sudo mv /var/www/feeds/magpierss-0.71.1/* /var/www/feeds/
sudo rm -fr /var/www/feeds/magpierss-0.71.1/
sudo chown -R www-data:root /var/www/feeds/
gksudo gedit /var/www/feeds/index.php
  • 開いたファイルに以下の行を入力してください。
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
 <title>DistroWatch.com - News</title>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
 <style type="text/css">
 /*<![CDATA[*/
 /* 
 DEFAULT TAG STYLES
 */
 body {
  background: #ffffff;
  margin-left: 20px;
  font-family: bitstream vera sans,sans-serif;
  font-size: 9pt;
 }
 h1 {
  font-family: luxi sans,sans-serif;
  font-size: 15pt;
 }
 /*]]>*/
 </style>
 </head>
 <body>
 <?php
 require_once 'rss_fetch.inc';
 error_reporting(E_ERROR);
 $url = 'http://distrowatch.com/news/dw.xml';
 $rss = fetch_rss($url);
 if ($rss) {
  echo "<h1>";
  echo "<a href=$url>", $rss->channel[title], "</a><br/>";
  echo "</h1>";
  foreach ($rss->items as $item ) {
   $url = $item[link];
   $title = $item[title];
   $description = $item[description];
   echo "<li>";
   echo "<b>Topic:</b> <a href=$url><b><u>$title</u></b></a><br/><br/>";
   echo "$description<br/><br/>";
   echo "</li>";
  }
 }
 else {
  echo "<a href=$url>", $url, "</a> - Server Down!<br/>";
 }
 ?>
 </body>
 </html>
  • 編集したファイルを保存してください。
  • http://localhost/feeds/index.php

FTPサーバ

ファイル転送サービスのためにFTPサーバをインストールするには

sudo apt-get install proftpd

How to configure FTP user to be "jailed" (chrooted) into their home directory

sudo cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf_backup
gksudo gedit /etc/proftpd/proftpd.conf
  • Find this section
...
DenyFilter           \*.*/
...
  • Add the following line below it
DefaultRoot           ~


  • Save the edited file
sudo /etc/init.d/proftpd restart

How to configure FTP Server to allow anonymous FTP user to read only

sudo cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf_backup
gksudo gedit /etc/proftpd/proftpd.conf
  • Append the following lines at the end of file
<Anonymous ~ftp>
 User            ftp
 Group            nogroup
 UserAlias          anonymous ftp
 DirFakeUser on ftp
 DirFakeGroup on ftp
 RequireValidShell      off
 MaxClients         10
 DisplayLogin        welcome.msg
 DisplayFirstChdir      .message
 <Directory *>
  <Limit WRITE>
   DenyAll
  </Limit>
 </Directory>
</Anonymous>
  • Save the edited file
sudo /etc/init.d/proftpd restart

How to configure FTP Server to allow anonymous FTP user to read/write

sudo cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf_backup
gksudo gedit /etc/proftpd/proftpd.conf
  • Append the following lines at the end of file
<Anonymous ~ftp>
 User            ftp
 Group            nogroup
 UserAlias          anonymous ftp
 DirFakeUser on ftp
 DirFakeGroup on ftp
 RequireValidShell      off
 MaxClients         10
 DisplayLogin        welcome.msg
 DisplayFirstChdir      .message
</Anonymous>
  • Save the edited file
sudo /etc/init.d/proftpd restart

How to map anonymous FTP user to folders outside /home/ftp/

sudo cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf_backup
gksudo gedit /etc/proftpd/proftpd.conf
  • Append the following lines at the end of file
<Anonymous /location_of_folder/>
 User            ftp
 Group            nogroup
 UserAlias          anonymous ftp
 DirFakeUser on ftp
 DirFakeGroup on ftp
 RequireValidShell      off
 MaxClients         10
 DisplayLogin        welcome.msg
 DisplayFirstChdir      .message
 <Directory *>
  <Limit WRITE>
   DenyAll
  </Limit>
 </Directory>
</Anonymous>
  • Save the edited file
sudo /etc/init.d/proftpd restart

How to change the default port number for FTP Server

e.g. Assumed that new port number is 77
sudo cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf_backup
gksudo gedit /etc/proftpd/proftpd.conf
  • Find this line
Port              21
  • Replace with the following line
Port              77
  • Save the edited file
sudo /etc/init.d/proftpd restart

WindowsマシンからリモートのUbuntuマシンへftpするには

例: リモートのUbuntuマシンにはFTPサーバサービスがインストールされているものとします。
#ファイル転送サービスのためにFTPサーバをインストールするにはを読んでください。
  • FileZillaをここからダウンロードしてください。

Personal Apt Repository

Setting Up Repository

Note: This type of repository is known as a Trivial Repository. This type of repository does not fully comply with Debian standards, so should not be used commercially. However, it is ideal for home or personal use.

  • Install Package Tools
sudo apt-get install dpkg-dev
  • Create Repos on Filesystem
mkdir /somewhere/apt
mkdir /somewhere/apt/archives
mkdir /somewhere/apt/archives/binary
  • (Optional) Copy existing local APT cache to your Repos
cp -v /var/cache/apt/archives/*.deb /somewhere/apt/archives/binary/
  • Create Package Lists for Repos
cd /somewhere/apt/archives
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
  • Publish Repos with Apache
cd /var/www
sudo ln -s /somewhere/apt/archives apt
  • Add Repos to Sources (on all PCs) to /etc/apt/sources.list

Open /etc/apt/sources.list

sudo gedit /etc/apt/sources.list

Add the following to the bottom of the file:

# My Repos
deb http://localhost/apt binary/
  • Update APT Database
sudo apt-get update

Updating Repository

Simply copy or download ".deb" files to /somewhere/apt/archives/binary/ and then update the Packages list:

cd /somewhere/apt/archives
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz

ストリーミングメディアサーバ

ストリーミングメディアサーバサービスのためにGNUMP3dをインストールするには

例: /var/music/がマルチメディアファイルのあるディレクトリだとします。
sudo apt-get install gnump3d
  • http://localhost:8888

GNUMP3dにおける、マルチメディアファイルを置くデフォルトのディレクトリを変更するには

例: マルチメディアファイルを置く新しいディレクトリが/home/music/だとします。
sudo cp /etc/gnump3d/gnump3d.conf /etc/gnump3d/gnump3d.conf_backup
gksudo gedit /etc/gnump3d/gnump3d.conf
  • 以下の行を探してください。
root = /var/music
  • 以下と置き換えてください。
root = /home/music
  • 以下の行を探してください。
user = gnump3d
  • 以下と置き換えてください。
user = root
  • 編集したファイルを保存してください。
sudo /etc/init.d/gnump3d restart
  • http://localhost:8888

GNUMP3dのデフォルトポート番号を変更するには

例:新しいポート番号は7979だとします。
sudo cp /etc/gnump3d/gnump3d.conf /etc/gnump3d/gnump3d.conf_backup
gksudo gedit /etc/gnump3d/gnump3d.conf
  • 以下の行を探してください。
port = 8888
  • 以下と置き換えてください。
port = 7878
  • 編集したファイルを保存してください。
sudo /etc/init.d/gnump3d restart
  • http://localhost:7878

イメージギャラリーサーバ

  • Gallery1とGallery2の比較については、こちらを参照してください。

Gallery1

イメージギャラリーサーバサービスのためにGallery1をインストールするには
sudo apt-get install gallery (Apacheを再起動するか尋ねられたら、NoかCancelを選択してください)
sudo apt-get install imagemagick
sudo apt-get install jhead
sudo apt-get install libjpeg-progs
sudo /etc/init.d/apache2 restart
sudo sh /usr/share/gallery/configure.sh
  • http://localhost/gallery/setup/index.php
  • Gallery Configuration
Gallery Configuration Wizard: Step 1
Next Step ->


Gallery Configuration Wizard: Step 2
General settings タブ ->
Admin password: パスワードを入力


Locations and URLs タブ ->
Album directory: /var/www/albums/
Temporary directory: /tmp/
Gallery URL: http://localhost/gallery
Albums URL: http://localhost/albums
Next Step -->


Gallery Configuration Wizard: Step 3
Next Step -->


Gallery Configuration Wizard: Step 4
Save Config ->
  • http://localhost/gallery/albums.php

インターネット(ホスト名か固定IP)、もしくはLAN(固定IP)からGallery1にアクセスできるようにするには

例: ネットワークとインターネット接続が適切に設定されているとします。
インターネット(ホスト名もしくは固定IP) もしくは LAN (固定IP): http://www.url.com
sudo cp /etc/gallery/config.php /etc/gallery/config.php_backup
gksudo gedit /etc/gallery/config.php
  • このセクションを見つけてください。
...
$gallery->app->photoAlbumURL = "http://localhost/gallery";
$gallery->app->albumDirURL = "http://localhost/albums";
  • 以下と置き換えてください。
$gallery->app->photoAlbumURL = "http://www.url.com/gallery";
$gallery->app->albumDirURL = "http://www.url.com/albums";
  • 編集したファイルを保存してください。
  • http://www.url.com/gallery/albums.php

Gallery1にLAN(ダイナミックIP)からアクセスできるようにするには

例: ネットワーク接続が適切に設定されているとします。
LAN(ダイナミックIP): 192.168.0.1
sudo cp /etc/gallery/config.php /etc/gallery/config.php_backup
gksudo gedit /etc/gallery/config.php
  • このセクションを見つけてください。
...
$gallery->app->photoAlbumURL = "http://localhost/gallery";
$gallery->app->albumDirURL = "http://localhost/albums";
...
  • 以下と置き換えてください。
$gallery->app->photoAlbumURL = "/gallery";
$gallery->app->albumDirURL = "/albums";
  • 編集したファイルを保存してください。
  • http://192.168.0.1/gallery/albums.php

Gallery1のデータをバックアップ/リストアするには

sudo tar zcvf gallery.tgz /var/www/albums/ /etc/gallery/
  • ギャラリーデータをリストアするには
sudo tar zxvf gallery.tgz -C /

Gallery2

Gallery2をインストールするには
Gallery2の設定は

Subversion version control server (svnserve) をインストールするには

sudo apt-get install subversion xinetd
  • Create user that will own the repositories
sudo adduser --system --no-create-home --home /var/svn --group --disabled-login svn
  • Create directory that will hold the repositories
sudo mkdir /var/svn
sudo chown svn:svn /var/svn
  • Create file /etc/xinetd.d/svnserve with the following content
service svn
{
       port = 3690
       socket_type = stream
       protocol = tcp
       wait = no
       user = svn
       server = /usr/bin/svnserve
       server_args = -i -r /var/svn
}
  • Restart xinetd
sudo /etc/init.d/xinetd restart
  • Create the first repository
sudo -u svn svnadmin create /var/svn/testrepo
  • It should be possible to check out the repository and work on it
svn co svn://localhost/testrepo