6 steps to deploy your Symfony site using Oracle 11g on Microsoft IIS

At work, I am deploying a web app on IIS, nothing new until now. But, weeks ago, I chose the framework Symfony to help me on translations, ORM, routing, templating etc. Deploy your pure PHP web site on IIS is easy, with a web site made with Symfony is definitifely not commun. Most of tutoriels on Internet (like StackOverFlow) are about Symfony 2 and answers are (too) short (and/or too specified). So, I decide to write this article explaining how to deploy your Symfony web site on the Microsoft IIS with an Oracle dababase (based on my experience).

This tutoriel has been written to help you in your deployment, take what you want but do not follow it like a « StackOverFlow copy/paste developer ».

Let’s start with version:

  • Microsoft IIS 2019
  • Symfony 4
  • Oracle 11g
  • PHP CLI 7.4.7
Step 1 : Composer & PHP

Install Composer via this link: https://getcomposer.org/download/ and, to check the installation, run composer with the command line (cmd) on your server (where IIS is).
Install PHP CGI (I think it works with PHP 8, try it and go back with PHP 7 if it doesn’t work) and then run php --version. This command line should work.

Step 2 : Import your web site

Copy your web site in a empty repository except vendor and var folders and env.local file. To finish, create a new Web site through IIS with the physical path to the public repository in your web site sources (recently copied).

Step 3: Install your dependencies with Composer

If your company uses a firewall to be connected on internet, you should first connect to your company’s firewall on your server (to have internet access). Execute the following command where your composer.json is: composer install --no-dev --optimize-autoloader.

Step 4: Global configuration

First, create a new file in the root folder called env.prod for the production configuration. In this file, add and modify this line ccording to yout database configuration DATABASE_URL=oci8://login:password@databaseUrl:port/databaseName (for example oci8://admin:1234@ Then, add APP_ENV=prod and APP_DEBUG=0. Compile the file by using composer dump-env prod, now, you have a env.prod.php file.

Your boss waiting the app deployment
Step 4: Route your web site

Firstly, install the IIS component called Rewrite URL (download it from here and launch the .exe). Check if this module is correctly installed by finding it on the Feature View. Then create a file called web.config in the public repository and insert the code available below. Now, all routes are managed by Symfony!

Step 5: Configure your PHP

Download the DLL for Oracle 11g here (choose DLL of the last version and, according to your PHP version, choose « Non Thread Safe »). Extract the content and move php_oci8_11g.dll into the folder ext of your PHP CLI (do not rename this file). Enable, at least, extensions (uncomment by deleting the semicolon) that you need and add the line extension=oci8_11g. Of course, adapt those steps if you have a different version of Oracle.

Step 6: Oracle 11g

Before this step, you should only have a database error in your web site logs. In the env.local file, add and modify this line according to your database configuration DATABASE_URL=oci8://login:password@databaseUrl:port/databaseName (for example oci8://admin:1234@ You know, Oracle is particular for Symfony, you must add some lines in config/services.yaml and create 2 classes in App\EventListener (see below).

  • If composer install --no-dev --optimize-autoloader doesn’t work, delete composer.lock and try again. If the problem persists, copy the vendor folder from your development environment into the root folder of your web site (not recommended in production environment).
  • If you want to debug routes of IIS, add a logging rule for 500 error (or another one) by clicking on Failed Request Tracing Rules in your IIS manager. Find the location by double clicking the module (Failed Request Tracing Rules) on Feature View and then click on View Trace Log (It was C:\inetpub\logs\FailedReqLogFiles for me). Other IIS’ logs are in C:\inetpub\logs\LogFiles.
  • More logs with Symfony and PHP: symfony logs are located in var/log/prod.log. If you are using the package monolog-bundle, add SHELL_VERBOSITY=3 in .env file to activate full log. For php logs, turn on full logs by changing display_errors=On and display_startup_errors=On in your php.ini. Those manipulations should be reverted after resolving your bug!!!
  • OCI means Oracle Call Interface, it is the interface (coded in native C) between your code and your Oracle Database
  • Define a global route (@Route("/",name="default")) redirecting to a login page
  • Do not store password in your CVS, use the file .env.local and untrack it.
  • Do not forget to use an user with the strict necessary access on your database. For example, you can create your tables by coping the PL/SQL result from this command: php bin/console doctrine:schema:create --dump-sql to delete the CREATE and ALTER access to your database user.
  • Avoid enable useless PHP extensions in your php.ini

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *