How to Install Laravel on CentOS Stream 10
Laravel is a web application framework with expressive, elegant syntax. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching.
Update System Packages
dnf update -y
Output
[root@vps ~]# dnf update -y
CentOS Stream 10 - BaseOS 6.4 MB/s | 6.3 MB 00:00
CentOS Stream 10 - AppStream 1.4 MB/s | 2.7 MB 00:01
CentOS Stream 10 - Extras packages 8.7 kB/s | 3.8 kB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing:
kernel x86_64 6.12.0-54.el10 baseos 324 k
Upgrading:
amd-gpu-firmware noarch 20250212-13.el10 appstream 27 M
amd-ucode-firmware noarch 20250212-13.el10 baseos 307 k
atheros-firmware noarch 20250212-13.el10 baseos 37 M
brcmfmac-firmware noarch 20250212-13.el10 baseos 9.6 M
centos-gpg-keys noarch 10.0-7.el10 baseos 14 k
centos-stream-release noarch 10.0-7.el10 baseos 29 k
centos-stream-repos noarch 10.0-7.el10 baseos 12 k
cirrus-audio-firmware noarch 20250212-13.el10 baseos 1.7 M
crypto-policies noarch 20250214-1.gitfd9b9b9.el10 baseos 98 k
crypto-policies-scripts noarch 20250214-1.gitfd9b9b9.el10 baseos 129 k
dnf noarch 4.20.0-11.el10 baseos 478 k
dnf-data noarch 4.20.0-11.el10 baseos 42 k
Install Required Dependencies
dnf install -y curl wget unzip git vim
Output
[root@vps ~]# dnf install -y curl wget unzip git vim
Last metadata expiration check: 0:24:45 ago on Sat 22 Feb 2025 12:29:20 PM UTC.
Package curl-8.9.1-5.el10.x86_64 is already installed.
Package wget-1.24.5-5.el10.x86_64 is already installed.
Package unzip-6.0-66.el10.x86_64 is already installed.
Package git-2.47.1-1.el10.x86_64 is already installed.
Package vim-enhanced-2:9.1.083-5.el10.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Install PHP and Required Extensions
Laravel requires PHP 8.1 or later. Install PHP and required extensions:
# Install EPEL repository
dnf install -y epel-release
# Enable CodeReady Builder repository
dnf config-manager --set-enabled crb
# Install Remi repository for PHP
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
# Reset and enable PHP 8.4 from Remi repository
dnf module reset php
dnf module enable php:remi-8.4
# Install PHP and required extensions
dnf install -y php php-fpm php-mysqlnd php-gd php-mbstring php-xml php-json php-curl php-zip
# Enable and start PHP-FPM service
systemctl enable --now php-fpm
Verify PHP installation:
php -v
Output
[root@vps ~]# php -v
PHP 8.4.4 (cli) (built: Feb 11 2025 15:36:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Zend Engine v4.4.4, Copyright (c) Zend Technologies
with Zend OPcache v8.4.4, Copyright (c), by Zend Technologies
Install Composer
Composer is required to install Laravel:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
Output
[root@vps ~]# curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
All settings correct for using Composer
Downloading...
Composer (version 2.8.5) successfully installed to: /root/composer.phar
Use it: php composer.phar
Verify Composer installation:
composer -V
Output
[root@vps ~]# composer -V
Composer version 2.8.5 2025-01-21 15:23:40
PHP version 8.4.4 (/usr/bin/php)
Run the "diagnose" command to get more detailed diagnostics output.
Install Apache and Start the Service
sudo dnf install -y httpd
sudo systemctl enable --now httpd
Output
[root@vps ~]# sudo dnf install -y httpd
sudo systemctl enable --now httpd
Last metadata expiration check: 0:34:07 ago on Sat 22 Feb 2025 12:29:20 PM UTC.
Package httpd-2.4.63-1.el10.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Allow HTTP traffic through the firewall:
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Output
[root@vps ~]# firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Warning: ALREADY_ENABLED: http
success
success
Install MySQL Server
dnf install -y mysql-server
systemctl enable --now mysqld
systemctl start --noe mysqld
Output
[root@vps ~]# dnf install -y mysql-server
sudo systemctl enable --now mysqld
Last metadata expiration check: 0:36:13 ago on Sat 22 Feb 2025 12:29:20 PM UTC.
Package mysql-server-8.4.2-5.el10.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Secure MySQL installation:
sudo mysql_secure_installation
Create a Laravel Project
Navigate to the web root directory and install Laravel:
cd /var/www/html
composer create-project --prefer-dist laravel/laravel myapp
Output
[root@vps html]# composer create-project --prefer-dist laravel/laravel myapp
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Creating a "laravel/laravel" project at "./myapp"
In CreateProjectCommand.php line 369:
Project directory "/var/www/html/myapp" is not empty.
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]
Set Permissions
chown -R apache:apache /var/www/html/myapp
chmod -R 775 /var/www/html/myapp/storage /var/www/html/myapp/bootstrap/cache
If permission issues persist, use:
chmod -R 777 /var/www/html/myapp/storage /var/www/html/myapp/bootstrap/cache
Configure Apache for Laravel
Create a new Virtual Host configuration:
vi /etc/httpd/conf.d/laravel.conf
Add the following configuration:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/myapp/public
<Directory /var/www/html/myapp>
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/laravel_error.log
CustomLog /var/log/httpd/laravel_access.log combined
</VirtualHost>
Note: Replace yourdomain.com with actual domain name Save and exit, then restart Apache:
systemctl restart httpd
Configure SELinux (If Enabled)
Check SELinux status:
sestatus
Output
[root@vps html]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 33
If it is enabled, allow HTTPD to modify files:
setsebool -P httpd_unified 1
setsebool -P httpd_execmem 1
Temporarily disable SELinux (for testing):
setenforce 0
Clear Cache and Migrate Database
cd /var/www/html/myapp
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
php artisan migrate
Output
[root@vps html]# cd /var/www/html/myapp
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
php artisan migrate
INFO Application cache cleared successfully.
INFO Configuration cache cleared successfully.
INFO Compiled views cleared successfully.
INFO Route cache cleared successfully.
INFO Nothing to migrate.
Access Laravel Application
Visit your server's IP or domain in a browser:
http://your-server-ip
Note: Replace your-server-ip with the actual IP address of you server
You should see the Laravel welcome page.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS