laravel安装配置

由于laravel需要许多配置环境,所以本教程从搭建lamp开始

环境更新

apt-get update

lamp搭建

1.安装apache2

apt-get install apache2

2.安装php5

apt-get install php5

3.安装mysql

apt-get install mysql-server mysql-client

4.安装linux下的mcrypt

apt-get install mcrypt

5.安装php下的mcrypt

apt-get install php5-mcrypt

6.安装 php扩展

apt-get install php5-mysql

7.修改mcrypt配置文件

cd /etc/php2/apache2/config.d 
ln -s   /etc/php5/mods-available/mcrypt/.ini   ./  (将对应文件链接到当前文件夹)
ls -l 查看

8.phpinfo 检查mcrypt mysql 是否全部安装成功

crtl + F ;

9.linux下载工具

apt-get install wget
apt-get install curl
apt-get install openssl

composer下载安装

1.下载

$ curl -sS https://getcomposer.org/installer | php     得到composer.phar

2.修改可执行权限

chmod +x ./composer.phar

3.将composer.phar移动到环境变量目录

mv composer.phar /bin/composer

4.查看

composer -v

laravel 安装和配置

1.下载创建目录(在/var/www/目录)

composer create-project --prefer-dist laravel/laravel community 5.1.*

等待时间略长 若出现绿色字样 Writing lock file 即安装成功

2.修改权限 storage和bootstrap/cache目录设置为可写

chmod -R a+w 目录名

3.设置apache默认路径

cd /etc/apache2/sites-available    //进入配置文件路径
cp 000-default.conf 000-default.conf.back    //复制配置文件
vim  将/var/www/html   修改为var/www/blog/public

4.重启apache

servive apache2 restart

5.访问ip,若出现laravel字样,安装成功

lnmp中的laravel配置

sudo vim /etc/php/7.0/fpm/php.ini  

输入/fix_pathinfo搜索,将cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0:

sudo vim /etc/php/7.0/fpm/pool.d/www.conf  

找到listen = /run/php/php7.1-fpm.sock修改为listen = 127.0.0.1:9000。使用9000端口。

service php7.1-fpm stop
service php7.1-fpm start

配置nginx配置文件

sudo vim /etc/nginx/sites-available/default  

修改成如下内容

    server {  
    #listen 80 default_server;
    listen 80;
    #listen [::]:80 default_server ipv6only=on;

    root /var/www/your-project-name/public;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name lufficc.com www.lufficc.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
    #
    #       # With php7.0-cgi alone:
            fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}

root:是你的项目的public目录,也就是网站的入口
index:添加了,index.php,告诉Nginx先解析index.php文件
server_name:你的域名,没有的话填写localhost
location / try_files修改为了try_files $uri $uri/ /index.php?$query_string;
location ~ .php$部分告诉Nginx怎么解析Php,原封不动复制即可,但注意:fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;的目录要和fpm的配置文件中的listen一致

参考链接

你可能感兴趣的:(laravel安装配置)