The following Laravel install and setup instructions are derived from the community forum thread. This guide covers proper installation and Nginx vhost configuration for Centmin Mod. For further Laravel usage beyond installation, refer to the official Laravel documentation.
Prerequisites
Follow the Getting Started guide, particularly steps 1 and 2, to create a new Nginx vhost via centmin.sh menu option 2.
Create Nginx Vhost
Use centmin.sh menu option 2 to create a domain (e.g., newdomain1.com). This generates:
- Vhost config:
/usr/local/nginx/conf/conf.d/newdomain1.com.conf - Web root:
/home/nginx/domains/newdomain1.com/public - Log directory:
/home/nginx/domains/newdomain1.com/log
Disable CLI Caches
Disable apc.enable_cli if you use APC Cache:
sed -i 's/apc.enable_cli=1/apc.enable_cli=0/' /etc/centminmod/php.d/apc.ini
fpmrestart
php -i | grep apc.enable_cli
Disable Zend OPcache CLI if enabled (usually disabled by default):
sed -i 's/opcache.enable_cli=1/opcache.enable_cli=0/' /etc/centminmod/php.d/zendopcache.ini
fpmrestart
php -i | grep opcache.enable_cli
Install Composer Globally
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Verify Composer is working:
composer --help
Create Laravel Project
Use Composer's create-project command. Change to the top-level directory of your vhost, then create the project:
cd /home/nginx/domains/newdomain1.com
composer create-project laravel/laravel myprojectname --prefer-dist
Your Laravel project ends up at /home/nginx/domains/newdomain1.com/myprojectname.
Set Permissions
chown -R nginx:nginx /home/nginx/domains/newdomain1.com/myprojectname
chmod -R 0770 /home/nginx/domains/newdomain1.com/myprojectname/storage
Verify the installed Laravel version:
cd /home/nginx/domains/newdomain1.com/myprojectname
php artisan -V
Configure open_basedir
For Centmin Mod .08 beta and higher, edit /usr/local/nginx/conf/php.conf (use shortcut phpinc) and comment out the open_basedir line to allow Laravel to access project files:
#fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;
If you use Centmin Mod .07 stable, you can skip commenting out the open_basedir line.
Nginx Vhost Configuration for Laravel
Edit the vhost config at /usr/local/nginx/conf/conf.d/newdomain1.com.conf. The key changes are the custom root path pointing to Laravel's public directory and the try_files directive:
server {
server_name newdomain1.com www.newdomain1.com;
access_log /home/nginx/domains/newdomain1.com/log/access.log combined buffer=256k flush=5m;
error_log /home/nginx/domains/newdomain1.com/log/error.log;
root /home/nginx/domains/newdomain1.com/myprojectname/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
include /usr/local/nginx/conf/staticfiles.conf;
include /usr/local/nginx/conf/php.conf;
include /usr/local/nginx/conf/drop.conf;
#include /usr/local/nginx/conf/errorpage.conf;
include /usr/local/nginx/conf/vts_server.conf;
}
The root directive must point to Laravel's public subdirectory, not the project root.
Restart Services
Restart both Nginx and PHP-FPM using the command shortcut:
nprestart
Or restart individually: ngxrestart for Nginx, fpmrestart for PHP-FPM.
Open newdomain1.com in your browser to see the Laravel default placeholder page.