Я настраиваю Laravel на EC2. После установки начальных разрешений и групп, когда я попытался, я получил ошибку Forbidden . Журнал показывал следующие ошибки:
[Sun Oct 20 08:02:10.648091 2019] [autoindex:error] [pid 29325] [client 39.48.136.176:51852] AH01276: Cannot serve directory /var/www/html/my_project/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
[Sun Oct 20 08:03:03.010061 2019] [autoindex:error] [pid 29326] [client 54.163.75.130:53702] AH01276: Cannot serve directory /var/www/html/my_project/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
[Sun Oct 20 08:18:05.310327 2019] [mpm_prefork:notice] [pid 29321] AH00169: caught SIGTERM, shutting down
Информация PHP работала нормально, когда я помещал файл в var/www/html
, но все перепуталось, когда я клонировал папку Laravel, и он начал показывать код. После добавления DirectoryIndex index.html index.php
он начинает показывать код.
Ниже приведены различные conf сведения о файлах.
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/my_project/public/
<Directory "/var/www/html/my_project">
DirectoryIndex index.html index.php
AllowOverride All
Options FollowSymLinks
</Directory>
</VirtualHost>
Httpd.Conf запчасти:
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
#IncludeOptional conf.d/*.conf
Include /etc/httpd/conf/vhosts/example.conf
Я не знаю, что происходит не так. Я настроил предыдущий экземпляр AWS с PHP 7.1 и Apache, и у него не было таких проблем. Я сейчас с PHP 7.3
Содержание папки
drwxr-xr-x 13 ec2-user apache 4096 Oct 20 07:08 .
drwxr-xr-x 3 ec2-user root 4096 Oct 20 06:48 ..
-rw-rw-r-- 1 ec2-user apache 833 Oct 20 06:54 .env
-rw-rw-r-- 1 ec2-user apache 565 Oct 20 06:49 .env.example
drwxr-xr-x 8 ec2-user apache 4096 Oct 20 06:49 .git
-rw-rw-r-- 1 ec2-user apache 146 Oct 20 06:49 .gitignore
drwxr-xr-x 7 ec2-user apache 4096 Oct 20 06:49 app
-rw-rw-r-- 1 ec2-user apache 1686 Oct 20 06:49 artisan
drwxr-xr-x 3 ec2-user apache 4096 Oct 20 06:49 bootstrap
-rw-rw-r-- 1 ec2-user apache 1458 Oct 20 06:49 composer.json
-rw-rw-r-- 1 ec2-user apache 148119 Oct 20 06:49 composer.lock
drwxr-xr-x 2 ec2-user apache 4096 Oct 20 06:49 config
drwxr-xr-x 5 ec2-user apache 4096 Oct 20 06:49 database
-rw-rw-r-- 1 ec2-user apache 1125 Oct 20 06:49 package.json
-rw-rw-r-- 1 ec2-user apache 1040 Oct 20 06:49 phpunit.xml
drwxr-xr-x 5 ec2-user apache 4096 Oct 20 07:31 public
-rw-rw-r-- 1 ec2-user apache 55 Oct 20 06:49 readme.md
drwxr-xr-x 5 ec2-user apache 4096 Oct 20 06:49 resources
drwxr-xr-x 2 ec2-user apache 4096 Oct 20 06:49 routes
-rw-rw-r-- 1 ec2-user apache 563 Oct 20 06:49 server.php
drwxr-xr-x 6 ec2-user ec2-user 4096 Oct 20 06:49 storage
drwxr-xr-x 4 ec2-user apache 4096 Oct 20 06:49 tests
drwxr-xr-x 38 ec2-user apache 4096 Oct 20 07:08 vendor
-rw-rw-r-- 1 ec2-user apache 549 Oct 20 06:49 webpack.mix.js
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
~
ИсторияВывод команды
1 sudo yum update
2 exit
3 python
4 python3
5 clear
6 sudo yum search python3
7 sudo yum list | grep python3
8 sudo yum list | grep python36
9 sudo yum search python36 python36-pip
10 clear
11 sudo yum install python36 python36-pip
12 python3
13 clear
14
15 exit
16 ls
17 pwd
18 ls -l
19 vim requirements.txt
20 pip-3.6 install -r requirements.txt
21 pip-3.6 install numpy
22 sudo pip-3.6 install numpy
23 sudo pip-3.6 install -r requirements.txt
24 sudo pip-3.6 install mod-wsgi
25 vim requirements.txt
26 sudo pip-3.6 install -r requirements.txt
27 gcc
28 sudo yum update
29 sudo yum search gcc
30 clear
31 sudo yum -y install gcc
32 gcc
33 gcc --version
34 sudo pip-3.6 install -r requirements.txt
35 pip-3.6 install stellar-base
36 sudo pip-3.6 install stellar-base
37 clear
38 sudo yum groupinstall "Development Tools"
39 sudo pip-3.6 install stellar-base
40 yum search python-dev
41 yum search python3-dev
42 yum search python3 | grep dev
43 sudo yum install python36-dev
44 sudo yum install python36-devel
45 sudo pip-3.6 install stellar-base
46 pip-3.6 install --upgrade pip
47 sudo pip-3.6 install --upgrade pip
48 pip-3.6 --version
49 pip-3.6
50 sudo pip-3.6 install -r requirements.txt
51 sudo easy_install pip==9.0.3
52 pip3
53 pip-3.6
54 pip3
55 sudo pip3 install -r requirements.txt
56 pip3
57 sudo pip3 install -r requirements.txt
58 python3
59 python3 -m pip --version
60 yum
61 sudo yum reinstall python36-pip
62 pip-3.6
63 pip-3.6 check
64 pip-3.6 list
65 clear
66 sudo pip-3.6 install -r requirements.txt
67 clear
68 pip-3.6 freeze --local | xargs pip uninstall -y
69 sudo pip-3.6 freeze --local | xargs pip uninstall -y
70 pip-3.6 list
71 pip-3.6 uninstall certifi
72 sudo pip-3.6 uninstall certifi
73 clear
74 pip-3.6 list
75 pip-3.6 list | xargs pip uninstall -y
76 sudo pip-3.6 list | xargs pip uninstall -y
77 pip-3.6 list
78 sudo pip-3.6 list | xargs
79 sudo pip-3.6 list | xargs pip uninstall -y
80 sudo pip-3.6 list | xargs pip-3.6 uninstall -y
81 sudo pip-3.6 list
82 pip-3.6 uninstall chardet
83 pip-3.6 uninstall chardet -y
84 sudo pip-3.6 uninstall chardet -y
85 clear
86 sudo pip-3.6 uninstall chardet -y
87 sudo pip-3.6 uninstall Click -y
88 sudo pip-3.6 uninstall crc16 -y
89 sudo pip-3.6 uninstall ed25519 -y
90 sudo pip-3.6 uninstall chardet -y
91 sudo pip-3.6 uninstall Click -y
92 sudo pip-3.6 uninstall crc16 -y
93 sudo pip-3.6 uninstall ed25519 -y
94 sudo pip-3.6 uninstall Flask -y
95 sudo pip-3.6 uninstall idna -y
96 sudo pip-3.6 uninstall itsdangerous -y
97 sudo pip-3.6 uninstall Jinja2 -y
98 sudo pip-3.6 uninstall MarkupSafe -y
99 sudo pip-3.6 uninstall mnemonic -y
100 sudo pip-3.6 uninstall numpy -y
101 sudo pip-3.6 uninstall pbkdf2 -y
102 sudo pip-3.6 uninstall pip -y
103 sudo pip-3.6 uninstall PyMySQL -y
104 sudo pip-3.6 uninstall requests -y
105 sudo pip-3.6 uninstall setuptools -y
106 sudo pip-3.6 uninstall six -y
107 sudo pip-3.6 uninstall sseclient -y
108 sudo pip-3.6 uninstall stellar-base -y
109 sudo pip-3.6 uninstall toml -y
110 sudo pip-3.6 uninstall urllib3 -y
111 sudo pip-3.6 uninstall Werkzeug -y
112 sudo pip-3.6 uninstall xmltodict -y
113 sudo pip-3.6 uninstall chardet -y
114 pip-3.6 --version
115 sudo yum reinstall python36-pip
116 pip-3.6 --version
117 clear
118 sudo pip-3.6 uninstall chardet -y
119 sudo pip-3.6 uninstall Click -y
120 sudo pip-3.6 uninstall crc16 -y
121 sudo pip-3.6 uninstall ed25519 -y
122 sudo pip-3.6 uninstall Flask -y
123 sudo pip-3.6 uninstall idna -y
124 sudo pip-3.6 uninstall itsdangerous -y
125 sudo pip-3.6 uninstall Jinja2 -y
126 sudo pip-3.6 uninstall MarkupSafe -y
127 sudo pip-3.6 uninstall mnemonic -y
128 sudo pip-3.6 uninstall numpy -y
129 sudo pip-3.6 uninstall pbkdf2 -y
130 sudo pip-3.6 uninstall pip -y
131 sudo pip-3.6 uninstall PyMySQL -y
132 sudo pip-3.6 uninstall requests -y
133 sudo pip-3.6 uninstall setuptools -y
134 sudo pip-3.6 uninstall six -y
135 sudo pip-3.6 uninstall sseclient -y
136 sudo pip-3.6 uninstall stellar-base -y
137 sudo pip-3.6 uninstall toml -y
138 sudo pip-3.6 uninstall urllib3 -y
139 sudo pip-3.6 uninstall Werkzeug -y
140 sudo yum reinstall python36-pip
141 sudo pip-3.6 uninstall chardet -y
142 sudo pip-3.6 uninstall Click -y
143 sudo pip-3.6 uninstall crc16 -y
144 sudo pip-3.6 uninstall ed25519 -y
145 sudo pip-3.6 uninstall Flask -y
146 sudo pip-3.6 uninstall idna -y
147 sudo pip-3.6 uninstall itsdangerous -y
148 sudo pip-3.6 uninstall Jinja2 -y
149 sudo pip-3.6 uninstall MarkupSafe -y
150 sudo pip-3.6 uninstall mnemonic -y
151 sudo pip-3.6 uninstall numpy -y
152 sudo pip-3.6 uninstall pbkdf2 -y
153 sudo pip-3.6 uninstall PyMySQL -y
154 sudo pip-3.6 uninstall requests -y
155 sudo pip-3.6 uninstall setuptools -y
156 sudo pip-3.6 uninstall six -y
157 sudo pip-3.6 uninstall sseclient -y
158 sudo pip-3.6 uninstall stellar-base -y
159 sudo pip-3.6 uninstall toml -y
160 sudo pip-3.6 uninstall urllib3 -y
161 sudo pip-3.6 uninstall Werkzeug -y
162 sudo pip-3.6 uninstall xmltodict -y
163 ls
164 sudo pip-3.6 list
165 sudo yum reinstall python36-pip
166 sudo pip-3.6 install -r requirements.txt
167 sudo easy_install pkg_resources
168 python3
169 clear
170 sudo yum reinstall python36 python36-pip
171 sudo pip-3.6 install -r requirements.txt
172 pip-3.6 install requests
173 clear
174 sudo yum reinstall python36-setuptools -y
175 pip-3.6 install requests
176 pip-3.6 uninstall requests
177 pip-3.6 list
178 clear
179 sudo pip-3.6 uninstall chardet -y
180 sudo pip-3.6 uninstall Click -y
181 sudo pip-3.6 uninstall crc16 -y
182 sudo pip-3.6 uninstall ed25519 -y
183 sudo pip-3.6 uninstall Flask -y
184 sudo pip-3.6 uninstall idna -y
185 sudo pip-3.6 uninstall itsdangerous -y
186 sudo pip-3.6 uninstall Jinja2 -y
187 sudo pip-3.6 uninstall MarkupSafe -y
188 sudo pip-3.6 uninstall mnemonic -y
189 sudo pip-3.6 uninstall numpy -y
190 sudo pip-3.6 uninstall pbkdf2 -y
191 sudo pip-3.6 uninstall PyMySQL -y
192 sudo pip-3.6 uninstall requests -y
193 sudo pip-3.6 uninstall six -y
194 sudo pip-3.6 uninstall sseclient -y
195 sudo pip-3.6 uninstall stellar-base -y
196 sudo pip-3.6 uninstall toml -y
197 sudo pip-3.6 uninstall urllib3 -y
198 sudo pip-3.6 uninstall Werkzeug -y
199 sudo pip-3.6 uninstall xmltodict -y
200 pip-3.6 list
201 sudo pip-3.6 install --upgrade pip
202 sudo pip-3.6 install requests -y
203 pip-3.6 list
204 sudo yum reinstall python36-setuptools -y
205 sudo yum install python36 python36-pip
206 sudo yum reinstall python36 python36-pip
207 pip-3.6 list
208 sudo pip-3.6 uninstall setuptools -y
209 sudo pip-3.6 install --upgrade pip
210 sudo pip-3.6 install setuptools -y
211 sudo yum reinstall python36-setuptools
212 pip-3.6
213 clear
214 sudo pip-3.6 install -r requirements.txt
215 clear
216 pip-3.6 list
217 clear
218 sudo service httpd start
219 php
220 sudo yum update -y
221 locale
222 ls -l /etc/profile.d/lang.sh
223 source /etc/profile.d/lang.sh
224 echo "$LANG"
225 echo "$LC_CTYPE"
226 sudo yum update
227 vi ~/.bashrc
228 clear
229 sudo vim /etc/profile.d/my-custom.lang.sh
230 source /etc/profile.d/my-custom.lang.sh
231 sudo yum update
232 exit
233 vim /etc/bashrc
234 clear
235 sudo yum reinstall glibc-common
236 exit
237 python3
238 clear
239 sudo yum search httpd2
240 clear
241 sudo yum install -y httpd24
242 sudo yum search php5
243 sudo yum search php7
244 exit
245 sudo yum install -y httpd24
246 sudo yum search php7
247 sudo yum install php73
248 sudo yum search php73 | grep nd
249 sudo yum install php73-mysqlnd
250 sudo yum search mysql
251 sudo yum search mysql57 | grep server
252 sudo yum install mysql57-server
253 clear
254 cat /etc/system-release
255 sudo service httpd start
256 sudo chkconfig httpd on
257 hkconfig --list httpd
258 chkconfig --list httpd
259 php
260 php-cli
261 cd /var/www/html/
262 ls
263 vim info.php
264 ls
265 sudo vim info.php
266 ls
267 sudo rm info.php
268 cd ..
269 clear
270 pwd
271 cd ..
272 whoami
273 chown -R ec2-user /var/www/html
274 sudo chown -R ec2-user /var/www/html
275 chmod -R 755 /var/www/html
276 cd www/html/
277 ls
278 vim info.php
279 ls
280 docker
281 exit
282 sudo yum update
283 ls
284 pwd
285 cd /var/www/html/
286 ls
287 vim info.php
288 python
289 python3
290 which python3
291 pip3
292 pip3 search stellar
293 pip3 search stellar | grep stellar
294 pip3 install -U stellar-sdk
295 sudo pip3 install -U stellar-sdk
296 pip3 install -U stellar-sdk
297 sudo
298 sudo pip3
299 which pip3
300 python3 -m pip install -U stellar-sdk
301 sudo python3 -m pip install -U stellar-sdk
302 pip3 install --upgrade pip
303 sudo pip3 install --upgrade pip
304 pip3 install xmltodict
305 pip3 install pymysql
306 exit
307 mysql -u
308 mysql -u root
309 ps
310 ps aux
311 ps aux | grep mysql
312 mysqld
313 mysql -V
314 clea
315 clear
316 mysql -V
317 ps aux | grep mysqld
318 chkconfig mysql on
319 service mysql start
320 mysql -u slv_user -p
321 sudo service mysqld restart
322 mysql -u ec2-user -p
323 sudo mysql_secure_installation
324 mysql -u root
325 mysql -u root -p captur3d
326 mysql -u root -p
327 cler
328 clear
329 mysql -u slv_user -p
330 pwd
331 ls
332 mysql -u slv_user -p slv_db < slv_web.sql
333 mysql -u slv_user -
334 mysql -u slv_user -p
335 php --version
336 ls
337 pwd
338 git
339 cd /var/www/html/
340 ls
341 clear
342 pwd
343 git clone git clone https://adnan@bitbucket.org/adnan/myproject_web.git
344 git clone https://adnan@bitbucket.org/adnan/myproject_web.git
345 ls
346 cd myproject_web/
347 ls
348 vim .env
349 sudo service httpd restart
350 ls
351 composer
352 cd ../../
353 ls
354 cd ~
355 ls
356 pwd
357 curl -sS https://getcomposer.org/installer | php
358 mv composer.phar /usr/local/bin/composer
359 sudo mv composer.phar /usr/local/bin/composer
360 composer
361 cd /var/www/html/myproject_web/
362 composer install
363 sudo vim /etc/php.ini
364 ls /usr/lib64/php/7.3/modules
365 ls -l /usr/lib64/php/7.3/modules
366 yum
367 yum search php-mbstring
368 yum search mbstring
369 sudo yum install php-mbstring
370 yum search php70-mbstring
371 yum search php73-mbstring
372 yum install php73-mbstring
373 sudo yum install php73-mbstring
374 sudo service httpd restart
375 composer install
376 ls
377 vim /etc/httpd/conf/httpd.conf
378 cd /etc/httpd/conf
379 ls
380 mkdir vhosts
381 sudo mkdir vhosts
382 ls -l
383 vim myproject.conf
384 cd vhosts/
385 ls
386 vim myproject.conf
387 sudo vim myproject.conf
388 pwd
389 ls
390 cd ..
391 ls
392 vim httpd.conf
393 sudo vim httpd.conf
394 sudo service httpd restart
395 cd /var/www/html/myproject_web/public/
396 ls
397 clear
398 ls -l
399 vim web.config
400 vim .htaccess
401 ls -la
402 cd ..
403 ls
404 clear
405 sudo chmod -R 777 storage bootstrap/cache
406 sudo service apache2 restart
407 sudo service httpd restart
408 ls -l
409 cd ..
410 ls
411 sudo chown -R ec2-user:apache myproject_web/
412 ls -l
413 ls -la
414 cd myproject_web/
415 ls -la
416 sudo service httpd restart
417 clear
418 cd ..
419 clear
420 ls -l
421 clear
422 ps aux | egrep '(apache|httpd)'
423 ls
424 cd myproject_web/
425 pwd
426 cd ..
427 sudo find /var/www/html/myproject_web -type d -exec chmod 755 {} \;
428 sudo find /var/www/html/myproject_web -type f -exec chmod 644 {} \;
429 sudo service httpd restart
430 cd myproject_web/
431 ls -l
432 sudo chmod -R storage/ bootstrap/cache/
433 sudo chmod -R ug+rwx storage/ bootstrap/cache/
434 ls -l
435 sudo service httpd restart
436 cd ..
437 clear
438 sudo find /var/www/html/myproject_web -type f -exec chmod 664 {} \;
439 sudo find /var/www/html/myproject_web -type d -exec chmod 755 {} \;
440 sudo service httpd restart
441 cd /etc/httpd/
442 ls
443 cd logs/
444 ls
445 sudo cd logs/
446 ls
447 ls -l
448 pwd
449 vim logs/
450 cd logs/
451 cd /var/log/httpd/
452 cd /var/www/html/myproject_web/
453 ls -l
454 sudo chgrp -R ec2-user:apache storage bootstrap/cache
455 whoami
456 groups
457 sudo chgrp -R www-data storage bootstrap/cache
458 sudo chgrp -R ec2-user storage bootstrap/cache
459 ls -l
460 sudo service httpd restart
461 cd /var/log
462 ls
463 cd httpd/
464 ls
465 clear
466 ls -l
467 cd httpd/
468 ls
469 sudo httpd/
470 cd /usr/local/apache/logs
471 vim /var/log/httpd/access_log
472 sudo vim /var/log/httpd/access_log
473 sudo vim /var/log/httpd/error_log
474 cd /var/www/html/myproject_web/public/
475 ls
476*
477 sudo vim /var/log/httpd/error_log
478 vim /etc/httpd/conf/vhosts/myproject.conf
479 sudo vim /etc/httpd/conf/vhosts/myproject.conf
480 sudo service httpd restart
481 a2enmod
482 cd ..
483 sudo vim /var/log/httpd/error_log
484 sudo vim /etc/httpd/conf/vhosts/myproject.conf
485 sudo vim /etc/httpd/conf/httpd.conf
486 sudo vim /etc/httpd/conf/vhosts/myproject.conf
487 sudo service httpd restart
488 locate apache2.conf
489 sudo vim /etc/httpd/conf/vhosts/myproject.conf
490 sudo service httpd restart
491 ls
492 ls -la
493 cd public/
494 vim .htaccess
495 clear
496 history
497 cd ..
498 clear
499 c ..
500 cd ..
501 history > history_for_print.txt
Обновление
Я использую Centos в AWS, и похоже, что Apache изменил способ загрузки модулей. Следовательно, вместо LoadModule
теперь запрашивается загрузка различных conf
файлов в /etc/httpd/conf.modules.d
. Я не смог найти файл, в котором я мог бы включить ModReWrite.
Обновление # 2
Только что проверил, что Modrewrite включен, запустив httpd -M | grep 'rewrite'