一文详解Linux如何安装Symfony2.8

发布时间 - 2021-09-13 00:00:00    点击率:

下面由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.创建项目

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

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  # php  # symfony  # nginx  # 接口  # console  # http  # 的是  # 完后  # 操作系统  # 我就  # 文档  # 也有  # 就在  # 去了  # 就能  # 还会 


相关栏目: 【 网站优化151355 】 【 网络推广146373 】 【 网络技术251813 】 【 AI营销90571


相关推荐: 如何用腾讯建站主机快速创建免费网站?  Laravel Blade模板引擎语法_Laravel Blade布局继承用法  如何在腾讯云服务器上快速搭建个人网站?  Laravel如何实现数据库事务?(DB Facade示例)  如何快速查询网站的真实建站时间?  深入理解Android中的xmlns:tools属性  PHP正则匹配日期和时间(时间戳转换)的实例代码  Windows家庭版如何开启组策略(gpedit.msc)?(安装方法)  Laravel如何使用Vite进行前端资源打包?(配置示例)  Laravel怎么进行数据库事务处理_Laravel DB Facade事务操作确保数据一致性  Laravel如何实现API速率限制?(Rate Limiting教程)  标题:Vue + Vuex + JWT 身份认证的正确实践与常见误区解析  Swift中switch语句区间和元组模式匹配  Gemini手机端怎么发图片_Gemini手机端发图方法【步骤】  Laravel如何使用查询构建器?(Query Builder高级用法)  Laravel Eloquent性能优化技巧_Laravel N+1查询问题解决  laravel怎么配置Redis作为缓存驱动_laravel Redis缓存配置教程  邀请函制作网站有哪些,有没有做年会邀请函的网站啊?在线制作,模板很多的那种?  Android使用GridView实现日历的简单功能  WordPress 子目录安装中正确处理脚本路径的完整指南  Laravel Session怎么存储_Laravel Session驱动配置详解  微信公众帐号开发教程之图文消息全攻略  Android利用动画实现背景逐渐变暗  高配服务器限时抢购:企业级配置与回收服务一站式优惠方案  Win11怎么关闭透明效果_Windows11辅助功能视觉效果设置  如何制作新型网站程序文件,新型止水鱼鳞网要拆除吗?  bing浏览器学术搜索入口_bing学术文献检索地址  Thinkphp 中 distinct 的用法解析  企业在线网站设计制作流程,想建设一个属于自己的企业网站,该如何去做?  网站建设整体流程解析,建站其实很容易!  Laravel如何自定义分页视图?(Pagination示例)  如何快速打造个性化非模板自助建站?  实现点击下箭头变上箭头来回切换的两种方法【推荐】  如何在云指建站中生成FTP站点?  中国移动官方网站首页入口 中国移动官网网页登录  如何为不同团队 ID 动态生成多个非值班状态按钮  EditPlus中的正则表达式实战(6)  Win11搜索不到蓝牙耳机怎么办 Win11蓝牙驱动更新修复【详解】  b2c电商网站制作流程,b2c水平综合的电商平台?  电商网站制作价格怎么算,网上拍卖流程以及规则?  如何破解联通资金短缺导致的基站建设难题?  Laravel如何设置自定义的日志文件名_Laravel根据日期或用户ID生成动态日志【技巧】  Laravel Fortify是什么,和Jetstream有什么关系  Laravel如何保护应用免受CSRF攻击?(原理和示例)  Laravel Livewire是什么_使用Laravel Livewire构建动态前端界面  Laravel如何使用Service Container和依赖注入?(代码示例)  JavaScript如何实现路由_前端路由原理是什么  java中使用zxing批量生成二维码立牌  JS实现鼠标移上去显示图片或微信二维码  Android仿QQ列表左滑删除操作