mayu watanabe
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # cloud9を使ったlaravel環境構築 ### AWSアカウントを作成する アカウント登録にクレカ登録、電話番号認証等必要になるので、ちょっと面倒ですが・・。cloud9の利用は無料ですが、サーバーをたてるとサーバーの使用料がかかります。でも登録から12ヶ月間は自動で無料枠が付与されます。詳しくは調べてみてください。 ### AWS Cloud 9上に新たな環境を作成 アカウントを作成したら、cloud9で環境を作成します。 1. create environmentをクリック ![](https://i.imgur.com/gA8370m.png) 2. Nameで適当に名前つけて、次に進む ![](https://i.imgur.com/OqsPLme.png) 3. Configure settingsはデフォルトのままでいいので、そのまま次へ進む 4. [create environment]を押して、環境が作成されます。 5. 環境作成されると、こんな画面に。 ![](https://i.imgur.com/HaCOMeg.png) 左側がフォルダ構成、ファイルクリックすると画面中央に表示されます(今AWS Cloud9と表示されているところ)。下にあるのがコマンド操作部分(ec2-user:~/environment $ と表示されているところ)。 次から、コマンドラインで環境構築していきます。 ### PHPのバージョンを7.1に上げる PHPのバージョン確認。 ``` $ php -v PHP 5.6.40 (cli) (built: Oct 31 2019 20:35:16) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans ``` デフォルトのPHPのバージョンが5.6なので、7.1にあげます。下記のコマンドを実行します。 ``` $ sudo yum -y update $ sudo yum -y install php71 php71-mbstring php71-pdo php71-intl php71-pdo_mysql php71-pdo_pgsql php71-xdebug php71-opcache php71-apcu $ sudo unlink /usr/bin/php $ sudo ln -s /etc/alternatives/php7 /usr/bin/php ``` ↑2行目でmysqlのPDOドライバをインストールしています。 cloud9でのlaravel環境構築を紹介している記事で、エラーになる場合があって、それがこのドライバがインストールされていないのが原因でした。デフォルトだと、`pdo_sqlite`しか入っていないです。 ``` $ php -m | grep pdo #ドライバの確認 pdo_mysql pdo_pgsql pdo_sqlite ``` ### Composerのインストール ``` $ curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer $ composer #確認用:composerの大きな文字が表示されてればOK ``` ### laravelのインストール ``` $ composer global require "laravel/installer" ``` メモリ不足でインストールができない時(composerコマンドでエラーになる) https://qiita.com/takaaki-mizuno/items/fc1b9ef513609cab7eb9 ### laravelプロジェクトの作成 ``` $ composer create-project laravel/laravel [プロジェクト名] ``` バージョンを指定しない場合、最新バージョンで作成されます。指定する場合は、プロジェクト名の後に例えば`5.5.*`などとつけて指定します。 ``` ec2-user:~/environment $ ls laravel-tdd README.md ``` environment直下に、プロジェクト(laravel-tdd)が作成されています。 ### mysqlのバージョンをあげる ``` ec2-user:~/environment $ mysql --version mysql Ver 14.14 Distrib 5.5.62, for Linux (x86_64) using readline 5.1 ``` ↑デフォルトだと5.5で、migrationでエラーになることがあるので、バージョンをあげます。下記コマンドを実行します。 ``` $ sudo service mysqld stop $ sudo yum -y erase mysql-config mysql55-server mysql55-libs mysql55 $ sudo yum -y install mysql57-server mysql57 $ sudo service mysqld start ``` ### mysqlでDBを作成する mysqlにログインします。パスワードは空白のままでエンター。 ``` ec2-user:~/environment $ mysql -uroot -p Enter password: #空欄 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.30 MySQL Community Server (GPL) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` プロジェクト用のDBを作成します。今回はsampleという名前で作成します。 ``` mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> create database sample; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sample | | sys | +--------------------+ 5 rows in set (0.00 sec) ``` 作成されました。 ### laravelの環境ファイルのDB設定を変更する exitでmysqlから一旦ログアウトします。プロジェクト下に移動し、`.env`という隠しファイルがあるので、それを編集します。 ``` ec2-user:~/environment $ ls laravel-tdd README.md ec2-user:~/environment $ cd laravel-tdd ec2-user:~/environment/laravel-tdd $ ls -a . artisan composer.lock .editorconfig .gitattributes phpunit.xml resources storage vendor .. bootstrap config .env .gitignore public routes .styleci.yml webpack.mix.js app composer.json database .env.example package.json readme.md server.php tests ``` ![](https://i.imgur.com/iQgT17h.png) ファイル構成欄の歯車マークをクリックすると、[show hidden files]という部分があるので、ここにチェックを入れると隠しファイルも表示されます。`.env`ファイルを開きます。 DBの設定のところを、下記のように書き換えます。 ``` DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=sample DB_USERNAME=root DB_PASSWORD= ``` 保存したら、artisanコマンドでmigrateできるか確認してみます。 ``` ec2-user:~/environment/laravel-tdd $ php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table (0.06 seconds) Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table (0.03 seconds) ec2-user:~/environment/laravel-tdd $ ``` ↑こんな感じで実行できれば、DBとの紐付けが成功しています。先ほど作ったDBみてみると、新しくテーブルが作成されています。 ``` mysql> use sample Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +------------------+ | Tables_in_sample | +------------------+ | migrations | | password_resets | | users | +------------------+ 3 rows in set (0.01 sec) mysql> ``` 最後に、ブラウザで表示確認してみます。まず、ローカルサーバーをたてて、 ``` ec2-user:~/environment/laravel-tdd $ php artisan serve --port=8080 Laravel development server started: <http://127.0.0.1:8080> ``` [preview running application]をクリックすると、ブラウザが開きます。 ![](https://i.imgur.com/iJ3pFR4.png) laravelの画面が表示されてたらOKです! ![](https://i.imgur.com/onfw0TF.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully