设为首页 收藏本站
查看: 789|回复: 0

[经验分享] How to install Yii2 on ubuntu

[复制链接]

尚未签到

发表于 2018-5-1 13:28:16 | 显示全部楼层 |阅读模式
  http://tutsnare.com/how-to-install-yii2-on-ubuntu/

How to install Yii2 on ubuntu using composer
  Best way to install Yii Framework is using composer. Below we will
see installation steps of a php framework yii2 on ubuntu. Let’s see How to install yii2 on ubuntu using composer.Before composer install we need some more packages installation. In
this article (How to install Yii2 on ubuntu using composer) we will
explore step by step all the commands to make yii2 installation easy andneed to make yii2 install. You need to just run these commands step by
step via terminal.
  Requirement :-
PHP >= 5.4
Some of packages installed :- curl, openssl, mcrypt etc.
  Below are the steps of installing yii2 on ubuntu using composer:- first we need to install latest update and upgrade of ubuntu server. so for this run below command at your terminal.
sudo apt-get update
sudo apt-get upgrade  After update we need to install php, apche, mysql (if not already installed)
  Install php mysql and apache
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install mysql-server
sudo apt-get install php5-mysql  Now we need to install some of require extension (json, curl, mcrypt
etc.) to run and download yii2 framework. and then restart apache serverto setup all extension. May be you don’t need to all extension but it’ssometimes require extension you need.
#installing json extension
sudo apt-get install php5-json
#installing unzip extension
sudo apt-get install unzip
#installing curl extension
sudo apt-get install curl
#installing openssl extension
sudo apt-get install openssl
#installing mcrypt extension
sudo apt-get install php5-mcrypt
#enable mcrypt extension
sudo php5enmod mcrypt
#enable mod rewrite extension
sudo a2enmod rewrite
#php gd extension
sudo apt-get install php5-gd
#restarting apache
sudo service apache2 restart  After successfully configure all php setup and require extension we
need to install composer to download yii2 from remote server. for this
first command will be for download composer using curl then second one
move composer to local user directory for make composer globally use.
# installing composer
curl -sS https://getcomposer.org/installer | php
# move composer globally
sudo mv composer.phar /usr/local/bin/composer
# check composer working
composer  

  Note :-
  

  if you need,please modify chinese source ,or it will be slow,if there is a ladder,you can skip,like this:
composer config -g repositories.packagist composer http://packagist.phpcomposer.com  申请github token,其他项目也会用到,不然会看到
  You'd better apply for a token GitHub, and other projects will be used, otherwise you will see:
Could not fetch https://api.github.com/repos/jquery/jquery, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+mrgeneral-linux+2015-09-05+1450
to retrieve a token. It will be stored in "/home/chengxiaobai/.composer/auth.json" for future use by Composer.
Token (hidden)  If you watch that when you installing composer,you will creating a token like that:


  •   sign up a github account,then add one emali.

  •   create a token:

    •   In the top right corner of any page, click your profile photo, then click Settings. DSC0000.png
    •   In the user settings sidebar, click Personal access tokens. DSC0001.png
    •   Click Generate new token. DSC0002.png DSC0003.png
    •   Give your token a descriptive name.
    •   Select the scopes you wish to grant to this token. The default scopes
      allow you to interact with public and private repositories, user data,
      and gis DSC0004.png ts.
    •   Click Generate token.
    •   ce4249e2a0a817c22226bbc62e790ae3f6aaf5c4

      Personal access tokens
        Tokens you have generated that can be used to access the GitHub API.
      Make sure to copy your new personal access token now. You won’t be able to see it again!

  If you thave already installed composer and it’s a old version you can update composer via below command
# updating composer
composer self-update  Now we have composer installed successfully on our ubuntu. and then
we need to install yii2 on ubuntu. I am sharing steps below with
terminal command run screen-shots that how to install yii2 on ubuntu.
  Now need to install Composer asset plugin first using composer.
Composer asset plugin allows managing bower and npm package
dependencies.
# install Composer asset plugin
composer global require "fxp/composer-asset-plugin:1.0.0"
DSC0005.png

  Now run below command to install yii2. First i am going switch to my
preferred destination where i want to install yii2 so i am installing at/var/www/html/ directory.
Note:- During installation Composer may ask for your
Github login credentials. This is normal because Composer needs to get
enough API rate-limit to retrieve the dependent package information fromGithub.
  更改composer 源(更改成https):
vim  ~/.composer/config.json
DSC0006.png

  更改为:

# changing dir
cd /var/www/html/
# install yii2
composer create-project yiisoft/yii2-app-basic basic

  You can also give your location at installation time see Full command of yii2 installation is there “–prefer-dist” means location where you want to install yii.
composer create-project --prefer-dist yiisoft/yii2-app-basic basic  Now check your preferred location you have a new directory named
“basic” you can rename it. also you can rename basic to your-name at
installation time like below.
composer create-project --prefer-dist yiisoft/yii2-app-basic NewName  Now you are done with how to install yii2 on ubuntu. and open url on http://localhost/basic/web/ and bam. Now you can enjoy a new php framework. you can get more about this on official site of yii framework and see what’s new features you are getting. you will really enjoy this php framework.
  Note :- If you want to install the latest development version of Yii then you need to execute below command via terminal.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-454431-1-1.html 上篇帖子: 安装Ubuntu 15.04后要做的事 下篇帖子: ubuntu apache2的配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表