首頁  >  文章  >  運維  >  一文詳解Linux如何安裝Symfony2.8

一文詳解Linux如何安裝Symfony2.8

藏色散人
藏色散人轉載
2021-09-13 16:04:061434瀏覽

下面由linux系統教學專欄來介紹Linux如何安裝Symfony2.8,希望對需要的朋友有幫助!

#環境說明

作業系統

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

安裝準備

皆使用apt-get 安裝

PHP5.4

至少要有個PHP5.4的環境

nginx

web server 是少不了了

安裝步驟

1.下載官方指令工具

sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

2.建立專案


一文詳解Linux如何安裝Symfony2.8


##############################################################################################################################這裡執行專案創建時,會從官網下載源碼包,執行完後就能在當前目錄看到了###
symfony new symfony2.8 2.8
###這裡我創建了一個新的項目叫symfony2.8,最後的###2.8# ##(不是專案名字中的2.8) 是要下載指定的symfony2.8版本的原始碼,如果要下載的是其他版本, 修改一下介面######3.偵測###在安裝完後, symfony還會進行一些檢測, 看看你的作業系統環境是否適合運行symfony, 按照提示將缺少的擴展安裝(我安裝了###intl###)或者將PHP的配置修改(我就改了時區),再執行###
php symfony2.8/bin/symfony_requirements
###再次偵測是否透過(php 後面的檔案就在新建立的專案中,我這裡專案名稱是symfony2.8)######執行####### ###symfony2.8' 自帶的console(位置###symfony2.8/bin/console###)可以暫時啟動一個webserver,預設連接埠是8000,啟動後,透過###http://localhost :8000` 我可以看到他的歡迎頁面了######nginx 配置######nginx 的配置其官方文檔裡也有, 這裡直接把我的複製過來,我也是直接修改的官方文檔###
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;
}
###要注意的是, nginx中包含了一個在開發環境適用的配置和一個在生產環境適用的配置,在生產華景部署的時候, 一定不要講開發環境的配置帶上去了######設定好後,重新 reload nginx, 我這裡監聽的是虛擬機的8028端口,透過訪問這個端口,也可以直接看到歡迎頁面############# #####推薦學習:《###linux影片教學###》######

以上是一文詳解Linux如何安裝Symfony2.8的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除