centos 7.4安装nginx + php7.2 +mysql5.6

1、 查看centos 版本

 

cat /etc/redhat-release

2、 安装nginx

yum install nginx

 

3、设置nginx开启起动

systemctl start nginx

4、测试访问http://你的域名或IP/

    centos 7.4安装nginx + php7.2 +mysql5.6_第1张图片

    如果访问不了,查看一下阿里云的开放端口是否含有80端口。

centos 7.4安装nginx + php7.2 +mysql5.6_第2张图片

5、 查看nginx安装位置

sudo find / -name nginx

centos 7.4安装nginx + php7.2 +mysql5.6_第3张图片

 

6、 安装php

 

通过yum list php*查看是否有自己需要安装的版本,如果没有就需要添加第三方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

7、 选择自己需要的php版本号

yum install php72w-common

8、 安装mysql

 

CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件,需要去官网上下载 

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

成功安装之后重启mysql服务

 # service mysqld restart

初次安装mysql是root账户是没有密码的

设置密码的方法

 # mysql -u root

mysql > set password for 'root'@'localhost' = password('666');

mysql> exit

9、安装php-fpm

sudo yum search php72
yum install php72w-fpm

10、配置php处理器

vim /etc/php.ini

查找cgi.fix_pathinfo
将 ;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0

 

 

 

 

11、配置www.conf

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


user = nobody
group = nobody
改为
user = nginx
group = nginx

 

前提是已经创建了nginx用户和nginx组。

 

11、起动php-fpm

systemctl start php-fpm

12、设置php-fpm开机启动

systemctl enable php-fpm

 

 

13、配置nginx

打开/etc/nginx/nginx.conf

    include /etc/nginx/conf.d/*.conf;
    index index.php index.html index.htm;
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;  
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location ~ .php$ {
                try_files $uri =404;
                root /usr/share/nginx/html;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi.conf;
        }
        error_page 404 /404.html;
        location = /404.html {

        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

13、访问http://你的IP/index.php,正常情况下会出现

centos 7.4安装nginx + php7.2 +mysql5.6_第4张图片

 

14、开启php报错信息

vim /etc/php.ini 

centos 7.4安装nginx + php7.2 +mysql5.6_第5张图片

 

15、重启php-fpm

service php-fpm restart

 

你可能感兴趣的:(系统类)