Centos7 yum安装php的方法

 4159

Centos7 yum安装php的方法:首先安装nginx以及MYSQL;然后通过命令“yum install php71w php71w-fpm php71w-cli php71w-common...”安装php以及扩展即可。


5f7d45c27c9a0.jpg


Centos7 yum快速安装php7.1

1、安装nginx

  1. yum install nginx
  2. ##开启nginx
  3. service nginx start

2、安装MYSQL

  1. yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  2. yum install mysql-community-server
  3. //开启mysql
  4. service mysqld start
  5. //查看mysql的root账号的密码
  6. grep 'temporary password' /var/log/mysqld.log
  7. //登录mysql
  8. mysql -uroot -p
  9. //修改密码
  10. ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
  11. //修改root用户可远程登录
  12. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  13. //刷新
  14. flush privileges;

3、安装php

  1. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  3. //查看
  4. yum search php71w
  5. //安装php以及扩展
  6. yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
  7. //开启服务
  8. service php-fpm start
  9. //修改/etc/nginx/nginx.conf 使其支持php 见下
  10. //重启nginx
  11. service nginx restart
  12. ---------------------配置
  1. server {
  2.     charset utf-8;
  3.     client_max_body_size 128M;
  4.     listen 80; ## listen for ipv4
  5.     server_name localhost;
  6.     root /var/www/;
  7.     index index.php;
  8.     location / {
  9.         if (!-e $request_filename){
  10.             rewrite ^/(.*)$ /index.php/$1 last;
  11.         }
  12.         try_files $uri $uri/ /index.php?$args;
  13.     }
  14.     location ~ \.php$ {
  15.         include fastcgi.conf;
  16.         fastcgi_pass 127.0.0.1:9000;
  17.         try_files $uri =404;
  18.     }
  19.     location ~ \.php {
  20.         fastcgi_pass 127.0.0.1:9000;
  21.         fastcgi_index index.php;
  22.         include /etc/fastcgi_params;
  23.         fastcgi_split_path_info ^(.+\.php)(/?.*)$;
  24.         fastcgi_param SCRIPT_FILENAME
  25.         fastcgi_param PATH_INFO $fastcgi_path_info;
  26.         fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  27.     }
  28.     error_page 404 /404.html;
  29.     location ~ /\.(ht|svn|git) {
  30.         deny all;
  31.     }
  32. }

4、安装redis

  1. yum install redis
  2. //修改配置 
  3. vi /etc/redis.conf
  4. //daemonize yes 后台运行
  5. //appendonly yes 数据持久化
  6. service redis start

5、安装php-redis扩展

  1. //先装git
  2. yum install git
  3. //git下扩展
  4. cd /usr/local/src
  5. git clone https://github.com/phpredis/phpredis.git
  6. //安装扩展
  7. cd phpredis
  8. phpize
  9. //修改php配置
  10. vi /etc/php.ini 添加extension=redis.so
  11. //重启php
  12. service php-fpm restart




TAG标签:
本文网址:https://www.zztuku.com/detail-7955.html
站长图库 - Centos7 yum安装php的方法
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐

    九个魔法元素矢量素材
    YII怎么输出sql语句?