Hosting a Laravel App on IONOS: Step-by-Step Guide Without Root Access

back

larave ionos

Important upfront: IONOS provides several PHP CLI versions in parallel on shared hosting packages, from php7.4-cli to php8.5-cli. All commands in this guide (Composer, Artisan) should therefore always be invoked with the explicit version, for example php8.3-cli instead of just php. If you overlook this, you'll quickly end up on an outdated default version that doesn't meet Laravel's requirements.

Finding SSH Credentials in the IONOS Panel

In the IONOS customer account under Hosting > SFTP & SSH you'll find the credentials for SSH access. Important: only the main user of a hosting package has SSH access — additionally created FTP users cannot log in via SSH.

For login, an SSH key is recommended over a password: upload your public key beforehand via ssh-copy-id or manually add it to the authorized_keys file in the .ssh directory on the server. This saves you entering a password on every deploy.

Verbindungsdaten

Connecting to the Server via SSH

Establish a connection with:

ssh username@servername

After logging in, you land in the main user's home directory.

Getting the Project onto the Server via Git

Navigate to the desired project folder (usually htdocs or a subfolder of it) and clone the repository:

git clone <repository-url> project-folder

For an existing project, a simple git pull is enough later to get the latest version.

Installing Composer Without Root

Many hosters like IONOS don't provide root access or a package manager, so apt install composer is out of the question. Still, Composer can be set up without any problems.

Downloading composer.phar

mkdir -p ~/bin
cd ~/bin
curl -sS https://getcomposer.org/installer | php8.3-cli
mv composer.phar ~/bin/composer.phar

Creating a Wrapper Script

Since composer.phar itself doesn't guarantee a shebang for the correct PHP version, a small wrapper under ~/bin/composer with the following content is worthwhile:

#!/bin/sh
exec php8.3-cli $HOME/bin/composer.phar "$@"

Then make it executable:

chmod +x ~/bin/composer

Extending PATH

For composer to work everywhere, add ~/bin to PATH in .bashrc or .bash_profile:

export PATH="$HOME/bin:$PATH"

Test whether everything works:

composer --version

This should then display the installed Composer and PHP version, entirely without root privileges and with an explicit PHP version.

Installing Composer Dependencies

Navigate to the Laravel project folder and install the production dependencies:

composer install --no-dev --optimize-autoloader

These flags ensure that dev dependencies are excluded and the autoloader is optimized for production.

Setting Up the .env File

Copy the template and adjust the values:

cp .env.example .env

Enter the database credentials (from the IONOS panel), APP_URL, and the production values:

APP_ENV=production
APP_DEBUG=false

Plus DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD matching your IONOS database access.

Note: The .env file doesn't belong in the Git repository. It stays permanently on the server and isn't overwritten with each new deploy, since it's excluded via .gitignore.

Initializing Laravel

Run the following one after another with the previously chosen PHP CLI version:

php8.3-cli artisan key:generate
php8.3-cli artisan storage:link
php8.3-cli artisan migrate --force
php8.3-cli artisan optimize

storage:link creates the symlink from public/storage to storage/app/public — without it, uploaded files return a 404. The --force flag on migrate is necessary because Artisan in production mode otherwise asks for an interactive confirmation, which fails on a non-interactive SSH session.

Setting Directory Permissions and Document Root

storage/ and bootstrap/cache/ must be writable by the web server:

chmod -R 775 storage bootstrap/cache

Without this, Laravel responds to every request with a 500 error.

In addition, the webspace root on IONOS doesn't point to laravel/public by default, but to the main directory. In the IONOS panel, an alternative directory can be set as the document root under the domain settings — enter the project's public folder there. If that's not possible, a fallback .htaccess in the webspace root pointing to laravel/public/index.php also works.

Frontend Assets: Adding the npm Build to the Repository

IONOS shared hosting doesn't provide Node.js/npm, so running npm run build on the server isn't possible. The solution: remove /public/build from .gitignore and generate the built assets locally, then commit them:

npm run build
git add public/build
git commit -m "Build assets"
git push

This step must be repeated before every git pull on the server for each deploy, otherwise the frontend and backend will drift out of sync.

Running the Scheduler and Queues Without Supervisor

Since Supervisor doesn't run on shared hosting, the Laravel scheduler must be triggered via an IONOS cron job — create a per-minute job in the panel under Cron Jobs:

* * * * * php8.3-cli /path/to/project/artisan schedule:run >> /dev/null 2>&1

The same problem applies to queues: running queue:work as a persistent process isn't cleanly possible without root/Supervisor. For most projects, the following .env entry is enough, which processes jobs synchronously within the request:

QUEUE_CONNECTION=sync

If real queues are needed, a separate cron job can be set up instead:

php8.3-cli artisan queue:work --stop-when-empty

Setting the Document Root to /public

The domain must point to the project's public folder in the IONOS panel, not to the project root. In the domain settings, explicitly set the directory to /public — otherwise you'll end up looking at Laravel's project structure instead of the front controller.

Troubleshooting: 404 or 503 on Subpages

If only the homepage loads while all other routes respond with 404 or 503, it's usually due to IONOS's rewrite configuration, which deviates from the standard.

In Laravel's public/.htaccess, inside <IfModule mod_rewrite.c>, right after the Options -MultiViews -Indexes block and before the remaining RewriteCond rules, add:

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

Otherwise, IONOS's default rewrite base deviates from the project path, which means only the homepage (index.php directly) works while all other Laravel routes lead nowhere.

Conclusion

Getting Laravel to run on IONOS shared hosting isn't rocket science, but it does require a few tricks that don't matter on classic root server hosting: explicit PHP CLI versions, a Composer wrapper without root, correctly set directory permissions and document root, and cron-job-based workarounds instead of Supervisor for the scheduler and queues. Once these points are set up cleanly, future deploys can be repeated with just a few commands.

eazyCode Logo Need support deploying your Laravel application? Our team at eazyCode is happy to help. Contact us with no obligation — we respond within 24 hours.

Kostenloses Erstgespräch – unverbindlich

Ihr Projekt verdient einen ehrlichen Partner.

Schildern Sie uns Ihre Anforderungen – wir melden uns innerhalb von 24 Stunden mit einer ersten Einschätzung. Kein Verkaufsgespräch, kein Kleingedrucktes.

Telefon

Mo–Fr, 9–17 Uhr. Wir sind direkt erreichbar.

+49 (0) 9072 922022 - 0
Termin vereinbaren

30 Minuten. Online. Kostenlos und unverbindlich.

Termin vereinbaren

Schreiben Sie uns – wir antworten innerhalb von 24 Stunden.