「インストール - Laravel」の版間の差分

ナビゲーションに移動 検索に移動
64行目: 64行目:
Webブラウザにおいて、以下のURLを入力して、LaravelのWebサイトが表示されるかどうか確認する。<br>
Webブラウザにおいて、以下のURLを入力して、LaravelのWebサイトが表示されるかどうか確認する。<br>
http://localhost:8000<br>
http://localhost:8000<br>
<br><br>
== 外部から接続する場合 ==
外部のクライアントPCからLaravelに接続する場合、仮想ホストを構築する必要がある。<br>
/etc/apache2/vhosts.dディレクトリに、以下のようなファイルを作成する。<br>
sudo vi /etc/apache2/vhosts.d/vhost-laravel01.conf
<br>
# /etc/apache2/vhosts.d/vhost-laravel01.confファイル
# VirtualHost template
# Note: to use the template, rename it to /etc/apache2/vhost.d/yourvhost.conf.
# Files must have the .conf suffix to be loaded.
#
# See /usr/share/doc/packages/apache2/README.QUICKSTART for further hints
# about virtual hosts.
#
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
    ServerAdmin webmaster@laravel01
    ServerName laravel01
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /home/<ユーザ名>/htdocs/laravel01/public
    # if not specified, the global error log is used
    ErrorLog /home/<ユーザ名>/htdocs/log/laravel01-error_log
    CustomLog /home/<ユーザ名>/htdocs/log/laravel01-access_log combined
    # don't loose time with IP address lookups
    HostnameLookups Off
    # needed for named virtual hosts
    UseCanonicalName Off
    # configures the footer on server-generated documents
    ServerSignature On
    # Optionally, include *.conf files from /etc/apache2/conf.d/
    #
    # For example, to allow execution of PHP scripts:
    #
    # Include /etc/apache2/conf.d/php5.conf
    #
    # or, to include all configuration snippets added by packages:
    # Include /etc/apache2/conf.d/*.conf
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    ScriptAlias /cgi-bin/ "/home/<ユーザ名>/htdocs/cgi-bin/"
    # "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have one, and where ScriptAlias points to.
    #
    <Directory "/home/<ユーザ名>/htdocs/cgi-bin">
        AllowOverride None
        Options +ExecCGI -Includes
        AddHandler cgi-script .cgi .pl .py .sh
        <IfModule !mod_access_compat.c>
            Require all granted
        </IfModule>
        <IfModule mod_access_compat.c>
            Order allow,deny
            Allow from all
        </IfModule>
    </Directory>
    # UserDir: The name of the directory that is appended onto a user's home
    # directory if a ~user request is received.
    #
    # To disable it, simply remove userdir from the list of modules in APACHE_MODULES
    # in /etc/sysconfig/apache2.
    #
    <IfModule mod_userdir.c>
        # Note that the name of the user directory ("public_html") cannot simply be
        # changed here, since it is a compile time setting. The apache package
        # would have to be rebuilt. You could work around by deleting
        # /usr/sbin/suexec, but then all scripts from the directories would be
        # executed with the UID of the webserver.
        UserDir public_html
        # The actual configuration of the directory is in
        # /etc/apache2/mod_userdir.conf.
        Include /etc/apache2/mod_userdir.conf
        # You can, however, change the ~ if you find it awkward, by mapping e.g.
        # http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/
        #AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
    </IfModule>
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/home/<ユーザ名>/htdocs/laravel01/public">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #  Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #  Options FileInfo AuthConfig Limit
        #
        AllowOverride None
        #
        # Controls who can get stuff from this server.
        #
        <IfModule !mod_access_compat.c>
            Require all granted
        </IfModule>
        <IfModule mod_access_compat.c>
            Order allow,deny
            Allow from all
        </IfModule>
    </Directory>
</VirtualHost>
<br>
次に、Laravelのプロジェクトディレクトリに対して、ユーザ名とグループ名をApache2のものに変更する。<br>
<u>SUSEの場合、Apache2のユーザ名およびグループ名は、<code>wwwrun</code>である。</u><br>
sudo chmod -R 775 <Laravelのプロジェクトディレクトリ>  # 不要の可能性がある(要調査)
sudo chown -R wwwrun:wwwrun <Laravelのプロジェクトディレクトリ>
<br>
最後に、外部のクライアントPCの/etc/hostsファイルを、以下のように追記する。<br>
sudo vi /etc/hosts
<br>
# /etc/hostsファイル
<サーバのIPアドレス>    laravel01
<br><br>
<br><br>


__FORCETOC__
__FORCETOC__
[[カテゴリ:Web]]
[[カテゴリ:Web]]

案内メニュー