Apache/一般ユーザーの$HOME/public_htmlを公開する設定方法
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../../)
* Apacheで一般ユーザーの$HOME/public_htmlを公開する設定方...
Apacheの設定により、以下のようにユーザーごとのホームペー...
http://サーバー名/~ユーザー名
これにより、サーバーに存在するユーザー毎にホームページを...
以下、~ユーザー名によるホームページ公開の設定方法を記しま...
#contents
#htmlinsertpcsp(web-top.html,web-sp.html)
* 使用した環境 [#g4141b9b]
本資料で使用した環境は以下の通りです。
- OS
$ lsb_release -d
Description: CentOS release 6.3 (Final)
- Apache
$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Feb 13 2012 22:31:42
本環境以外の方(Windowsなど)でも、httpd.confは一緒なので、...
また、httpd.confではなく、apache.confになっている環境もあ...
* 関連資料 [#v3e80a17]
Windows, CentOS, UbuntuのLAMP, LAPPなどのインストール使用...
参考にしてください。
-[[WindowsでXAMPPを用いてLAMP環境を構築>LAMP/WindowsでXAM...
以下の4つの資料は[[LINUX.JUST4FUN.BIZ>http://linux.just4f...
-[[UbuntuでLAMP環境を構築する>http://linux.just4fun.biz/U...
-[[CentOSでLAMP環境を構築する>http://linux.just4fun.biz/C...
-[[UbuntuでLAPP環境を構築する>http://linux.just4fun.biz/U...
-[[CentOSでLAPP環境を構築する>http://linux.just4fun.biz/C...
* SELinuxを無効にする [#ic7e6aef]
SELinuxを無効にしないとPermission deniedになります。~
SELinuxの無効化は以下のリンクを参考にして設定してください。
-[[CentOSでSELinux動作モード確認・動作モードの設定方法>ht...
ちなみにrootユーザーになり、以下のコマンドでEnforceと出力...
[root@centos6 ~]# getenforce
Enforcing
一時的にSELinuxを無効化にする方法は、以下のコマンドで可能...
setenforce 0
* httpd.confを修正しユーザー毎にホームページを公開する [#...
httpd.confファイルを開き、以下のキーワードを探します。~
本資料では、CentOS6を使用しています。~
以下のディレクトリにhttpd.confがありました。~
作業はrootユーザーにて行いました。
[sakura@centos6 ~]$ su -
パスワード:
[root@centos6 ~]# vi /etc/httpd/conf/httpd.conf
-変更前
187 LoadModule userdir_module modules/mod_userdir.so
<省略>
360 <IfModule mod_userdir.c>
361 #
362 # UserDir is disabled by default since it can...
363 # of a username on the system (depending on h...
364 # permissions).
365 #
366 UserDir disabled
367
368 #
369 # To enable requests to /~user/ to serve the ...
370 # directory, remove the "UserDir disabled" li...
371 # the following line instead:
372 #
373 #UserDir public_html
374
375 </IfModule>
<省略>
381 #<Directory /home/*/public_html>
382 # AllowOverride FileInfo AuthConfig Limit
383 # Options MultiViews Indexes SymLinksIfOwnerMa...
384 # <Limit GET POST OPTIONS>
385 # Order allow,deny
386 # Allow from all
387 # </Limit>
388 # <LimitExcept GET POST OPTIONS>
389 # Order deny,allow
390 # Deny from all
391 # </LimitExcept>
392 #</Directory>
- 変更後~
以下の変更を行いました。
+ userdir_moduleのロード(最初からコメントされていなかった...
+ UserDir disabled → #UserDir disabled
+ #UserDir public_html → UserDir public_html
+ <Directory /home/*/public_html> ... </Directory> のコメ...
187 LoadModule userdir_module modules/mod_userdir.so
<省略>
360 <IfModule mod_userdir.c>
361 #
362 # UserDir is disabled by default since it can...
363 # of a username on the system (depending on h...
364 # permissions).
365 #
366 #UserDir disabled
367
368 #
369 # To enable requests to /~user/ to serve the ...
370 # directory, remove the "UserDir disabled" li...
371 # the following line instead:
372 #
373 UserDir public_html
374
375 </IfModule>
<省略>
381 <Directory /home/*/public_html>
382 AllowOverride FileInfo AuthConfig Limit
383 Options MultiViews Indexes SymLinksIfOwnerMat...
384 <Limit GET POST OPTIONS>
385 Order allow,deny
386 Allow from all
387 </Limit>
388 <LimitExcept GET POST OPTIONS>
389 Order deny,allow
390 Deny from all
391 </LimitExcept>
392 </Directory>
変更が終了したらhttpd.confを保存しapache(httpd)を再起動し...
CentOSではrootユーザーにて以下のコマンドで再起動しました。
service httpd restart
上記コマンドを実行したときの出力です。
[root@centos6 ~]# service httpd restart
httpd を停止中: ...
httpd を起動中: ...
[root@centos6 ~]#
#br
* ユーザーのホームディレクトリにpublic_htmlを作成する [#a...
以下、ユーザー名 sakura で設定を行います。
+ sakura ユーザーでログインします。
+ public_htmlディレクトリを作成します。
mkdir ~/public_html
+ httpd(apache)プロセスがアクセスできるようにパーミッショ...
CentOSの設定を見たところ、以下のようになっていました。
[sakura@centos6 ~]$ cd ..
[sakura@centos6 home]$ ls -l
合計 8
drwx------. 30 sakura sakura 4096 2月 11 21:00 2013 s...
drwx------. 4 tsubaki tsubaki 4096 2月 11 21:03 2013 t...
ユーザー以外、アクセスができないので、以下のようにパーミ...
chmod o+r /home/sakura
以下、chmodによるアクセス権限変更および確認を記します。
[sakura@centos6 home]$ pwd
/home
[sakura@centos6 home]$ ls -ld sakura/
drwx------. 30 sakura sakura 4096 2月 11 21:00 2013 sak...
[sakura@centos6 home]$ chmod o+x sakura/
[sakura@centos6 home]$ ls -ld sakura/
drwx-----x. 29 sakura sakura 4096 2月 11 21:21 2013 sak...
その他にパーミッション(権限)に--xになりました。
上記操作で作成したpublic_htmlのパーミッションを確認すると...
[sakura@centos6 home]$ cd
[sakura@centos6 ~]$ ls -ld public_html/
drwxrwxr-x. 2 sakura sakura 4096 2月 11 21:02 2013 publ...
* public_htmlにindex.htmlを作成しブラウザからアクセスして...
作成したpublic_htmlディレクトリにindex.htmlを作成してみま...
[sakura@centos6 ~]$ cd public_html/
[sakura@centos6 public_html]$ echo '<b>Hello world!</b>'...
作成したindex.htmlのパーミッションを確認すると、その他にr...
[sakura@centos6 public_html]$ ls -l index.html
-rw-rw-r--. 1 sakura sakura 20 2月 11 21:14 2013 index....
* ブラウザを起動してアクセスしてみる [#e09f8b50]
今回使用したユーザー名はsakuraです。~
したがって、以下のようにすれば/home/sakura/public_html/の...
http://ホスト名/~sakura/
実際にアクセスしたときのスクリーンショットです。
#ref(01.gif)
以上、Apacheで一般ユーザーの$HOME/public_htmlを公開する設...
#htmlinsertpcsp(web-btm.html,web-sp.html)
終了行:
#navi(../../)
* Apacheで一般ユーザーの$HOME/public_htmlを公開する設定方...
Apacheの設定により、以下のようにユーザーごとのホームペー...
http://サーバー名/~ユーザー名
これにより、サーバーに存在するユーザー毎にホームページを...
以下、~ユーザー名によるホームページ公開の設定方法を記しま...
#contents
#htmlinsertpcsp(web-top.html,web-sp.html)
* 使用した環境 [#g4141b9b]
本資料で使用した環境は以下の通りです。
- OS
$ lsb_release -d
Description: CentOS release 6.3 (Final)
- Apache
$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Feb 13 2012 22:31:42
本環境以外の方(Windowsなど)でも、httpd.confは一緒なので、...
また、httpd.confではなく、apache.confになっている環境もあ...
* 関連資料 [#v3e80a17]
Windows, CentOS, UbuntuのLAMP, LAPPなどのインストール使用...
参考にしてください。
-[[WindowsでXAMPPを用いてLAMP環境を構築>LAMP/WindowsでXAM...
以下の4つの資料は[[LINUX.JUST4FUN.BIZ>http://linux.just4f...
-[[UbuntuでLAMP環境を構築する>http://linux.just4fun.biz/U...
-[[CentOSでLAMP環境を構築する>http://linux.just4fun.biz/C...
-[[UbuntuでLAPP環境を構築する>http://linux.just4fun.biz/U...
-[[CentOSでLAPP環境を構築する>http://linux.just4fun.biz/C...
* SELinuxを無効にする [#ic7e6aef]
SELinuxを無効にしないとPermission deniedになります。~
SELinuxの無効化は以下のリンクを参考にして設定してください。
-[[CentOSでSELinux動作モード確認・動作モードの設定方法>ht...
ちなみにrootユーザーになり、以下のコマンドでEnforceと出力...
[root@centos6 ~]# getenforce
Enforcing
一時的にSELinuxを無効化にする方法は、以下のコマンドで可能...
setenforce 0
* httpd.confを修正しユーザー毎にホームページを公開する [#...
httpd.confファイルを開き、以下のキーワードを探します。~
本資料では、CentOS6を使用しています。~
以下のディレクトリにhttpd.confがありました。~
作業はrootユーザーにて行いました。
[sakura@centos6 ~]$ su -
パスワード:
[root@centos6 ~]# vi /etc/httpd/conf/httpd.conf
-変更前
187 LoadModule userdir_module modules/mod_userdir.so
<省略>
360 <IfModule mod_userdir.c>
361 #
362 # UserDir is disabled by default since it can...
363 # of a username on the system (depending on h...
364 # permissions).
365 #
366 UserDir disabled
367
368 #
369 # To enable requests to /~user/ to serve the ...
370 # directory, remove the "UserDir disabled" li...
371 # the following line instead:
372 #
373 #UserDir public_html
374
375 </IfModule>
<省略>
381 #<Directory /home/*/public_html>
382 # AllowOverride FileInfo AuthConfig Limit
383 # Options MultiViews Indexes SymLinksIfOwnerMa...
384 # <Limit GET POST OPTIONS>
385 # Order allow,deny
386 # Allow from all
387 # </Limit>
388 # <LimitExcept GET POST OPTIONS>
389 # Order deny,allow
390 # Deny from all
391 # </LimitExcept>
392 #</Directory>
- 変更後~
以下の変更を行いました。
+ userdir_moduleのロード(最初からコメントされていなかった...
+ UserDir disabled → #UserDir disabled
+ #UserDir public_html → UserDir public_html
+ <Directory /home/*/public_html> ... </Directory> のコメ...
187 LoadModule userdir_module modules/mod_userdir.so
<省略>
360 <IfModule mod_userdir.c>
361 #
362 # UserDir is disabled by default since it can...
363 # of a username on the system (depending on h...
364 # permissions).
365 #
366 #UserDir disabled
367
368 #
369 # To enable requests to /~user/ to serve the ...
370 # directory, remove the "UserDir disabled" li...
371 # the following line instead:
372 #
373 UserDir public_html
374
375 </IfModule>
<省略>
381 <Directory /home/*/public_html>
382 AllowOverride FileInfo AuthConfig Limit
383 Options MultiViews Indexes SymLinksIfOwnerMat...
384 <Limit GET POST OPTIONS>
385 Order allow,deny
386 Allow from all
387 </Limit>
388 <LimitExcept GET POST OPTIONS>
389 Order deny,allow
390 Deny from all
391 </LimitExcept>
392 </Directory>
変更が終了したらhttpd.confを保存しapache(httpd)を再起動し...
CentOSではrootユーザーにて以下のコマンドで再起動しました。
service httpd restart
上記コマンドを実行したときの出力です。
[root@centos6 ~]# service httpd restart
httpd を停止中: ...
httpd を起動中: ...
[root@centos6 ~]#
#br
* ユーザーのホームディレクトリにpublic_htmlを作成する [#a...
以下、ユーザー名 sakura で設定を行います。
+ sakura ユーザーでログインします。
+ public_htmlディレクトリを作成します。
mkdir ~/public_html
+ httpd(apache)プロセスがアクセスできるようにパーミッショ...
CentOSの設定を見たところ、以下のようになっていました。
[sakura@centos6 ~]$ cd ..
[sakura@centos6 home]$ ls -l
合計 8
drwx------. 30 sakura sakura 4096 2月 11 21:00 2013 s...
drwx------. 4 tsubaki tsubaki 4096 2月 11 21:03 2013 t...
ユーザー以外、アクセスができないので、以下のようにパーミ...
chmod o+r /home/sakura
以下、chmodによるアクセス権限変更および確認を記します。
[sakura@centos6 home]$ pwd
/home
[sakura@centos6 home]$ ls -ld sakura/
drwx------. 30 sakura sakura 4096 2月 11 21:00 2013 sak...
[sakura@centos6 home]$ chmod o+x sakura/
[sakura@centos6 home]$ ls -ld sakura/
drwx-----x. 29 sakura sakura 4096 2月 11 21:21 2013 sak...
その他にパーミッション(権限)に--xになりました。
上記操作で作成したpublic_htmlのパーミッションを確認すると...
[sakura@centos6 home]$ cd
[sakura@centos6 ~]$ ls -ld public_html/
drwxrwxr-x. 2 sakura sakura 4096 2月 11 21:02 2013 publ...
* public_htmlにindex.htmlを作成しブラウザからアクセスして...
作成したpublic_htmlディレクトリにindex.htmlを作成してみま...
[sakura@centos6 ~]$ cd public_html/
[sakura@centos6 public_html]$ echo '<b>Hello world!</b>'...
作成したindex.htmlのパーミッションを確認すると、その他にr...
[sakura@centos6 public_html]$ ls -l index.html
-rw-rw-r--. 1 sakura sakura 20 2月 11 21:14 2013 index....
* ブラウザを起動してアクセスしてみる [#e09f8b50]
今回使用したユーザー名はsakuraです。~
したがって、以下のようにすれば/home/sakura/public_html/の...
http://ホスト名/~sakura/
実際にアクセスしたときのスクリーンショットです。
#ref(01.gif)
以上、Apacheで一般ユーザーの$HOME/public_htmlを公開する設...
#htmlinsertpcsp(web-btm.html,web-sp.html)
ページ名: