centos7配置php服务器,centos7 php7+nginx服务器配置

标签:

主机:centos7.5

打开终端:

yum update

yum install epel-release

安装nginx:

yum install nginx

systemctl start nginx

systemctl enable nginx

安装MariaDB 10:

添加源:

vi /etc/yum.repos.d/MariaDB.repo

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

安装数据库并设置密码:

yum install MariaDB-server MariaDB-client

systemctl start mariadb

mysql_secure_installation

systemctl enable mariadb

安装php

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install php70w

安装php及其他拓展:

yum install php70w-xml php70w-soap php70w-xmlrpc php70w-mbstring php70w-json php70w-gd php70w-mcrypt php70w-mysql

yum install php70w-intl php70w-tidy

yum install php70w-pecl-redis

yum install php-pecl-mongodb

yum install php70w-fpm

yum install php70w-devel php70w-pear

yum install php70w-pecl-apcu php70w-opcache

修改php.ini

vi /etc/php.ini

find cgi.fix_pathinfo=1 and then replace it with cgi.fix_pathinfo=0

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

1.

listen = /var/run/php-fpm/php-fpm.sock

2.

listen.owner = nginx

listen.group = nginx

3.

user = nginx

group = nginx

开启php-fpm:

systemctl start php-fpm

Enable it to boot

systemctl enable php-fpm

配置nginx配置文件

vi /etc/nginx/conf.d/default.conf

server {

listen 80;

server_name localhost;

# note that these lines are originally from the "location /" block

root /usr/share/nginx/html;

index index.php index.html index.htm;

location / {

try_files $uri $uri/ =404;

}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

location ~ \.php$ {

try_files $uri =404;

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

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

如果你发现存在permission denied等问题

chown nginx:nginx /var/run/php-fpm/php-fpm.sock

chown nginx:nginx -R /usr/share/nginx/html

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

标签:

来源: https://blog.csdn.net/My_Idiot/article/details/82862253

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值