首页 > 代码库 > Lavarel下ngix和apache下运行

Lavarel下ngix和apache下运行

技术分享

 

[php] view plain copy

  1. 1.进入终端后查看php版本  
  2. php -v  
  3. 输出可能如下:  
  4. PHP 5.4.35 (cli) (built: Nov 14 2014 07:04:10) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies  
[php] view plain copy
 
  1. 2.执行下面的命令升级软件仓库  
  2.  rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm  
  3.  rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm  

[php] view plain copy
 
  1. 3.执行下面的命令删除php  
  2. yum remove php-common  
  3. 然后像安装那样问你是否继续的,输入yes即可  

[php] view plain copy
 
  1. 4.安装php 5.6版本(php56w-devel这个不是必需的)  
  2. yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring  

[php] view plain copy
 
  1. 5.重启httpd  
  2. service httpd restart  
  3. 查看最新的版本  
  4. php -v  
  5. 现在应该是5.6了!  
  apache环境下
CentOS 7安装Laravel:
 
添加两个仓库:
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
 
安装PHP:
yum install php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
 
安装apache和Mariadb:
yum install httpd mariadb mariadb-server
 
启动Mariadb服务:
systemctl start mariadb
systemctl enable mariadb
 
启动httpd服务:
systemctl start httpd
systemctl enable httpd
 
Mariadb数据库root密码默认为空,运行MySQL初始化脚本:
mysql_secure_installation
 
安装composer:
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer
 
从Github clone 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
 
创建.env配置文件:
mv .env.example .env
 
生成App key:
php artisan key:generate
技术分享
编辑config/app.php,把上面生成的key写入:
技术分享
 
配置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>
 
重启Apache服务:
systemctl restart httpd

 

Lavarel下ngix和apache下运行