从零开始搭建linux下laravel 5.5所需环境(二)

我们已经装好了nginx,现在我们开始装mysql和php

我们同样使用yum来安装。

先安装MySQL软件(客户端、服务器端、依赖库)

yum install -y mysql mysql-server mysql-devel

然后设置自启动,报错

正确的安装方法以及错误原因参考这里

好了,到这里我们就安装好mysql了,下面我们开始安装php。

详细安装参考我的另一篇文章:Centos 6/ 7下通过yum安装php7环境

也可以参考另外一篇文章:yum安装新版php7.0 后来更新了,也可以安装7.2了

总结一下,首先是更新yum源,根据自己的CentOS版本来选择

CentOS/RHEL 7.x:

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

如果是centos6,那么执行以下代码: 
CentOS/RHEL 6.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

然后就可以yum安装PHP了

yum install php70w-common

要安装其他拓展的话上面文章里有,这里我已经安装好了laravel5.5所需的拓展了

//使用命令查看拓展
php -m

然后,我们配置一下nginx

vim /etc/nginx/nginx.conf
#这一段是最原始的配置,我们注释掉
#    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

#写入我们新的配置
server{
        listen 80;#监听端口
        server_name www.xxx.com,xxx.com;#域名
        index index.html index.htm index.php;
        root /home/wwwroot/phpinfo;#站点目录

        location ~ .*\.(php|php5)?$
        {
            #fastcgi_pass unix:/tmp/php-cgi.sock;
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           include fastcgi.conf;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
        {
           expires 30d;
           # access_log off;
        }
        location ~ .*\.(js|css)?$
        {
           expires 15d;
           # access_log off;
        }
        access_log off;
    }

然后重启nginx

service nginx restart

访问一下,可以了!(这里我提前在站点目录里写了一个php文件,没有写的可以写一个)

好的,至此环境就搭好了,下一篇我们准备安装larvael了,不太会写,有什么不对的地方还请大家留言指出,共同学习!

猜你喜欢

转载自www.cnblogs.com/blibli/p/9476948.html
今日推荐