Centos7下thinkphp5.0环境配置

首先把yum源修改为阿里的yum源,如果没有安装wget,先安装一个。(如果有请蹦过)

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install wget -y

备份本地yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak

获取阿里yum源配置文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

安装epel源

yum install epel-release

安装环境

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install php php-fpm php-mysql nginx mariadb-server php-gd* -y

修改php-fpm文件

vi /etc/php-fpm.d/www.conf

 启动服务

systemctl start php-fpm
systemctl start nginx

简单配置 数据库

systemctl start mariadb
mysql_secure_installation
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: # 再输入一次你设置的密码
Remove anonymous users? [Y/n] # 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] #是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] # 是否删除test数据库,回车
Reload privilege tables now? [Y/n] # 是否重新加载权限表,回车

root 用户支持远程访问

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;

配置Nginx文件

新建配置文件

vi /etc/nginx/conf.d/www.a.com.conf

文件内容

server {

  listen 80;
  server_name www.a.com;
  set $root /var/www/myweb;
  
  #listen 443 ssl;
  #ssl_certificate *.pem;
  #ssl_certificate_key *.key;
  #ssl_session_timeout 5m;
  #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  #ssl_prefer_server_ciphers on;
  
  location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
    root $root;
    client_max_body_size 100M;
  }
  location / {
    index index.php;
    if (!-e $request_filename) {
      rewrite ^/(.*)$ /index.php/$1 last;
      break;
    }
    root $root;
    client_max_body_size 100M;
  }
  location ~ \.php/?.*$ {
    root $root;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;

    set $fastcgi_script_name2 $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
      set $fastcgi_script_name2 $1;
      set $path_info $2;
    }
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
    client_max_body_size 100M;
  }
   include /etc/nginx/mime.types;
    default_type application/octet-stream;

  }

重新加载配置文件

nginx -s relaod

 

posted @ 2020-04-09 15:54  不懂相处  阅读(612)  评论(0编辑  收藏  举报