>  기사  >  운영 및 유지보수  >  Linux에 Symfony2.8을 설치하는 방법을 자세히 설명하는 기사

Linux에 Symfony2.8을 설치하는 방법을 자세히 설명하는 기사

藏色散人
藏色散人앞으로
2021-09-13 16:04:061520검색

다음 칼럼에서는 linux 시스템 튜토리얼 칼럼에서 Symfony2.8을 Linux에 설치하는 방법을 소개하겠습니다. 필요한 친구들에게 도움이 되길 바랍니다!

환경 설명

운영 체제

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를 사용하여 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.创建项目

这里执行项目创建时,会从官网下载源码包,执行完后就能在当前目录看到了

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,启动后,通过

PHP5.4 설치

At 최소한 PHP5.4 환경이 필요합니다

nginx

웹 서버가 필수입니다

설치 단계

Linux에 Symfony2.8을 설치하는 방법을 자세히 설명하는 기사1. 공식 명령 도구를 다운로드하세요

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;
}
2. 여기서 프로젝트 생성을 실행하면 소스 코드가 생성됩니다. 공식 웹 사이트 패키지에서 다운로드하면 실행 후 현재 디렉터리에서 볼 수 있습니다

rrreee여기서 Symfony2.8이라는 새 프로젝트를 만들었고 마지막 2.8(프로젝트의 2.8이 아님) name)은 지정된 Symfony2.8 버전의 소스 코드를 다운로드하는 것입니다. 다른 버전을 다운로드하려면 인터페이스를 수정하세요.
3. 감지

설치 후 Symfony는 운영 체제 환경이 다음과 같은지 확인하기 위해 몇 가지 테스트도 수행합니다. Symfony 실행에 적합합니다. 누락된 확장 프로그램을 설치하거나(intl 설치) PHP 구성을 수정하라는 메시지가 표시되고(시간대를 변경했습니다) 🎜rrreee🎜를 실행하여 통과 여부를 확인합니다. 다시 (PHP 뒤에 있는 파일은 새로 만든 프로젝트 중 여기에서 내 프로젝트 이름은 Symfony2.8입니다.)🎜🎜Run🎜🎜symfony2.8' 내장 콘솔(위치symfony2.8) /bin/console)을 임시로 시작할 수 있습니다. 웹서버, 기본 포트는 8000입니다. 시작한 후 http://localhost:8000`🎜🎜nginx 구성🎜🎜nginx를 통해 환영 페이지를 볼 수 있습니다. 구성은 공식 문서에서도 볼 수 있습니다. 여기에서 직접 복사하고, 공식 문서도 직접 수정했습니다🎜rrreee🎜 nginx에는 개발 환경에 적용 가능한 구성과 Huajing 배포 시 프로덕션 환경에 적용 가능한 구성이 포함되어 있다는 점에 유의하세요. 프로덕션에서는 반드시 개발 환경 구성에 대해 이야기하지 마십시오. 구성 후 nginx를 다시 로드하십시오. 여기서 듣고 있는 것은 가상 머신의 8028 포트입니다. 이 포트에 액세스하면 직접 볼 수도 있습니다. 환영 페이지. 추천 학습: "🎜linux 비디오 튜토리얼🎜"🎜🎜

위 내용은 Linux에 Symfony2.8을 설치하는 방법을 자세히 설명하는 기사의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 segmentfault.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제