laravel備忘(安裝於ubuntu16.04)
一、必要安裝
安裝等等要解壓的工具
sudo apt-get install unzip zip
安裝lamp
sudo apt-get install lamp-server^
安裝php擴充
sudo apt-get install php7.0-mysql php7.0-cli php7.0-json php7.0-mcrypt php7.0-mbstring php7.0-gd php7.0-xml(即php5-dom)
安裝phpMyAdmin
sudo apt-get install phpmyadmin
sudo apt-get install phpmyadmin
二、下載安裝composer
下載
wget -c https://getcomposer.org/composer.phar
可執行
chmod +x composer.phar
移到/usr/local/bin,改名composer
mv composer.phar /usr/local/bin/composer
composer基本指令
測試看看
composer
版本
composer -V
升級
composer self-update
是否有效
composer validate
如果出現 ./composer.json not found.
請用 composer global require "phpunit/php-invoker=1.1.*"
三、用composer於html下安裝laravel,放置在/home/webadmin/html/laravel/
不得用root使用者
cd /home/webadmin/
mkdir html
cd /var/www/
sudo mv html html2
ln -s /home/webadmin/html /var/www/html (此時 /var/www/ 有兩個目錄 html html2)
cd /home/webadmin/html/
mkdir laravel
安裝最新版的laravel
composer create-project laravel/laravel --prefer-dist /home/webadmin/html/laravel
要是安裝laravel 5.1版本,則為
composer create-project laravel/laravel --prefer-dist /home/webadmin/html/laravel 5.1
成功後,出現:
composer create-project laravel/laravel --prefer-dist /home/webadmin/html/laravel 5.1
成功後,出現:
php artisan key:generate
Application key [base64:gS7Fs2tXdjW3UVmAuO/+YRvCDrHmgaqU84iPCIgJ368=] set successfully.
四、加入apache虛擬主機(安裝phpmyadmin,則免做步驟、四)
sudo vi /etc/hosts
sudo vi /etc/hosts
sudo vim /etc/apache2/sites-available/laravel.conf
寫入:
-------------------------------------------------------------------------------------
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /home/webadmin/html/laravel/public
<Directory /home/webadmin/html/laravel>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
-------------------------------------------------------------------------------------
如果要取消原本80網頁
$sudo a2dissite 000-default.conf
啟用新網頁
$sudo a2ensite laravel.conf
$sudo a2enmod rewrite
$sudo service apache2 restart
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /home/webadmin/html/laravel/public
<Directory /home/webadmin/html/laravel>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
-------------------------------------------------------------------------------------
如果要取消原本80網頁
$sudo a2dissite 000-default.conf
啟用新網頁
$sudo a2ensite laravel.conf
$sudo a2enmod rewrite
$sudo service apache2 restart
五、更改特定目錄擁有者為www-data,及777
cd /home/webadmin/html/laravel/
sudo chown -R www-data storage/ bootstrap/cache/
sudo chmod -R 777 storage/ bootstrap/cache/
sudo chown -R www-data storage/ bootstrap/cache/
sudo chmod -R 777 storage/ bootstrap/cache/
資料來源:
1.laravel備忘(安裝於ubuntu16.04) http://etplayinfo.blogspot.tw/2016/11/laravel.html
1.laravel備忘(安裝於ubuntu16.04) http://etplayinfo.blogspot.tw/2016/11/laravel.html
沒有留言:
張貼留言