dyson6 2017-11-3 08:51
在 AWS AMI EC2安裝 PHP7.1+Laravel Composer+MongoDB+Swagger
AMI(Amazon Machine Images)說得簡單一點的話,其實就是映象檔(Image),它可以將目前的EC2做快速的複製.<br>如果要使用安裝 PHP7.1+Laravel Composer+MongoDB.可以這樣安裝~<br><br><br>(1)安裝 PHP7.1<br># yum install php71*<br><br>(2)安裝 composer<br># curl -sS https://getcomposer.org/installer | sudo php<br># mv composer.phar /usr/local/bin/composer<br># ln -s /usr/local/bin/composer /usr/bin/composer<br><br>(3)安裝Laravel mongodb Driver<br># yum install php7-pear php7-devel gcc openssl-devel git<br># pecl7 install mongodb<br># echo "extension=mongodb.so" > /etc/php.d/mongodb.ini<br><br>在Laravel項目中安裝swagger-php:<br># composer require zircote/swagger-php<br><br>(4)安裝mongodb 3.4 server<br>請建立 /etc/yum.repos.d/mongodb-org-3.4.repo 檔案,並加入以下內容:<br>[quote]<br>[mongodb-org-3.4]<br>name=MongoDB Repository<br>baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/<br>gpgcheck=1<br>enabled=1<br>gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc<br>[/quote]<br><br># yum install mongodb-org mongodb-org-server<br><br>啟動 mongod service<br># service mongod start<br><br>這樣就可以囉~~<br><br>安裝過程有出現一些狀況...可以這樣解~<br>問題(一):<br>Laravel composer install 出現這個問題:<br>PHP Composer update “cannot allocate memory” error (using Laravel 5.3)<br>proc_open() fork failed - cannot allocate memory composer<br><br>解法(增加swap空間):<br># /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024<br># /sbin/mkswap /var/swap.1<br># /sbin/swapon /var/swap.1<br><br>問題(二): 幫 git 加上 Auto Complete<br># curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash<br><br>Next, add the following lines to your <font color="Red">.bash_profile</font>. <br>[quote]<br>if [ -f ~/.git-completion.bash ]; then<br> . ~/.git-completion.bash<br>fi<br>[/quote]<br><br>參考文章:<br>https://stackoverflow.com/questions/18116261/php-composer-update-cannot-allocate-memory-error-using-laravel-4<br>http://code-worrier.com/blog/autocomplete-git/