Ubuntu安装Laravel
由于现在的ubuntu资源库已经没有了php5.6,所以本文安装laravel环境是apache2+php7.0+mysql(本文中有ubuntu的相关操作一笔带过)
获得root用户权限
sudo su首先更新安装资源
apt-get update
(在这步的时候会根据网速的不同,时间不同,如果速度慢时间长可以更换源【这里不明确讲】)安装vim编译器
apt-get install vim安装apache2
apt-get install apache2
(安装完成后,在浏览器输入localhost验证是否安装成功)安装php7.0
apt-get install php7.0
(在php5.6情况下,安装完php环境,apache就能自动添加php模块,但是在php7.0没有了这个模块,需要手动安装)
apt-get install libapache2-mod-php安装完成后在/var/www/html下新建phpinfo.php文件 在浏览器即可访问
安装mysql环境
apt-get install mysql-server mysql-client
(如果有图形界面安装过程中需要输入mysql密码)安装laravel加密的扩展
apt-get install mcrypt php7.0-mcrypt php7.0-mysql安装 curl wget openssl mbstring zip
apt-get install curl wget openssl php-zip php-mbstring安装composer
curl -sS https://getcomposer.org/installer | php
或者
php-r “readfile(‘https://getcomposer.org/installer‘);” | php
或者手动下载composer.phar并上传不管通过哪种方式,都需要吧composer复制到bin文件夹下
cp composer.phar /bin/composer
(这样composer命令就可以直接调用)安装laravel
composer creat-project –prefer-dist laravel/laravel 项目名称
(通过这种方式安装的是lavavel最新版,不建议使用,可以下载laravelLTS版复制到项目目录)配置虚拟主机
cd /etc/apache2/site-available
cp 000-default.conf demo.conf
vim demo.conf //更改其中的目录和访问的域名,目录是laravel下的public
ln -s demo.conf ../site-enabled //加软连接
service apache2 restart //重启apache2配置hosts文件
vim /etc/hosts
添加127.0.0.1 你的域名
保存重启阿apache2
给项目目录所有权限chmod 777 * -R
打开浏览器就可用域名访问 即可