$sudo apt-get install unzip zip
2.安裝PHP 7.2 與其拓展套件
//軟體源拓展工具
$sudo apt -y install software-properties-common apt-transport-https lsb-release ca-certificates
//軟體源
$sudo add-apt-repository ppa:ondrej/php
//更新
$sudo apt-get update
//安裝PHP 7.2 與其拓展套件
$sudo apt-get install php7.2 php7.2-cli php7.2-json php7.2-mbstring php7.2-gd php7.2-xml php7.2-ldap php7.2-mysql php7.2-zip
3.安裝composer:
//下載composer
$wget -c https://getcomposer.org/composer.phar
//將composer.phar設為可執行
$chmod +x composer.phar
//移到/usr/local/bin,並改名composer,隨時可呼叫
$sudo mv composer.phar /usr/local/bin/composer
//測試
$composer
4.安裝phpmyadmin
$sudo apt-get install phpmyadmin
5.於html下安裝laravel,放置在/home/webadmin/html/laravel/
$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
6.安裝最新版的laravel
$composer create-project laravel/laravel --prefer-dist /home/webadmin/html/laravel
7.加入apache虛擬主機
$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網頁
<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
8.更改特定目錄擁有者為www-data,及777
$cd /home/webadmin/html/laravel/
$sudo chown -R www-data storage/ bootstrap/cache/
$sudo chmod -R 777 storage/ bootstrap/cache/
9.設定預設php版本為 7.2
$sudo update-alternatives --set php /usr/bin/php7.2
10.Apache2 啟用 php7.2
$ sudo a2enmod php7.2
$ sudo systemctl restart apache2
資料來源:
1.lubuntu 16.04 x64 安裝 laravel 5 與安裝phpmyadmin
https://www.tecmint.com/install-different-php-versions-in-ubuntu/
3.ubuntu 16.04 安装PhpMyAdmin https://blog.csdn.net/l6807718/article/details/51374915
4.Ubuntu – 安裝 PHP7 + Apache + Mysql/MariaDB + phpMyadmin http://jsnwork.kiiuo.com/archives/2505/ubuntu-%E5%AE%89%E8%A3%9D-php7-apache-mysqlmariadb-phpmyadmin/