未定義のホスト名の場合、先頭の定義が使用されるため。
2013年1月29日火曜日
apacheのバーチャルホストとWordPressのマルチサイトを使う
apacheのバーチャルホストとWordPressのマルチサイトを利用する場合は、VirtualHostの一番先頭にWordPressのVirtualHostを定義すること。
2012年12月29日土曜日
httpd.conf : Apache2+mod_fastcgi+php-fpm
Apache + mod_fastcgi + php-fpm
Server version: Apache/2.2.15 (Unix)
ServerTokens Prod
KeepAlive On
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
ServerAdmin root@localhost
ServerName www.luiukko.jp:80
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerSignature Off
2012年12月28日金曜日
SL6+mysql+php+apache+mod_fastcgi+php-fpm
WordPressをインストールするために、必要なモジュールをインストールしていきます。
mysql
yum install mysql-server mysql chkconfig mysqld on次に/etc/my.cnfを編集します。ファイルの内容は、VPS 2GB用のmy.cnfを参考にしてください。
service mysqld start /usr/bin/mysql_secure_installation
PHP 5.3 + php-fpm
PHP 5.3をインストールします。yum install php54 php54-common php54-mysql php54-mbstring php54-gd php54-xml php54-fpm/etc/php.iniを編集します。内容は、VPS 2GB用のphp.iniを参考にしてください。 mod_fastcgiをインストールします。
yum install mod_fastcgimod_fastcgiを有効にします。 /etc/httpd/conf.d/fastcgi.conf
User apache Group apache LoadModule fastcgi_module modules/mod_fastcgi.so FastCgiExternalServer /var/www/fcgi-bin/php-fpm -socket /var/run/php-fpm.sock AddHandler php-fastcgi .php ScriptAlias /fcgi-bin/ /var/www/fcgi-bin/ Action php-fastcgi /fcgi-bin/php-fpm AddType application/x-httpd-php .php DirectoryIndex index.phpphp.confを無効にする。
$ mv php.conf php.conf.bakphp-fpmをUnix Socketでリッスンするように設定します。
listen = /var/run/php-fpm.sock listen.owner = apache listen.group = apache listen.mode = 0666apacheの設定で、ExecCGIを有効にする。 /etc/httpd/conf/httpd.conf
サービスをリスタートする。Options +ExecCGI
# service php-fpm restart # service httpd restart
Permission denied: FastCGI: failed to connect to server "/var/www/fcgi-bin/php-fpm": connect() failed
原因は、SELinuxであることまでは分かりましたが、有効にしたまま動作するようにする方法は分かりません。
しばらくは、SELinuxを無効にしておきます。
# getenforce Enforcing # setenforce 0
2012年12月24日月曜日
VPS 2GB用のphp.ini
お名前.com VPSの2GBプラン用のphp.iniファイルです。
post_max_size = 15M upload_max_filesize = 15M allow_url_fopen = On [Date] ; Defines the default timezone used by the date functions ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone date.timezone = "Asia/Tokyo"
VPS 2GB用のmy.cnf
お名前.com VPSの2GBプラン用のmy.cnfファイルです。
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 character-set-server = utf8 skip-name-resolve skip-innodb default-storage-engine=MyISAM interactive_timeout = 50 join_buffer = 1M key_buffer = 250M max_connections = 100 max_heap_table_size = 32M myisam_sort_buffer_size = 96M query_cache_limit = 4M query_cache_size = 250M query_prealloc_size = 65K query_alloc_block_size = 128K read_buffer_size = 1M read_rnd_buffer_size = 768K sort_buffer_size = 1M table_cache = 4096 thread_cache_size = 1024 tmp_table_size = 32M wait_timeout = 500 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [mysql] default-character-set = utf8 [isamchk] key_buffer = 64M sort_buffer = 64M read_buffer = 16M write_buffer = 16M [myisamchk] key_buffer = 64M sort_buffer = 64M read_buffer = 16M write_buffer = 16M
お名前.com VPSにSL6.3をインストールした時のメモ
cat /etc/redhat-release Scientific Linux release 6.3 (Carbon)
ID関連
一般ユーザーを作って、sshを使ったrootログインを制限して、suできるユーザーを限定する。useradd hoge passwd hoge usermod -G wheel hoge
vi /etc/ssh/sshd_config
Port 2022 Protocol 2 SyslogFacility AUTHPRIV PermitRootLogin no PasswordAuthentication yes PermitEmptyPasswords no ChallengeResponseAuthentication no UsePAM yes Subsystem sftp /usr/libexec/openssh/sftp-server
service sshd restart
vi /etc/pam.d/su
#%PAM-1.0 auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. #auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid auth include system-auth account sufficient pam_succeed_if.so uid = 0 use_uid quiet account include system-auth password include system-auth session include system-auth session optional pam_xauth.soついでにロケールを変更。
vi /etc/sysconfig/i18n
LANG="ja_JP.UTF-8" SYSFONT="latarcyrheb-sun16"
IPv6関連
IPv6が有効になっているかを確認。
ifconfig -a
eth0 Link encap:Ethernet HWaddr 52:54:01:00:62:10
inet addr:49.212.122.248 Bcast:49.212.123.255 Mask:255.255.254.0
inet6 addr: fe80::5054:1ff:fe00:6210/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
IPv6を無効にする。
echo 'options ipv6 disable=1' >/etc/modprobe.d/disable-ipv6.conf chkconfig ip6tables off reboot
APIPA関連
APIPAが有効になっているかを確認する。netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 49.212.122.0 0.0.0.0 255.255.254.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 0.0.0.0 49.212.122.1 0.0.0.0 UG 0 0 0 eth0netowkを編集して無効にする。
vi /etc/sysconfig/network
NETWORKING=yes HOSTNAME=v103-3-18-170.myvps.jp GATEWAY=49.212.122.1 NOZEROCONF=yes
service network restart
yumリポジトリ関連
yumのプラグインを追加。yum install yum-plugin-fastestmirror yum-plugin-prioritiessl.repoとsl-other.repoのプライオリティを1に設定し最優先にする。
cd /etc/yum.repos.d vi sl.repoそれぞれのセクションの最後に以下の行を追加
priority=1EPELをリポジトリに追加する。
yum install epel-releaseIUS Yumリポジトリを追加する
wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-10.ius.el6.noarch.rpm rpm -Uvh ius-release-1.0-8.ius.el6.noarch.rpmRPMforgeを追加する。
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm全てのパッケージをアップデートしておきます。
yum update
iptables
iptablesを一括設定するファイルを作成しておきます。 ここでは、sshd, http, smtpを開けておきます。#!/bin/sh /sbin/iptables -F /sbin/iptables -X /sbin/iptables -P INPUT DROP /sbin/iptables -P OUTPUT ACCEPT /sbin/iptables -P FORWARD DROP /sbin/iptables -A INPUT -i lo -j ACCEPT /sbin/iptables -A OUTPUT -o lo -j ACCEPT /sbin/iptables -A INPUT -s 10.0.0.0/8 -j DROP /sbin/iptables -A INPUT -s 172.16.0.0/12 -j DROP /sbin/iptables -A INPUT -s 192.168.0.0/16 -j DROP /sbin/iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 2022 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 25 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT /etc/rc.d/init.d/iptables save
2012年9月22日土曜日
PDFファイルをEvernoteに保存する
PDFファイルをDropboxに保存すると、自動的にEvernoteに連携される仕組みを作ってみました。
WappwolfのDropbox Automatorというサービスを使います。既にDropboxとEvernoteはアカウントを持っていますので、Wappwolfのアカウントを作るところからです。
Try now! をクリックして、Login with dropbox "one folder" accessを選びます。
Dropboxにサインインして、Wappwolf Automator からの接続リクエストを許可します。 DropboxにWappwolfフォルダが作成され、その下に自動化するためのフォルダを指定する画面になりますので、適当な名前を入力します。
次に画面をスクロールして、Any fileにある Upload it to Evernoteを選択して、Connect to Evernoteをクリックします。
Evernoteにサインインして、Wappwolfのアクセスを承認します。 画面が戻ったら上に表示されている、Finishedをクリックします。 次の画面が表示されたら完了のようです。うまく行かなかった場合には、もう一回やってみるといいかもしれません。
これで準備完了です。 EvernoteにアップロードしたいファイルをDropboxの¥Apps¥Wappwolf¥Evernoteに保存すればOKです。
Dropboxにサインインして、Wappwolf Automator からの接続リクエストを許可します。 DropboxにWappwolfフォルダが作成され、その下に自動化するためのフォルダを指定する画面になりますので、適当な名前を入力します。
次に画面をスクロールして、Any fileにある Upload it to Evernoteを選択して、Connect to Evernoteをクリックします。
Evernoteにサインインして、Wappwolfのアクセスを承認します。 画面が戻ったら上に表示されている、Finishedをクリックします。 次の画面が表示されたら完了のようです。うまく行かなかった場合には、もう一回やってみるといいかもしれません。
これで準備完了です。 EvernoteにアップロードしたいファイルをDropboxの¥Apps¥Wappwolf¥Evernoteに保存すればOKです。
2012年8月5日日曜日
install php5 on OpenSUSE 12
# zypper install php5 php5-mysql php5-mbstring php5-gd php5-fpm Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW packages are going to be installed: libsqlite3-0 php5 php5-ctype php5-dom php5-fpm php5-gd php5-iconv php5-json php5-mbstring php5-mysql php5-pdo php5-sqlite php5-tokenizer php5-xmlreader php5-xmlwriter sqlite2 t1lib The following recommended packages were automatically selected: php5-ctype php5-dom php5-iconv php5-json php5-sqlite php5-tokenizer php5-xmlreader php5-xmlwriter The following packages are suggested, but will not be installed: php5-gettext php5-pear php5-suhosin 17 new packages to install. Overall download size: 3.6 MiB. After the operation, additional 13.6 MiB will be used. Continue? [y/n/?] (y): y Retrieving package t1lib-5.1.2-15.7.1.x86_64 (1/17), 152.0 KiB (405.0 KiB unpacked) Retrieving: t1lib-5.1.2-15.7.1.x86_64.rpm [done] Retrieving package php5-5.3.8-4.24.1.x86_64 (2/17), 1.1 MiB (4.6 MiB unpacked) Retrieving: php5-5.3.8-4.24.1.x86_64.rpm [done (7.1 MiB/s)] Retrieving package php5-xmlwriter-5.3.8-4.24.1.x86_64 (3/17), 29.0 KiB (47.0 KiB unpacked) Retrieving: php5-xmlwriter-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-tokenizer-5.3.8-4.24.1.x86_64 (4/17), 24.0 KiB (19.0 KiB unpacked) Retrieving: php5-tokenizer-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-pdo-5.3.8-4.24.1.x86_64 (5/17), 54.0 KiB (120.0 KiB unpacked) Retrieving: php5-pdo-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-mbstring-5.3.8-4.24.1.x86_64 (6/17), 402.0 KiB (2.1 MiB unpacked) Retrieving: php5-mbstring-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-json-5.3.8-4.24.1.x86_64 (7/17), 31.0 KiB (35.0 KiB unpacked) Retrieving: php5-json-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-iconv-5.3.8-4.24.1.x86_64 (8/17), 33.0 KiB (39.0 KiB unpacked) Retrieving: php5-iconv-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-gd-5.3.8-4.24.1.x86_64 (9/17), 100.0 KiB (333.0 KiB unpacked) Retrieving: php5-gd-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-fpm-5.3.8-4.24.1.x86_64 (10/17), 1.0 MiB (4.2 MiB unpacked) Retrieving: php5-fpm-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-dom-5.3.8-4.24.1.x86_64 (11/17), 64.0 KiB (173.0 KiB unpacked) Retrieving: php5-dom-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-ctype-5.3.8-4.24.1.x86_64 (12/17), 23.0 KiB (15.0 KiB unpacked) Retrieving: php5-ctype-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-mysql-5.3.8-4.24.1.x86_64 (13/17), 69.0 KiB (200.0 KiB unpacked) Retrieving: php5-mysql-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package php5-xmlreader-5.3.8-4.24.1.x86_64 (14/17), 29.0 KiB (31.0 KiB unpacked) Retrieving: php5-xmlreader-5.3.8-4.24.1.x86_64.rpm [done] Retrieving package libsqlite3-0-3.7.8-1.1.2.x86_64 (15/17), 262.0 KiB (798.0 KiB unpacked) Retrieving: libsqlite3-0-3.7.8-1.1.2.x86_64.rpm [done] Retrieving package sqlite2-2.8.17-179.1.2.x86_64 (16/17), 148.0 KiB (346.0 KiB unpacked) Retrieving: sqlite2-2.8.17-179.1.2.x86_64.rpm [done] Retrieving package php5-sqlite-5.3.8-4.24.1.x86_64 (17/17), 62.0 KiB (160.0 KiB unpacked) Retrieving: php5-sqlite-5.3.8-4.24.1.x86_64.rpm [done (0 B/s)] Installing: t1lib-5.1.2-15.7.1 [done] Installing: php5-5.3.8-4.24.1 [done] Installing: php5-xmlwriter-5.3.8-4.24.1 [done] Installing: php5-tokenizer-5.3.8-4.24.1 [done] Installing: php5-pdo-5.3.8-4.24.1 [done] Installing: php5-mbstring-5.3.8-4.24.1 [done] Installing: php5-json-5.3.8-4.24.1 [done] Installing: php5-iconv-5.3.8-4.24.1 [done] Installing: php5-gd-5.3.8-4.24.1 [done] Installing: php5-fpm-5.3.8-4.24.1 [done] Installing: php5-dom-5.3.8-4.24.1 [done] Installing: php5-ctype-5.3.8-4.24.1 [done] Installing: php5-mysql-5.3.8-4.24.1 [done] Installing: php5-xmlreader-5.3.8-4.24.1 [done] Installing: libsqlite3-0-3.7.8-1.1.2 [done] Installing: sqlite2-2.8.17-179.1.2 [done] Installing: php5-sqlite-5.3.8-4.24.1 [done]
# chkconfig php-fpm onphpの内容を確認します。
# cd /srv/www/htdocs # echo '<?php phpinfo(); ?>' >info.php
2012年8月4日土曜日
install nginx on OpenSUSE 12
# zypper install nginx Loading repository data... Reading installed packages... 'nginx' not found in package names. Trying capabilities. Resolving package dependencies... The following NEW packages are going to be installed: GeoIP libGeoIP1 libxslt1 nginx-1.0 The following recommended package was automatically selected: GeoIP 4 new packages to install. Overall download size: 1.3 MiB. After the operation, additional 4.0 MiB will be used. Continue? [y/n/?] (y): y Retrieving package libxslt1-1.1.26-15.8.1.x86_64 (1/4), 149.0 KiB (402.0 KiB unpacked) Retrieving: libxslt1-1.1.26-15.8.1.x86_64.rpm [done (6.2 KiB/s)] Retrieving package libGeoIP1-1.4.7-3.1.2.x86_64 (2/4), 75.0 KiB (242.0 KiB unpacked) Retrieving: libGeoIP1-1.4.7-3.1.2.x86_64.rpm [done] Retrieving package GeoIP-1.4.7-3.1.2.x86_64 (3/4), 481.0 KiB (1.2 MiB unpacked) Retrieving: GeoIP-1.4.7-3.1.2.x86_64.rpm [done] Retrieving package nginx-1.0-1.0.10-3.4.1.x86_64 (4/4), 581.0 KiB (2.1 MiB unpacked) Retrieving: nginx-1.0-1.0.10-3.4.1.x86_64.rpm [done] Installing: libxslt1-1.1.26-15.8.1 [done] Installing: libGeoIP1-1.4.7-3.1.2 [done] Installing: GeoIP-1.4.7-3.1.2 [done] Installing: nginx-1.0-1.0.10-3.4.1 [done] # chkconfig nginx on # rcnginx startSuSEfirewall2を設定して、ポート80へのInboundを許可します。
# cd /etc/sysconfig/SuSEfirewall2.d/services # echo 'TCP="80"' >httpd
# vi /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT="sshd smtp dovecot httpd"設定を反映します。
# rcSuSEfirewall2 restart
Install MySQL on OpenSUSE 12
パッケージをインストールします。
# zypper install mysql-community-server mysql-community-client Loading repository data... Reading installed packages... 'mysql-community-client' not found in package names. Trying capabilities. No provider of 'mysql-community-client' found. Resolving package dependencies... The following NEW packages are going to be installed: mysql-community-server mysql-community-server-client mysql-community-server-errormessages 3 new packages to install. Overall download size: 8.0 MiB. After the operation, additional 60.5 MiB will be used. Continue? [y/n/?] (y): y Retrieving package mysql-community-server-errormessages-5.5.25-3.12.1.x86_64 (1/3), 146.0 KiB (1.0 MiB unpacked) Retrieving: mysql-community-server-errormessages-5.5.25-3.12.1.x86_64.rpm [done]Retrieving package mysql-community-server-client-5.5.25-3.12.1.x86_64 (2/3), 736.0 KiB (17.1 MiB unpacked) Retrieving: mysql-community-server-client-5.5.25-3.12.1.x86_64.rpm [done]Retrieving package mysql-community-server-5.5.25-3.12.1.x86_64 (3/3), 7.1 MiB (42.4 MiB unpacked) Retrieving: mysql-community-server-5.5.25-3.12.1.x86_64.rpm [done] Installing: mysql-community-server-errormessages-5.5.25-3.12.1 [done] Installing: mysql-community-server-client-5.5.25-3.12.1 [done] Installing: mysql-community-server-5.5.25-3.12.1 [done]自動起動をOnにします。
# systemctl enable mysql.service mysql.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig mysql onサービスを起動します。
# systemctl start mysql.service Failed to issue method call: Unit mysql.service failed to load: No such file or directory. See system logs and 'systemctl status mysql.service' for details.エラーで起動できず。。。 原因がわからないので、一旦アンインストールして、パッケージの入手からやり直すことにします。 アンインストール。
# zypper remove mysql-community-server mysql-community-server-client mysql-community-server-errormessagesパッケージをMySQLのサイトからダウンロードします。SLESを選択して、MySQL ServerとClient Utilitiesをダウンロードします。 http://dev.mysql.com/downloads/mysql/5.5.html rpmパッケージをインストールします。
# rpm -ivh MySQL-server-5.5.27-1.sles11.x86_64.rpmPreparing... ########################################### [100%] ls: cannot access /var/lib/mysql/*.err: No such file or directory ls: cannot access /var/lib/mysql/*.err: No such file or directory 1:MySQL-server ########################################### [100%] insserv: Service network is missed in the runlevels 2 4 to use service mysql Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off # rpm -ivh MySQL-client-5.5.27-1.sles11.x86_64.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]セキュリティ設定用のスクリプトを実行します。
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n]
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
お終い!
telnetでIMAPアクセス
# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=CRAM-MD5 AUTH=LOGIN AUTH=PLAIN] Dovecot ready.
1 login mascotpark@lool.jp password
1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
2 list "" *
* LIST (\HasNoChildren) "." "INBOX"
2 OK List completed.
3 select INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $NotJunk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $NotJunk \*)] Flags permitted.
* 1 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1342696244] UIDs valid
* OK [UIDNEXT 2] Predicted next UID
* OK [HIGHESTMODSEQ 1] Highest
3 OK [READ-WRITE] Select completed.
4 fetch 1 body[]
* 1 FETCH (BODY[] {523}
Return-Path:
X-Original-To: mascotpark@lool.jp
Delivered-To: mascotpark@lool.jp
Received: by mail.lool.jp (Postfix, from userid 0)
id 4B8482003D4; Sat, 4 Aug 2012 14:20:25 +0900 (JST)
Date: Sat, 04 Aug 2012 14:20:25 +0900
To: mascotpark@lool.jp
Subject: hello
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20120804052025.4B8482003D4@mail.lool.jp>
From: root@mail.lool.jp (root)
test
)
4 OK Fetch completed.
5 logout
* BYE Logging out
5 OK Logout completed.
Connection closed by foreign host.
#
2012年7月16日月曜日
[RESOLVED] warning: not set-gid or not owner+group+world executable:
postfix起動時に以下のメッセージが表示されます。
Jul 16 11:10:25 v103-3-189-170 postfix/postfix-script[3588]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postqueue Jul 16 11:10:25 v103-3-189-170 postfix/postfix-script[3589]: warning: not set-gid or not owner+group+world executable: /usr/sbin/postdropそれぞれのファイルのパーミッションは以下の通りです。
-rwxr-xr-x 1 root maildrop 15064 May 10 18:44 postdrop -rwxr-xr-x 1 root maildrop 15016 May 10 18:44 postqueueパーミッションを以下の通り変更します。
# cd /usr/sbin # chmod g+s postdrop postqueue # ls -l postqueue postdrop -rwxr-sr-x 1 root maildrop 15064 May 10 18:44 postdrop -rwxr-sr-x 1 root maildrop 15016 May 10 18:44 postqueue
[RESOLVED] warning: not owned by group maildrop:
メッセージの内容は以下の通り。
Jul 16 10:59:28 v103-3-189-170 postfix/postfix-script[3316]: warning: not owned by group maildrop: /usr/sbin/postqueue Jul 16 10:59:28 v103-3-189-170 postfix/postfix-script[3317]: warning: not owned by group maildrop: /usr/sbin/postdropこの時の各ファイルのオーナーは次の通り。
-rwxr-xr-x 1 root root 15064 May 10 18:44 postdrop -rwxr-xr-x 1 root root 15016 May 10 18:44 postqueueグループをmaildropに変更します。
# chgrp maildrop postqueue postdrop # ls -l -rwxr-xr-x 1 root maildrop 15064 May 10 18:44 postdrop -rwxr-xr-x 1 root maildrop 15016 May 10 18:44 postqueue
openSUSE12.1 メールサーバー インストール postfix dovecot
openSUSE12.1に、postfixとdovecotをインストールして、メールサーバーを構築します。
# zypper install --no-recommends postfix dovecot12 Loading repository data... Reading installed packages... 'postfix' is already installed. No update candidate for 'postfix-2.8.8-3.13.1.x86_64'. The highest available version is already installed. Resolving package dependencies... The following NEW package is going to be installed: dovecot12 The following packages are recommended, but will not be installed: dovecot12-backend-mysql dovecot12-backend-pgsql dovecot12-backend-sqlite 1 new package to install. Overall download size: 2.6 MiB. After the operation, additional 14.4 MiB will be used. Continue? [y/n/?] (y): y Retrieving package dovecot12-1.2.17-7.1.3.x86_64 (1/1), 2.6 MiB (14.4 MiB unpacked) Retrieving: dovecot12-1.2.17-7.1.3.x86_64.rpm [done] Installing: dovecot12-1.2.17-7.1.3 [done]postfixはインストールされていました。 今回は次のようなメールサーバーを構築します。
- SASL認証はdovecotで行う
- virtual mailboxを使う
- SSLによる暗号化
- IMAPを使う
# postconf -a cyrus dovecotSSLの自己証明書と秘密鍵を作ります。
# cd /etc/ssl/private # openssl req -new -x509 -nodes -days 3650 -out mail.crt -keyout mail.key Generating a 1024 bit RSA private key .....++++++ ...........................................++++++ writing new private key to 'mail.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:mail.lool.jp Email Address []: # chmod 600 mail.key次にvirtual mailbox用に、ユーザーとグループを作成します。
# groupadd -g 1001 vmail # useradd -u 1001 -g 1001 -d /var/spool/vmail -r -s /sbin/nologin vmailvirtual mailboxディレクトリを作成します。
# mkdir /var/spool/vmail # chown vmail.vmail /var/spool/vmail # chmod 700 /var/spool/vmail/etc/postfix/main.cfを編集します。
setgid_group = maildrop
daemon_directory = /usr/lib/postfix
myhostname = mail.lool.jp
mydomain = lool.jp
myorigin = $mydomain
mydestination = $myhostname localhost.$mydomain localhost
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
permit_auth_destination,
reject
debug_peer_level = 3
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_gid_maps = static:1001
virtual_uid_maps = static:1001
virtual_mailbox_base = /var/spool/vmail
virtual_mailbox_domains = lool.jp
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/dovecot-auth
/etc/postfix/vmailboxにvirtual mailboxを定義します。
mascotpark@lool.jp mascotpark/Maildir/
# cd /etc/postfix # postmap vmailbox/etc/postfix/master.cfを編集します。
smtp inet n - n - - smtpd submission inet n - n - - smtpd -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject次に/etc/dovecot/dovecot.confを編集します。
protocols = imap imaps
protocol imap {
listen = *:143
ssl_listen = *:993
}
listen = *
disable_plaintext_auth = yes
ssl = yes
ssl_cert_file = /etc/ssl/private/mail.crt
ssl_key_file = /etc/ssl/private/mail.key
verbose_ssl = yes
mail_location = maildir:/var/spool/vmail/%u/Maildir
mail_uid = 1001
mail_gid = 1001
mail_debug = yes
lock_method = fcntl
protocol imap {
mail_plugin_dir = /usr/lib64/dovecot/modules/imap
}
auth_username_format = %Ln
auth default {
mechanisms = cram-md5 login plain
passdb passwd-file {
args = scheme=CRAM-MD5 username_format=%u /etc/dovecot/passwd
}
user = root
socket listen {
master {
path = /var/run/dovecot/auth-master
mode = 0600
user = postfix
group = postfix
}
client {
path = /var/spool/postfix/private/dovecot-auth
mode = 0660
user = postfix
group = postfix
}
}
}
dict {
}
plugin {
}
/etc/dovecot/passwdファイルを作ります。
mascotpark:{CRAM-MD5}477934589a58e54b516c742aff2e8a77019df50f3b33f134385b875047370666
サービスを再起動します。
# systemctl restart postfix.service # systemctl restart dovecot.serviceFirewallを設定します。 smtpとdovecotで使用するポート番号を設定します。 /etc/sysconfig/SuSEfirewall2.d/services/smtp
TCP="25 465 587"/etc/sysconfig/SuSEfirewall2.d/services/dovecot
TCP="imap imaps pop3 pop3s sieve 4190"/etc/sysconfig/SuSEfirewall2を編集し、サービスを再起動します。
FW_CONFIGURATIONS_EXT="sshd smtp dovecot"
# /sbin/SuSEfirewall2 stop SuSEfirewall2: Firewall rules unloaded. # /sbin/SuSEfirewall2 start SuSEfirewall2: Setting up rules from /etc/sysconfig/SuSEfirewall2 ... SuSEfirewall2: using default zone 'ext' for interface eth0 SuSEfirewall2: Firewall rules successfully settelnetを使って動作を確認します。
# telnet localhost 25 EHLO localhost 250-mail.lool.jp 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN MAIL FROM:root 250 2.1.0 Ok RCPT TO:mascotpark@lool.jp 250 2.1.5 Ok DATA 354 End data with. TEST . 250 2.0.0 Ok: queued as 6EC272003DA quit 221 2.0.0 Bye Connection closed by foreign host.
# telnet localhost 143 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=CRAM-MD5 AUTH=PLAIN AUTH=LOGIN] Dovecot ready. x LOGIN mascotpark@lool.jp password x OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in x LOGOUT * BYE Logging out x OK Logout completed. Connection closed by foreign host.
2012年7月10日火曜日
SUSE sshdのポートを変更したのでFirewallの設定を変える
sshdのポートを20から2022に変更したので、それに合わせてFirewallのポートも20から2022に変更します。
/etc/sysconfig/SuSEfirewall2.d/servicesディレクトリの下に、サービス名のファイル名があります。
今回は、sshdですので、その内容を以下に変更します。
## Name: Secure Shell Server ## Description: Open ports for Secure Shell Server # space separated list of allowed TCP ports #TCP="ssh" TCP=2022設定の変更を反映する方法はまだ分かっていません。。。リブートしました。
2012年7月9日月曜日
SUSE ホスト名の変更 固定IPアドレス デフォルトゲートウェイ設定 DNS設定
ホスト名を変更するには、/etc/HOSTNAMEファイルを編集します。
myhostname/etc/sysconfig/network/ifcfg-eth0を編集して、ネットワークを設定します。
BOOTPROTO='static' BROADCAST='103.3.189.255' ETHTOOL_OPTIONS='' IPADDR='103.3.189.170' MTU='' NAME='Ethernet Card 0' NETMASK='255.255.255.0' NETWORK='103.3.189.0' REMOTE_IPADDR='' STARTMODE='auto' USERCONTROL='no'デフォルトゲートウェイを設定します。 /etc/sysconfig/network/routesファイルを作成します。
default 103.3.189.1 - -/etc/resolv.confを編集して、DNSサーバーを設定します。/etc/resolv.confを手動で編集する際には、/etc/sysconfig/network/configファイルを編集します。
NETCONFIG_DNS_POLICY=""
search myvps.jp nameserver 210.157.1.170 nameserver 210.172.133.178
お名前.com VPSにopenSUSEをインストール
お名前.comのVPS(2GB)を借りたので、openSUSEをインストールしてみました。
まずはOS Imageをダウンロードします。
software.opensuse.org: openSUSE 12.1 のダウンロード
次にダウンロードしたISOイメージをアップロードします。そのために、コントロールパネルの画面から、ssh private keyをダウンロードします。ページの下の方にあります。
接続先サーバー名、ユーザー名、ダウンロードした公開鍵ファイルを使って、SFTPで接続します。接続したらimagesディレクトリの下に、ダウンロードしたISOイメージファイルをアップロードします。
次にOS再インストールのタブを選択して、OSにアップロードしたopenSUSEを選択します。パーティションはお好みで。
実行すると、サーバーリストが表示されますので、IPアドレスと初期ホスト名をメモしておきます。起動をクリックして、VMをブートします。
installationを選択します。
言語とキーボードレイアウトを日本語に設定して、次へ。
新規インストールと手動設定を選んで、次へ。
ハードウェアの時刻はUTCに設定のチェックを外します。
私はサーバー用途でインストールしますので、最小限のサーバ(テキストモード)を選びます。
パーティションを任意に設定して、次へ。
ユーザー名とパスワードなどこちらもお好みで。
インストール設定を確認します。最後のsshを有効にしました。
問題がなければインストールをGO!
ホスト名とドメイン名を設定しますが、とりあえずデフォルトのまま進みます。
デフォルトのままでもいいですが、IPv6を無効にしてから次に進みます。
インターネットへの接続テストはお好みで。
エラーが表示されてもあまり気にせず前に進みます。
オンライン更新を実行するのまま、次に進みます。
了解して次へ進みます。
修正のダウンロードとインストールが完了したら次へ進みます。
途中おかしくなったら再起動します。次の画面が表示されたらインストールは終わりです。
まずはOS Imageをダウンロードします。
software.opensuse.org: openSUSE 12.1 のダウンロード
次にダウンロードしたISOイメージをアップロードします。そのために、コントロールパネルの画面から、ssh private keyをダウンロードします。ページの下の方にあります。
接続先サーバー名、ユーザー名、ダウンロードした公開鍵ファイルを使って、SFTPで接続します。接続したらimagesディレクトリの下に、ダウンロードしたISOイメージファイルをアップロードします。
次にOS再インストールのタブを選択して、OSにアップロードしたopenSUSEを選択します。パーティションはお好みで。
実行すると、サーバーリストが表示されますので、IPアドレスと初期ホスト名をメモしておきます。起動をクリックして、VMをブートします。
installationを選択します。
言語とキーボードレイアウトを日本語に設定して、次へ。
新規インストールと手動設定を選んで、次へ。
ハードウェアの時刻はUTCに設定のチェックを外します。
私はサーバー用途でインストールしますので、最小限のサーバ(テキストモード)を選びます。
パーティションを任意に設定して、次へ。
ユーザー名とパスワードなどこちらもお好みで。
インストール設定を確認します。最後のsshを有効にしました。
問題がなければインストールをGO!
ホスト名とドメイン名を設定しますが、とりあえずデフォルトのまま進みます。
デフォルトのままでもいいですが、IPv6を無効にしてから次に進みます。
インターネットへの接続テストはお好みで。
エラーが表示されてもあまり気にせず前に進みます。
オンライン更新を実行するのまま、次に進みます。
了解して次へ進みます。
修正のダウンロードとインストールが完了したら次へ進みます。
途中おかしくなったら再起動します。次の画面が表示されたらインストールは終わりです。
2012年7月8日日曜日
postfix + dovecot on SL6
postfixの設定
# postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 home_mailbox = Maildir/ html_directory = no inet_interfaces = all inet_protocols = ipv4 local_recipient_maps = proxy:unix:passwd.byname $alias_maps $virtual_mailbox_maps mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = $myhostname, localhost myhostname = mail.lumiukko.jp mynetworks = 49.212.129.72 mynetworks_style = host myorigin = $myhostname newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES relay_domains = $mydestination sample_directory = /usr/share/doc/postfix-2.6.6/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_path = private/dovecot-auth smtpd_sasl_security_options = noanonymous smtpd_sasl_type = dovecot smtpd_tls_auth_only = yes smtpd_tls_cert_file = /etc/pki/tls/certs/mail.crt smtpd_tls_key_file = /etc/pki/tls/certs/mail.key smtpd_use_tls = yes unknown_local_recipient_reject_code = 550 virtual_alias_maps = hash:/etc/postfix/virtual virtual_gid_maps = static:502 virtual_mailbox_base = /var/spool/vmail virtual_mailbox_domains = lumiukko.jp virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_uid_maps = static:502/etc/postfix/master.cfの内容
smtp inet n - n - - smtpd submission inet n - n - - smtpd -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING #smtps inet n - n - - smtpd # -o smtpd_tls_wrappermode=yes # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING/etc/postfix/vmailboxの内容
nordenlife@lumiukko.jp lumiukko.jp/nordenlife/Maildir/
dovecotの設定
# doveconf -n
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-220.7.1.el6.x86_64 x86_64 Scientific Linux release 6.2 (Carbon)
auth_mechanisms = cram-md5 login
auth_username_format = %Lu
auth_verbose = yes
listen = *
mail_debug = yes
mail_location = maildir:~/Maildir
mbox_write_locks = fcntl
passdb {
args = scheme=CRAM-MD5 username_format=%u /etc/dovecot/passwd
driver = passwd-file
}
protocols = imap
service auth {
unix_listener /var/spool/postfix/private/dovecot-auth {
group = postfix
mode = 0600
user = postfix
}
}
ssl = required
ssl_cert = </etc/pki/tls/certs/mail.crt
ssl_key = </etc/pki/tls/certs/mail.key
userdb {
args = uid=vmail gid=vmail home=/var/spool/vmail/%d/%n
driver = static
}
/etc/dovecot/passwdの内容
nordenlife@lumiukko.jp:{CRAM-MD5}c68d3329d0db55548a14e9d7
2012年7月7日土曜日
[RESOLVED] Recipient address rejected: User unknown in local recipient tabl
postfix + dovecotでメールサーバーを構築中ですが、以下のメッセージが表示されうまくメールが送信できません。
ユーザー認証は、dovecot側でバーチャルユーザーを使っています。
# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.lumiukko.jp ESMTP Postfix HELO mail.lumiukko.jp 250 mail.lumiukko.jp MAIL FROM:root 250 2.1.0 Ok RCPT TO:nordenlife@lumiukko.jp 550 5.1.1上記のテストで、/var/log/maillogに出力されるエラーメッセージは以下の通り。: Recipient address rejected: User unknown in local recipient table
Jul 7 23:01:17 www4298uf postfix/smtpd[19280]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1dovecotにimapで接続する際の認証はうまく行ってる気がするのですが。。。: Recipient address rejected: User unknown in local recipient table; from= to= proto=SMTP helo=
# telnet localhost 143 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=CRAM-MD5 AUTH=PLAIN AUTH=LOGIN] Dovecot ready. x LOGIN nordenlife@lumiukko.jp password x OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in x LOGOUT * BYE Logging out x OK Logout completed. Connection closed by foreign host.postfixの認証を試してみるとうまく行きます。うーん。 ログイン認証はbase64でエンコードする必要があります。
# echo -n "nordenlife@lumiukko.jp" | base64 bm9yZGVubGlmZUBsdW1pdWtrby5qcA== # echo -n "password" | base64 cGFzc3dvcmQ= [root@www4298uf ~]# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.lumiukko.jp ESMTP Postfix AUTH LOGIN 334 VXNlcm5hbWU6 bm9yZGVubGlmZUBsdW1pdWtrby5qcA== 334 UGFzc3dvcmQ6 cGFzc3dvcmQ= 235 2.7.0 Authentication successful QUIT 221 2.0.0 Bye Connection closed by foreign host.
原因判明
local_recipient_mapsを設定していなかったことが原因でした。 /etc/postfix/main.cflocal_recipient_maps = proxy:unix:passwd.byname $alias_maps $virtual_mailbox_maps alias_maps = hash:/etc/aliases virtual_mailbox_maps = hash:/etc/postfix/vmailboxちなみに、/etc/postfix/vmailboxの内容は以下になっています。
nordenlife@lumiukko.jp lumiukko.jp/nordenlife/Maildir/
登録:
投稿 (Atom)