在CentOS系统中配置Laravel路由,你需要遵循以下步骤:
composer global require laravel/installer
laravel new project-name
/etc/nginx/conf.d/
目录下),添加以下内容:server {
listen 80;
server_name example.com; # 替换为你的域名或公网IP
root /path/to/your/laravel/project/public; # 替换为你的Laravel项目的public目录路径
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
sudo systemctl restart nginx
routes/web.php
文件,编写你的路由规则。例如:Route::get('/', function () {
return 'Hello, World!';
});
Route::get('/about', function () {
return 'About page';
});
http://example.com
和http://example.com/about
来测试你的路由是否正常工作。以上就是在CentOS系统中配置Laravel路由的基本步骤。你可以根据自己的需求进一步自定义路由和中间件等设置。