一、在centos7下安装laravel
1、添加两个仓库:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、 安装php
yum install php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
3、 安装apache和Mariadb:
yum install httpd mariadb mariadb-server
4、 启动Mariadb、httpd服务:
systemctl start mariadb
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd
5、 Mariadb数据库root密码默认为空,运行MySQL初始化脚本:
mysql_secure_installation
6、 安装composer
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer
#如不能安装,则使用其他方法进行安装
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
//下载安装脚本(composer-setup.php)到当前目录
php composer-setup.php
//执行安装过程
php -r "unlink('composer-setup.php');"
//删除安装脚本 -- composer-setup.php
mv composer.phar /usr/local/bin/composer
//全局安装
#配置国内镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
使用国内镜像,加速composer安装等,可参考http://pkg.phpcomposer.com/#h…
7、 从github获取laravel源码
cd /var/www
git clone https://github.com/laravel/laravel
#安装Laravel:
cd laravel
composer install
chown -R apache:apache /var/www/laravel
chmod -R 755 /var/www/laravel
#生成App key:
php artisan key:generate
编辑config/app.php,把上面生成的key写入
8、 配置apache
1. 使用apache
#配置Apache,创建Virtual Host:
vim /etc/httpd/conf.d/laravel.conf
#写入:
<VirtualHost *:80>
DocumentRoot /var/www/laravel/public
ServerName your_domain.com
<Directory /var/www/laravel/>
AllowOverride All
</Directory>
</VirtualHost>
2. 使用php内置服务器
cd learnlaravel5/public
php -S 0.0.0.0:1024
9、 迁移
1. git clone
2. composer install
#设置文件权限(eg):
chown -R apache:apache /var/www/laravel
chmod -R 755 /var/www/laravel
3. 配置环境(.env)
mv .env.example .env
#修改参数eg:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel5
DB_USERNAME=root
DB_PASSWORD=password
3. 数据库迁移
php artisan migrate
composer dump-autoload
php artisan db:seed