centos7 安装php 与nginx环境简便方法(全程yum)

安装nginx:

1.yum -y install epel-release

2.rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm     ##更新安装包

3.yum -y install nginx  ##安装nginx

4. systemctl start nginx   ## 启动 nginx

    systemctl stop nginx       ## 关闭 nginx

    systemctl restart nginx    ## 重启 nginx

5. systemctl enable nginx.service##设置 nginx 服务开机自启动

安装php:

1.yum -y install epel-release

2.rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm##更新安装包

3.yum list php*##查看php版本

4.yum install php71w##安装php71(请根据上一步查看到的php实际情况选择名称 ,我的是 php71w)

5.yum list php71w-fpm##安装php-fpm

6.systemctl start php-fpm##之后 systemctl enable php-fpm 将php服务设置为启动

7.yum install php71w-cli##安装php客户端,支持控制台php命令

centos7及其以上系统。

##安装vimplus(建议在普通用户下安装)强大的vim编辑器

git clone https://github.com/chxuan/vimplus.git ~/.vimplus##复制文件包

cd ~/.vimplus     ##进入安装目录

./install.sh    ##安装vimplus

nginx 与php关联:

1.nginx -t ##查看nginx配置文件路径

在nginx配置文件中http模块中添加配置:

server {

listen 80;

server_namewww.nginx.com;

root /usr/share/nginx/html;

location / {

index index.html index.htm index.php;

}

location ~ .php(.*)$ {

# # With php-fpm (or other unix sockets):

# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

# # With php-cgi (or other tcp sockets):

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_split_path_info ^((?U).+.php)(/?.+)$;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

include fastcgi_params;

}

}

未经允许不得转载:PHP100中文网 - 中国第一档PHP资源分享门户 » centos7 安装php 与nginx环境简便方法(全程yum)

赞 (0) 打赏

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏