1.安装PHP
添加php安装源:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
更新软件仓库:
sudo apt-get update
查看可以安装的版本:
sudo apt-cache search <软件包名称>
安装php:
sudo apt-get install php7.2
在ubuntu系统里面安装php会自动安装apache2!
2.查看apache已经启用的扩展:
apachectl -t -D DUMP_MODULES
3.开启apache扩展:
列子:开启apache rewrite扩展。
sudo a2enmod rewrite
4.安装composer:
下载composer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
全局安装:
mv composer.phar /usr/local/bin/composer
到此composer全局安装完毕。
5.composer换源:
$ composer config -g repo.packagist composer https://packagist.laravel-china.org
6.安装或启用laravel需要的apache和php的扩展模块:
sudo a2enmod rewrite
查看php已经启用的模块:
php -m
为了运行laravel需要安装php缺少的模块:
php自带的有几个,这里再安装laravel需要的就行了:
sudo apt-get install php7.2-mbstring
sudo apt-get install php7.2-xml
安装php mysql扩展:
sudo apt-get install php7.2-mysql
7.重启apache命令:
sudo service apache2 restart
8.安装MySQL:
sudo apt-get install mysql-server
9.创建数据库并且指定字符集:
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
10.mysql授权:
grant all privileges on testdb to dba@'localhost' identified by '123345';