Environment description
Operating system
tony@ubuntu:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS Release: 14.04 Codename: trusty
Symfony
symfony2.8
Installation preparation
Use apt-get
to install
PHP5.4
At least there must be a PHP5.4 environment
nginx
web server is indispensable
Installation steps
1. Download the official command tool
sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony sudo chmod a+x /usr/local/bin/symfony
2. Create a project
When executing the project creation here, the source code package will be downloaded from the official website. After execution, you can see it in the current directory
symfony new symfony2.8 2.8
Here I created a new project called symfony2.8, and the final 2.8
(not 2.8 in the project name) is to download the source code of the specified symfony2.8 version. If you want to download other versions, modify the interface
3. Detection
After installation, Symfony will also perform some tests to see if your operating system environment is suitable for running symfony. Follow the prompts to install the missing extensions (I installed intl
) or modify the PHP configuration (I changed the time zone ), and then execute
php symfony2.8/bin/symfony_requirements
to check again whether it passes (the file behind php is in the newly created project, my project name here is symfony2.8)
Run
symfony2.8' The built-in console (location
symfony2.8/bin/console) can temporarily start a webserver. The default port is 8000. After startup, use
http://localhost :8000` You can see his welcome page
nginx configuration
nginx configuration is also included in its official documents. I directly copy mine here, and I also directly modified the official documents.
server { listen 8028; #server_name domain.tld www.domain.tld; root /data/app/symfony2.8/web; location / { # try to serve file directly, fallback to app.php try_files $uri /app.php$is_args$args; } # DEV # This rule should only be placed on your development environment # In production, don't include this and don't deploy app_dev.php or config.php location ~ ^/(app_dev|config)\.php(/|$) { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; } # PROD location ~ ^/app\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; # Prevents URIs that include the front controller. This will 404: # http://domain.tld/app.php/some-path # Remove the internal directive to allow URIs like this internal; } # return 404 for all other php files not matching the front controller # this prevents access to other php files you don't want to be accessible. location ~ \.php$ { return 404; } error_log /data/log/nginx/symfony_error.log; access_log /data/log/nginx/symfony_access.log; }
It should be noted that nginx contains a configuration suitable for the development environment and a configuration suitable for the production environment. When deploying Huajing in production, be sure not to mention the configuration of the development environment.
After configuration, reload nginx. What I am listening to here is the 8028 port of the virtual machine. By accessing this port, you can also directly see the welcome page