Lesson 2 from „Learn symfony 2.4 tutorial“ : Creating a development environment
Now we have a fresh symfony2 app. If not, please read the first tutorial about how to install symfony2.4.
We can access the symfony2.4 application on http://localhost/path_to_sf_project/web/app_dev.php. But the name is not so cool, right ?
We will learn in this tutorial how to create a local domain like http://innobyte.dev (you can choose any domain you want).
** Note : This instructions are specific to Apache (We should create a tutorial example for nginx too ?) and assume you have already installed Apache and running on your machine.
Step 1.First, we need to create a new file (we need sudo privileges)
1 |
sudo touch /etc/apache2/sites-available/innobyte.dev.conf |
Step 2. Edit the file created (/etc/apache2/sites-available/innobyte.dev.conf) with your favorite ide and add :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
ServerAdmin webmaster@localhost ServerName innobyte.dev ServerAlias www.innobyte.dev DocumentRoot /var/www/path_to_sf_project/web Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All #Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <directory "="" usr="" lib="" cgi-bin"=""> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch #Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined |
**Note : Change the path_to_sf_project with your path folder to symfony project
If you want to read more about apache vhosts, you can read here.
Step 3. Activate your new local domain
1 |
sudo a2ensite innobyte.dev.conf |
Step 4. Add a new domain to the bottom of the host file (/etc/hosts) – you need edit this with sudo too.
1 |
127.0.0.1 innobyte.dev www.innobyte.dev |
Step 5. Reload the apache service to get the new configuration
1 |
sudo service apache2 reload |
Step 6. edit the /var/www/path_to_sf_project/web/.htaccess file
Change app.php to app_dev.php (to use dev environment – make sure you change all occurrences of app to app_dev, should be 4 changes)
Now we can go to http://innobyte.dev. Easy, right ?