回答編集履歴
6
修正
answer
CHANGED
@@ -135,7 +135,7 @@
|
|
135
135
|
Vagrant.configure("2") do |config|
|
136
136
|
config.vm.box = "ubuntu/trusty64"
|
137
137
|
config.vm.network "forwarded_port", guest: 80, host: 8080
|
138
|
-
config.vm.synced_folder "./
|
138
|
+
config.vm.synced_folder "./", "/var/www/html" # ←追記
|
139
139
|
end
|
140
140
|
```
|
141
141
|
|
@@ -145,6 +145,6 @@
|
|
145
145
|
vagrant reload --provision
|
146
146
|
```
|
147
147
|
|
148
|
-
すると
|
148
|
+
すると `Vagrantfile` が置かれているフォルダが仮想マシンの `/var/www/html` とシンクロするはずです。
|
149
149
|
|
150
150
|
[http://laraweb.net/environment/84/](http://laraweb.net/environment/84/)
|
5
追記3
answer
CHANGED
@@ -123,4 +123,28 @@
|
|
123
123
|
これでファイルが作成できました。
|
124
124
|
では、ブラウザから `localhost:8080/phptest/phpinfo.php` を見て下さい。
|
125
125
|
`PHP INFO` ページが確認できれば、後は自力でできそうではないですか?
|
126
|
-
如何でしょうか?
|
126
|
+
如何でしょうか?
|
127
|
+
|
128
|
+
# 追記3
|
129
|
+
> 自分で作成したファイルをphptestフォルダに入れたいのですがこれはどこにあるのでしょうか?
|
130
|
+
|
131
|
+
Macと仮想マシン間で **ストレージの同期** を行う必要があります。
|
132
|
+
|
133
|
+
`Vagrantfile` に `config.vm.synced_folder` を追記します。
|
134
|
+
```
|
135
|
+
Vagrant.configure("2") do |config|
|
136
|
+
config.vm.box = "ubuntu/trusty64"
|
137
|
+
config.vm.network "forwarded_port", guest: 80, host: 8080
|
138
|
+
config.vm.synced_folder "./html", "/var/www/html" # ←追記
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
仮想マシンを再起動して設定を反映。
|
143
|
+
|
144
|
+
```
|
145
|
+
vagrant reload --provision
|
146
|
+
```
|
147
|
+
|
148
|
+
するとMac上に `html` フォルダができて、中身が仮想マシンの `/var/www/html` とシンクロするはずです。
|
149
|
+
|
150
|
+
[http://laraweb.net/environment/84/](http://laraweb.net/environment/84/)
|
4
修正
answer
CHANGED
@@ -39,10 +39,10 @@
|
|
39
39
|
まずはここまで確認して下さい。
|
40
40
|
|
41
41
|
# 追記2
|
42
|
-
私の環境でもPHPを入れました。
|
42
|
+
私の仮想環境でもPHPを入れました。
|
43
43
|
|
44
44
|
```
|
45
|
-
sudo apt install -y php5 # とりあえずphp5を入れました
|
45
|
+
$ sudo apt install -y php5 # とりあえずphp5を入れました
|
46
46
|
```
|
47
47
|
|
48
48
|
apacheの設定ファイルは `/etc/apache2` 配下にあります。
|
@@ -111,7 +111,7 @@
|
|
111
111
|
これは危険な設定なので外部に公開する本番サーバではNGです。
|
112
112
|
|
113
113
|
```
|
114
|
-
sudo chmod 777 -R /var/www/html
|
114
|
+
$ sudo chmod 777 -R /var/www/html
|
115
115
|
```
|
116
116
|
|
117
117
|
`phpinfo.php` ファイルを作成します。
|
3
追記2
answer
CHANGED
@@ -36,4 +36,91 @@
|
|
36
36
|
```
|
37
37
|
|
38
38
|
`localhost:8080` をブラウザで見る→ `Apace2 Ubuntu Default Page` が表示される
|
39
|
-
まずはここまで確認して下さい。
|
39
|
+
まずはここまで確認して下さい。
|
40
|
+
|
41
|
+
# 追記2
|
42
|
+
私の環境でもPHPを入れました。
|
43
|
+
|
44
|
+
```
|
45
|
+
sudo apt install -y php5 # とりあえずphp5を入れました
|
46
|
+
```
|
47
|
+
|
48
|
+
apacheの設定ファイルは `/etc/apache2` 配下にあります。
|
49
|
+
今回チェックしないといけないのは `/etc/apache2/sites-enabled/000-default.conf` です。
|
50
|
+
見てみましょう。
|
51
|
+
|
52
|
+
```
|
53
|
+
$ cat /etc/apache2/sites-enabled/000-default.conf
|
54
|
+
<VirtualHost *:80>
|
55
|
+
# The ServerName directive sets the request scheme, hostname and port that
|
56
|
+
# the server uses to identify itself. This is used when creating
|
57
|
+
# redirection URLs. In the context of virtual hosts, the ServerName
|
58
|
+
# specifies what hostname must appear in the request's Host: header to
|
59
|
+
# match this virtual host. For the default virtual host (this file) this
|
60
|
+
# value is not decisive as it is used as a last resort host regardless.
|
61
|
+
# However, you must set it for any further virtual host explicitly.
|
62
|
+
#ServerName www.example.com
|
63
|
+
|
64
|
+
ServerAdmin webmaster@localhost
|
65
|
+
DocumentRoot /var/www/html
|
66
|
+
|
67
|
+
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
|
68
|
+
# error, crit, alert, emerg.
|
69
|
+
# It is also possible to configure the loglevel for particular
|
70
|
+
# modules, e.g.
|
71
|
+
#LogLevel info ssl:warn
|
72
|
+
|
73
|
+
ErrorLog ${APACHE_LOG_DIR}/error.log
|
74
|
+
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
75
|
+
|
76
|
+
# For most configuration files from conf-available/, which are
|
77
|
+
# enabled or disabled at a global level, it is possible to
|
78
|
+
# include a line for only one particular virtual host. For example the
|
79
|
+
# following line enables the CGI configuration for this host only
|
80
|
+
# after it has been globally disabled with "a2disconf".
|
81
|
+
#Include conf-available/serve-cgi-bin.conf
|
82
|
+
</VirtualHost>
|
83
|
+
```
|
84
|
+
|
85
|
+
ワーッと出てきてよく分からないと思いますが、見るべきは `DocumentRoot` という項目です。
|
86
|
+
|
87
|
+
```
|
88
|
+
DocumentRoot /var/www/html
|
89
|
+
```
|
90
|
+
|
91
|
+
`/var/www/html` とあります。
|
92
|
+
|
93
|
+
ここにファイルを置くとサーバが見てくれます。
|
94
|
+
すでにここには `index.html` があります。
|
95
|
+
先程の `Apace2 Ubuntu Default Page` を表示するhtmlファイルですね。
|
96
|
+
|
97
|
+
```
|
98
|
+
$ ls /var/www/html/index.html
|
99
|
+
index.html # ←Apace2 Ubuntu Default Page用のファイル
|
100
|
+
```
|
101
|
+
|
102
|
+
実際に動作確認してみます。
|
103
|
+
`/var/www/html` 下に `phptest` というフォルダを作ります。
|
104
|
+
この下にテストファイルを置きます。
|
105
|
+
|
106
|
+
```
|
107
|
+
$ sudo mkdir /var/www/html/phptest
|
108
|
+
```
|
109
|
+
|
110
|
+
で、テスト用のPHPファイルを作りますが、その前に `html` フォルダ以下の権限を緩めておきます。
|
111
|
+
これは危険な設定なので外部に公開する本番サーバではNGです。
|
112
|
+
|
113
|
+
```
|
114
|
+
sudo chmod 777 -R /var/www/html
|
115
|
+
```
|
116
|
+
|
117
|
+
`phpinfo.php` ファイルを作成します。
|
118
|
+
|
119
|
+
```
|
120
|
+
$ echo "<?php phpinfo();" > /var/www/html/phptest/phpinfo.php
|
121
|
+
```
|
122
|
+
|
123
|
+
これでファイルが作成できました。
|
124
|
+
では、ブラウザから `localhost:8080/phptest/phpinfo.php` を見て下さい。
|
125
|
+
`PHP INFO` ページが確認できれば、後は自力でできそうではないですか?
|
126
|
+
如何でしょうか?
|
2
修正
answer
CHANGED
@@ -30,9 +30,9 @@
|
|
30
30
|
```
|
31
31
|
$ sudo apt update -y
|
32
32
|
$ sudo apt install -y apache2
|
33
|
-
$ sudo apachectl
|
33
|
+
$ sudo apachectl status
|
34
34
|
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.2.15. Set the 'ServerName' directive globally to suppress this message
|
35
|
-
httpd (pid 2831) already running
|
35
|
+
httpd (pid 2831) already running # ←already runningが出ているかを確認しましょう
|
36
36
|
```
|
37
37
|
|
38
38
|
`localhost:8080` をブラウザで見る→ `Apace2 Ubuntu Default Page` が表示される
|
1
追記
answer
CHANGED
@@ -1,2 +1,39 @@
|
|
1
1
|
apacheは起動できているか?
|
2
|
-
apacheのdocument root設定は適切か?を確認する必要があります。
|
2
|
+
apacheのdocument root設定は適切か?を確認する必要があります。
|
3
|
+
|
4
|
+
# 追記
|
5
|
+
私の手元で試しました。
|
6
|
+
|
7
|
+
`Vagrantfile`
|
8
|
+
|
9
|
+
```
|
10
|
+
# -*- mode: ruby -*-
|
11
|
+
# vi: set ft=ruby :
|
12
|
+
|
13
|
+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
14
|
+
# configures the configuration version (we support older styles for
|
15
|
+
# backwards compatibility). Please don't change it unless you know what
|
16
|
+
# you're doing.
|
17
|
+
Vagrant.configure("2") do |config|
|
18
|
+
config.vm.box = "ubuntu/trusty64"
|
19
|
+
config.vm.network "forwarded_port", guest: 80, host: 8080
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
```
|
24
|
+
vagrant up
|
25
|
+
vagrant ssh
|
26
|
+
```
|
27
|
+
|
28
|
+
仮想マシンの中に入ったら、以下を順に実行。
|
29
|
+
|
30
|
+
```
|
31
|
+
$ sudo apt update -y
|
32
|
+
$ sudo apt install -y apache2
|
33
|
+
$ sudo apachectl start
|
34
|
+
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.2.15. Set the 'ServerName' directive globally to suppress this message
|
35
|
+
httpd (pid 2831) already running
|
36
|
+
```
|
37
|
+
|
38
|
+
`localhost:8080` をブラウザで見る→ `Apace2 Ubuntu Default Page` が表示される
|
39
|
+
まずはここまで確認して下さい。
|