Laravel项目启动问题求助:新手无法启动Blog项目
Hey there! I totally get the confusion when you're just starting out with Laravel—let's get your blog project up and running without any fuss. Here are the two easiest methods tailored to your XAMPP setup:
Method 1: Use Laravel's Built-in Development Server (Recommended for Beginners)
This is the simplest way because it bypasses any Apache configuration headaches:
- Open Command Prompt (CMD) on your Windows 10 machine.
- Navigate to your blog project's root directory using the
cdcommand. For example, if your project is inC:\xampp\htdocs\blog, run:cd C:\xampp\htdocs\blog - Once you're in the project folder, start the server with:
php artisan serve - You'll see a message like
Laravel development server started: http://127.0.0.1:8000in the terminal. Just copy that URL into your browser, and your blog should load right up!
Method 2: Configure XAMPP Apache to Access via localhost or a Custom Domain
If you prefer using XAMPP's Apache server directly, here's what you need to fix the localhost/blog issue:
Quick Fix (Temporary)
Laravel's entry point is always the public folder—so instead of localhost/blog, try visiting:
localhost/blog/public
This should work, but the URL will have /public in it, which isn't ideal long-term.
Permanent Fix: Set Up a Virtual Host (Cleaner URL)
This lets you use a custom domain like blog.test instead of messy paths:
- Open the XAMPP Apache virtual hosts file:
C:\xampp\apache\conf\extra\httpd-vhosts.conf - Add these lines at the end of the file (replace the path with your actual project's
publicfolder location):<VirtualHost *:80> DocumentRoot "C:\xampp\htdocs\blog\public" ServerName blog.test </VirtualHost> - Edit your Windows hosts file (requires admin rights):
- Go to
C:\Windows\System32\drivers\etc\hosts - Add this line at the bottom:
127.0.0.1 blog.test
- Go to
- Restart the Apache server from the XAMPP control panel.
- Now you can just type
blog.testin your browser to access your Laravel blog!
Quick Troubleshooting Check
If you run into issues with php artisan serve, make sure you've installed all the project dependencies. If there's no vendor folder in your project, run this in the project root:
composer install
内容的提问来源于stack exchange,提问作者giggiox

