{"id":18506,"date":"2016-02-06T10:52:29","date_gmt":"2016-02-06T16:52:29","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=18506"},"modified":"2022-12-09T07:12:06","modified_gmt":"2022-12-09T13:12:06","slug":"how-to-install-symfony-3-framework-with-nginx-on-ubuntu-14-04","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-symfony-3-framework-with-nginx-on-ubuntu-14-04\/","title":{"rendered":"How to install Symfony 3 Framework with Nginx on Ubuntu 14.04"},"content":{"rendered":"
Symfony 3 is an open source and high performance PHP framework used for developing web 2.0 applications. Symfony allows you to develop faster and better software than with flat PHP. <\/p>\n <\/p>\n At the time of writing this tutorial, the latest stable version is Symfony 3.0.1 and it requires:<\/p>\n If you have Apache installed on your server, stop the Apache service and remove Apache packages:<\/p>\n Make sure your Ubutu VPS<\/a> is fully up to date by using the following commands:<\/p>\n In order to install Nginx, PHP-FPM, curl and MySQL on your server, run the following command:<\/p>\n Locate the PHP configuration file using the following command:<\/p>\n Edit the \/etc\/php5\/fpm\/php.ini configuration file using the following command:<\/p>\n then, add\/modify the following lines:<\/p>\n Run the following command to restart the php5-fpm service for the changes to take effect:<\/p>\n Install the latest stable version of Symfony on your virtual server using the following commands:<\/p>\n Create a new Symfony project:<\/p>\n Set the proper ownership of files and directories inside the ‘\/var\/www\/your-domain.com’ directory:<\/p>\n For performance reasons, our recommendation is to run php5-fpm in socket mode, instead of accessing via <IP_address>:PORT. and add the following lines:<\/p>\n In order to enable the newly created Nginx block, create a new symbolic link using the following command:<\/p>\n Test the Nginx configuration:<\/p>\n and restart the Nginx web server for the changes to take effect:<\/p>\n Open http:\/\/your-domain\/app.php and you should access the welcome page of Symfony 3. Learn how to create your first page in Symfony<\/a>. That is it. The framework has been installed now.<\/p>\n Of course you don\u2019t have to do any of this if you use one of our PHP Web Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Symfony 3 PHP framework<\/strong> for you. They are available 24×7 and will take care of your request immediately.<\/p>\n PS<\/span>.<\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" Symfony 3 is an open source and high performance PHP framework used for developing web 2.0 applications. Symfony allows you … <\/p>\n
\nIn this step by step tutorial, we will show you how to easily install Symfony 3 framework with Nginx<\/strong> on your Ubuntu based virtual server.<\/p>\n\n
\/etc\/init.d\/apache2 stop\r\napt-get remove apache2*<\/pre>\n
apt-get update\r\napt-get upgrade<\/pre>\n
apt-get install nginx php5-fpm php5-cli php5-mcrypt php5-gd curl mysql-client-5.5 mysql-server-5.5 mysql-server-core-5.5<\/pre>\n
php5-fpm -i | grep php.ini\r\nConfiguration File (php.ini) Path => \/etc\/php5\/fpm\r\nLoaded Configuration File => \/etc\/php5\/fpm\/php.ini<\/pre>\n
vi \/etc\/php5\/fpm\/php.ini<\/pre>\n
memory_limit = 128M\r\ncgi.fix_pathinfo = 0\r\nsafe_mode = Off\r\nmax_execution_time = 120\r\nmax_input_time = 120\r\ndate.timezone = \"America\/Chicago\"\r\n<\/pre>\n
\/etc\/init.d\/php5-fpm restart<\/pre>\n
sudo curl -LsS https:\/\/symfony.com\/installer -o \/usr\/local\/bin\/symfony\r\nsudo chmod a+x \/usr\/local\/bin\/symfony<\/pre>\n
symfony new project_name<\/pre>\n
mv \/project_name \/var\/www\/your-domain.com<\/pre>\n
chown chown www-data:www-data -R \/var\/www\/your-domain.com\/<\/pre>\n
\nRemove the default Nginx server block, then create a new Nginx configuration file and add the following virtual block for your domain name:<\/p>\nrm \/etc\/nginx\/sites-enabled\/default\r\nvi \/etc\/nginx\/sites-available\/your-domain.com<\/pre>\n
server {\r\n listen 80;\r\n server_name your-domain.com;\r\n client_max_body_size 20M;\r\n root \/var\/www\/your-domain.com\/web;\r\n index index.php index.html;\r\n access_log \/var\/log\/nginx\/your-domain.com-access.log;\r\n error_log \/var\/log\/nginx\/your-domain.com-error.log;\r\n set $yii_bootstrap \"index.php\";\r\n charset utf-8;\r\n\r\nlocation \/ {\r\n try_files $uri @rewriteapp;\r\n }\r\n\r\nlocation @rewriteapp {\r\n rewrite ^(.*)$ \/app.php\/$1 last;\r\n }\r\n\r\nlocation ~ ^\/(app|app_dev|config)\\.php(\/|$) {\r\n\r\n fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n fastcgi_split_path_info ^(.+\\.php)(\/.*)$;\r\n include fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n fastcgi_param HTTPS off;\r\n }\r\n\r\nlocation ~ \\.php {\r\n fastcgi_index index.php;\r\n fastcgi_split_path_info ^(.+\\.php)(.*)$;\r\n if (-f $document_root$fastcgi_script_name){\r\n set $fsn $fastcgi_script_name;\r\n }\r\n include \/etc\/nginx\/fastcgi_params;\r\n fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n }\r\n\r\nlocation ~ \/\\. {\r\n deny all;\r\n access_log off;\r\n log_not_found off;\r\n }\r\n}\r\n<\/pre>\n
ln -s \/etc\/nginx\/sites-available\/your-domain.com \/etc\/nginx\/sites-enabled\/your-domain.com<\/pre>\n
# nginx -t\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/pre>\n
\/etc\/init.d\/nginx restart<\/pre>\n