ฉันรู้ว่ามีโพสต์ที่คล้ายกันมากมาย แต่หลังจากค้นคว้ามา 3 ชั่วโมงแล้ว ฉันก็ยังหาวิธีแก้ปัญหาไม่ได้ หวังว่าใครสามารถช่วยได้
เทคโนโลยีที่ใช้:
- อาปาเช่/2.4.7 (อูบุนตู)
- ลาราเวล 5.4
- PHP 7.0
/etc/apache2/site-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
Servername example.com
DocumentRoot /var/www/html/example.com
<Directory />
Options +FollowSymLinks
#AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/example.com/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/html/example.com/parcgilley/public">
Options Includes Indexes FollowSymLinks
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI +MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
.......
ดังนั้นรูทเอกสารจึงอยู่ที่ /var/www/html/example.com และไซต์ laravel ของฉันอยู่ที่ /var/www/html/example.com/parcgilley ฉันพยายามกำหนดค่า 000-default.conf ให้ชี้ไซต์ของฉันไปที่ /var/www/html/example.com/parcgilley/public แต่เมื่อฉันไปที่ example.com/parcgilley มันแสดง "Index of /parcgilley" และเมื่อฉันไปที่ http://www.example.com/parcgilley/public/ , Chrome แสดงว่า "หน้านี้ใช้งานไม่ได้"
นี่คือไฟล์ public/.htaccess ของฉัน:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
นี่ไม่ใช่เนื้อหาต้นฉบับ ฉันทำตามคำแนะนำจาก Laravel ดังนั้นฉันจึงแทนที่ต้นฉบับด้วยโค้ดด้านบน .
นอกจากนี้ ฉันได้ตั้งค่าการอนุญาตสำหรับโฟลเดอร์รูทของโปรเจ็กต์ /parcgilley และโฟลเดอร์ที่เก็บข้อมูล แต่ก็ไม่มีประโยชน์
ฉันไม่รู้ว่าต้องสร้างไฟล์ .htaccess เพื่อให้ชี้ไปที่โฟลเดอร์ /public หรือไม่ แต่ฉันไม่ค่อยมีความรู้เกี่ยวกับการกำหนดค่า apache มากนัก
ข้อมูลเชิงลึกใด ๆ ที่จะได้รับการชื่นชม
แก้ไข:
นอกจากนี้ ฉันยังใช้ SSH และ Git เพื่อส่งเว็บไซต์จากเครื่องท้องถิ่นของฉันไปยังเซิร์ฟเวอร์ โดยมี repo เปล่าอยู่ที่ /var/repo/site.git ฉันไม่รู้ว่าเกี่ยวข้องกับปัญหาหรือไม่