Linux下安装php

  • rpm 安装 Php7 相应的 yum源

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

  • 安装php7.0

yum install -y php70w

  • 安装php扩展

yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64

  • 安装PHP FPM

yum install -y php70w-fpm

修改php-fpm配置文件

  • php-fpm配置文件位置:(/etc/php-fpm.d/www.conf)
    ​ * 修改

user =nginx
​ group=nginx

在nginx.conf配置php

//在 location / { }下面增加
location ~ \.php$ {
                        root /usr/share/nginx/html; #指定php的根目录
                        fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                }

启动nginx服务

  • 启动nginx服务

systemctl start nginx.service

  • 查看启动状态

systemctl status nginx
看到以下字眼说明启动成功!
​Active: active (running) since 六 2016-11-19 13:40:04 CST; 50min ago

你可能感兴趣的:(Linux下安装php)