Install Laravel PHP framework on AlmaLinux 10 in about 15 minutes and finish with a Laravel 13 application served by Apache and PHP-FPM. You will also create a dedicated MariaDB account, keep SELinux enforcing, and allow only web traffic through the firewall.
AlmaLinux 10 ships PHP 8.3, which meets Laravel 13’s minimum PHP requirement. The commands below use the distribution’s packages and the official Composer installer, so you do not need an outdated PHP repository or a development-only artisan serve process.
Prerequisites
- A fresh 64-bit AlmaLinux 10 VPS with at least 2 GB of RAM and 15 GB of free disk space.
- SSH access as
root, or a user with workingsudoprivileges and outbound HTTPS access. - A public IPv4 address. A domain is optional for the first HTTP test, but required for a trusted TLS certificate.
- A VPSLake Linux VPS if you need an AlmaLinux server with root access.
The commands use sudo for a non-root account. If you are logged in as root, remove sudo from each command. Replace every placeholder written in uppercase before running the related command.
Step 1: Confirm AlmaLinux 10 and update the server
Confirming the release first prevents an EL9 repository or service instruction from being mixed into an EL10 installation.
grep -E '^(PRETTY_NAME|VERSION_ID|ID_LIKE)=' /etc/os-release
uname -m
sudo dnf upgrade -y
The release should identify AlmaLinux 10 and the architecture should normally be x86_64. The minor version and kernel text will change as updates are published.
PRETTY_NAME="AlmaLinux 10.x (Purple Lion)"
VERSION_ID="10.x"
x86_64
If DNF installs a new kernel, keep this SSH session open until you have confirmed that the VPS can reboot and reconnect.
Step 2: Install PHP, Apache, MariaDB, and Composer
These packages provide the web server, PHP runtime, FastCGI process manager, database server, and PHP extensions Laravel needs.
sudo dnf install -y httpd mariadb-server mariadb php php-cli php-fpm php-pdo php-mysqlnd php-mbstring php-xml php-bcmath php-curl php-gd php-opcache php-pecl-zip unzip git policycoreutils-python-utils firewalld
sudo systemctl enable --now httpd php-fpm mariadb firewalld
php -v
sudo systemctl is-active httpd php-fpm mariadb firewalld
AlmaLinux 10’s base repositories provide PHP 8.3. The service check should print active for all four services.
PHP 8.3.x (cli) ...
active
active
active
active
Install Composer using the checksum published by Composer instead of piping an unverified installer into PHP. The Composer installation documentation explains the same system-wide PHAR layout.
cd /tmp
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then echo 'ERROR: Invalid Composer installer checksum'; rm -f composer-setup.php; exit 1; fi
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
rm -f composer-setup.php
composer --version
The final command should report Composer 2.x. Its patch number changes independently of AlmaLinux.
Step 3: Create a protected MariaDB database
Laravel should use a separate local database account rather than the MariaDB administrative account.
sudo mariadb-secure-installation
Keep Unix-socket authentication for the database administrator, remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables when prompted. Then replace YOUR_DB_PASSWORD with a long, unique password and create the application database:
sudo mariadb <<'SQL'
CREATE DATABASE laravel_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD';
GRANT ALL PRIVILEGES ON laravel_db.* TO 'laravel_user'@'localhost';
FLUSH PRIVILEGES;
SQL
sudo mariadb -e "SHOW DATABASES LIKE 'laravel_db';"
The last command should return laravel_db. Do not open port 3306 in firewalld; the web application and MariaDB are on the same VPS.
Step 4: Create the Laravel application
Running Composer as the apache user lets the first install create its cache and application files without leaving a root-owned Composer cache behind.
sudo install -d -o apache -g apache /var/www/laravelapp /usr/share/httpd/.cache /usr/share/httpd/.config
sudo -u apache -H composer create-project --no-interaction laravel/laravel /var/www/laravelapp
The create-project command installs the current Laravel release compatible with PHP 8.3. Laravel’s deployment documentation requires PHP 8.3 or newer and says that the web root must be the application’s public directory.
Open the generated environment file:
sudoedit /var/www/laravelapp/.env
Set these values in the file and replace YOUR_DOMAIN and YOUR_DB_PASSWORD with your own values. Leave the generated APP_KEY line in place.
APP_ENV=production
APP_DEBUG=false
APP_URL=http://YOUR_DOMAIN
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
DB_PASSWORD=YOUR_DB_PASSWORD
Save the file, then set the encryption key for this new application and apply the initial schema:
sudo -u apache -H php /var/www/laravelapp/artisan key:generate --force
sudo -u apache -H php /var/www/laravelapp/artisan config:clear
sudo -u apache -H php /var/www/laravelapp/artisan migrate --force
Successful migrations end with lines such as DONE or Ran, followed by a list of created tables. Do not run db:seed unless your own application includes seed data you intend to load.
Step 5: Point Apache at Laravel’s public directory
Apache must expose only public; serving the project root could disclose .env, Composer files, and other private application data.
Create a name-based virtual host. Replace both occurrences of YOUR_DOMAIN before saving the file.
sudo tee /etc/httpd/conf.d/laravel.conf > /dev/null <<'APACHE'
<VirtualHost *:80>
ServerName YOUR_DOMAIN
ServerAlias www.YOUR_DOMAIN
DocumentRoot /var/www/laravelapp/public
<Directory /var/www/laravelapp/public>
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
ErrorLog /var/log/httpd/laravel-error.log
CustomLog /var/log/httpd/laravel-access.log combined
</VirtualHost>
APACHE
sudo apachectl configtest
sudo systemctl reload httpd
Syntax OK confirms that Apache accepted the virtual host. The php-fpm package supplies the PHP handler used by Apache on AlmaLinux 10.
Step 6: Apply SELinux labels and firewall rules
SELinux can remain enforcing: label Laravel’s two writable directories explicitly, allow Apache’s database connection, and expose only HTTP and HTTPS.
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/laravelapp/(storage|bootstrap/cache)(/.*)?'
sudo restorecon -Rv /var/www/laravelapp
sudo chown -R root:apache /var/www/laravelapp
sudo find /var/www/laravelapp -type d -exec chmod 0750 {} +
sudo find /var/www/laravelapp -type f -exec chmod 0640 {} +
sudo chown -R apache:apache /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache
sudo find /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache -type d -exec chmod 0770 {} +
sudo find /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache -type f -exec chmod 0660 {} +
sudo setsebool -P httpd_can_network_connect_db on
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
sudo systemctl restart php-fpm httpd
storage and bootstrap/cache need write access for logs, compiled views, and framework caches. Red Hat’s SELinux guidance recommends a persistent httpd_can_network_connect_db boolean when Apache must reach MariaDB.
Verify the Laravel installation
Run the checks below. The host header lets you test the virtual host before DNS is changed; replace YOUR_DOMAIN with the same name used in laravel.conf.
sudo systemctl is-active httpd php-fpm mariadb
sudo apachectl configtest
sudo -u apache -H php /var/www/laravelapp/artisan --version
sudo -u apache -H php /var/www/laravelapp/artisan migrate:status
curl -fsSI -H 'Host: YOUR_DOMAIN' http://127.0.0.1/
You should see active services, Syntax OK, a Laravel version, migration statuses, and an HTTP success response.
active
active
active
Syntax OK
Laravel Framework 13.x
HTTP/1.1 200 OK
After your DNS A record points to the VPS, open http://YOUR_DOMAIN in a browser. The default Laravel page confirms that Apache is serving the correct public directory and PHP-FPM is executing the application.
Troubleshooting
Your requirements could not be resolved during Composer install
Laravel 13 requires PHP 8.3 or newer. Check that the command-line PHP is the AlmaLinux 10 package and that the required extensions are loaded; do not mix EL9 PHP repositories into this server.
php -v
php -m | grep -E 'bcmath|ctype|curl|dom|fileinfo|mbstring|openssl|PDO|tokenizer|xml'
sudo dnf clean all
sudo dnf makecache
If PHP is older than 8.3, stop and correct the enabled AlmaLinux 10 package stream before rerunning Composer.
SQLSTATE[HY000] [1045] Access denied
The values in .env do not match the MariaDB account, or Laravel is still using cached configuration. Test the account directly, then clear the application cache after correcting the password.
mariadb -u laravel_user -p laravel_db -e 'SELECT 1;'
sudo -u apache -H php /var/www/laravelapp/artisan config:clear
sudo -u apache -H php /var/www/laravelapp/artisan migrate --force
Enter the real database password at the prompt. A result containing 1 proves that the database account works independently of Laravel.
403 Forbidden or Permission denied for the application
Apache may have a stale ownership or SELinux label after files were copied into the project. Restore the labels and permissions without disabling SELinux.
sudo restorecon -Rv /var/www/laravelapp
sudo chown -R root:apache /var/www/laravelapp
sudo find /var/www/laravelapp -type d -exec chmod 0750 {} +
sudo find /var/www/laravelapp -type f -exec chmod 0640 {} +
sudo chown -R apache:apache /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache
sudo find /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache -type d -exec chmod 0770 {} +
sudo find /var/www/laravelapp/storage /var/www/laravelapp/bootstrap/cache -type f -exec chmod 0660 {} +
sudo systemctl reload httpd
If the error remains, inspect recent AVC denials with sudo ausearch -m AVC -ts recent and correct the reported path rather than using chmod 777.
503 Service Unavailable or PHP source appears in the browser
PHP-FPM is stopped, or Apache has not loaded the packaged PHP handler. Check both services and Apache’s configuration before restarting them.
sudo systemctl status php-fpm --no-pager
sudo journalctl -u php-fpm -n 40 --no-pager
sudo apachectl configtest
sudo systemctl restart php-fpm httpd
The service should be active (running) and apachectl configtest should return Syntax OK.
Hardening
- Point DNS to the VPS, issue a trusted TLS certificate, and change
APP_URLtohttps://YOUR_DOMAINbefore accepting logins or other sensitive data. - Keep
APP_DEBUG=falsein production and runphp artisan config:cacheonly after.envcontains the final values. - Leave MariaDB port 3306 closed. The local application can reach the database without making it public.
- Back up
/var/www/laravelappand the MariaDB database before upgrades, and apply AlmaLinux security updates regularly.
FAQ
Which PHP version does Laravel 13 need?
Laravel 13 requires PHP 8.3 or newer. AlmaLinux 10 provides PHP 8.3 in its standard repositories, so this guide does not add a third-party PHP repository.
Can I use an IP address instead of a domain?
Yes. You can test the default page through the VPS IP, although the Apache ServerName should be a real hostname for a clean virtual-host match. A domain is also needed for most automated TLS certificate providers.
Why does the Apache document root end in /public?
Laravel keeps .env, vendor, and application code above that directory. Exposing only public prevents those files from being downloaded as web content.
Can I use SQLite instead of MariaDB?
Yes. A new Laravel application can use SQLite for small deployments or development. MariaDB is used here because it is a better fit when you expect multiple users, background jobs, or a growing production database.