google cloud 安裝php Laravel 從0開始 筆記本



未整理

如何切換為root 

You can use 'sudo su -' to switch to the root user. You can also use 'sudo passwd root' to update root's authentication token(s) and then use 'su -' command to switch to the root user.

Install Apache

# yum --enablerepo=remi,epel install httpd
設定 Apache 開機自動執行:
# systemctl start httpd
# systemctl enable httpd

先安裝 wget

yum install wget
安裝git
yum install git-core


MySQL安裝

安裝 MySQL Repository:
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
安裝 MySQL Server, MySQL client 已經包括在 server 套件內:
# yum install mysql-community-server
開機自動啟動 MySQL
# /usr/bin/systemctl enable mysqld
啟動 MySQL
# /usr/bin/systemctl start mysqld
MySQL 預設為空密碼, 執行以下指令修改:
# /usr/bin/mysql_secure_installation

Install PHP

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm
If you already have EPEL installed:
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7*.rpm
Enabling the Repo
Now we need to make sure the repo is enabled and select which version you want to install. We need to head over to /etc/yum.repos.d you should inside see a file called remi.repo.
Open the file in your favourite editor (Nano, Pico, Vi etc), you'll see a number of sections. We need to make sure that the first section [remi] is enabled:
[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Note the line enabled=1 make sure this is set! Now technically you can actually go ahead and install PHP, but you will only get PHP 5.4.*. Which might be want to you want is so skip ahead to the next section!
If we want PHP 5.5 or PHP 5.6 we need to do a bit more work, further down in the repo.repo file you will see two additional sections [remi-php55] and [remi-php56], decide which PHP version you want to install and then enable the correct. So for PHP 5.6 we would change to:
[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Once you made your changes save your modified file and quit your editor.
Installing PHP
yum install php php-bcmath php-cli php-common php-mysqlnd php-dba php-pdo php-devel php-embedded php-enchant php-fpm php-gd php-imap php-interbase php-intl php-ldap php-mbstring php-mcrypt php-mssql php-odbc php-opcache php-pear php-pecl-apcu php-pecl-apcu-devel php-pecl-gearman php-pecl-geoip php-pecl-igbinary php-pecl-igbinary-devel php-pecl-imagick php-pecl-imagick-devel php-pecl-memcache php-pecl-memcached php-pecl-redis php-pecl-xdebug php-pgsql php-phpdbg php-process php-pspell php-recode php-snmp php-soap php-tidy php-xml php-xmlrpcAs you can see PHP is installing version 5.5.20-2.el6.remi from the remi-php55 repo! Once you have hit Y to confirm the install restart apache and magical unicorns you have a better version of PHP!
You can also change your mind in the future by going back into the remi.repo file and enable a different PHP version and then run yum update and if you have moved from 5.5 to 5.6 it will upgrade PHP for you. If you want to downgrade for any reason you will need to remove PHP (sudo yum remove php*) and then reinstall the PHP modules you want.

Step 3: Install Composer

Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer
如果ram很小記得下面這個

To enable the swap you can use for example:
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

Step 4: Install Laravel

To download latest version of Laravel, Use below command to clone master repo of laravel from github.ㄗ
# cd /var/www
# git clone https://github.com/laravel/laravel.git
Navigate to Laravel code directory and use composer to install all dependencies required for Laravel framework.
# cd /var/www/laravel
# composer install
Dependencies installation will take some time. After than set proper permissions on files.
# chown -R apache.apache /var/www/laravel
# chmod -R 755 /var/www/laravel

Step 5: Set Encryption Key

Now set the 32 bit long random number encrypption key, which used by the Illuminate encrypter service.
$ php artisan key:generate

Application key [Z4hfTHU7hFMwHauzOwv7rO9e0MJ9UnhQ] set successfully.
Now edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.
'key' => env('APP_KEY', 'Z4hfTHU7hFMwHauzOwv7rO9e0MJ9UnhQ'),

'cipher' => 'AES-256-CBC',

Step 6: Create Apache Virtual Host

Now add a Virtual Host in your Apache configuration file to access Laravel framework from web browser. To do it edit Apache configuration file /etc/httpd/conf/httpd.conf and add below code at end of file
# vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
       ServerName laravel.example.com
       DocumentRoot /var/www/laravel/public

       <Directory /var/www/laravel>
              AllowOverride All
       </Directory>
</VirtualHost>
Restart Apache service and access Laravel framework using your favourite web browser and start developing a great web application.
 # service httpd restart
Now access the Laravel website in web browser.
技術提供:Blogger.