centos php+mysql+nginx基础环境搭建

前端之家收集整理的这篇文章主要介绍了centos php+mysql+nginx基础环境搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

版本号

使用的是 centos6.7

中文输入法

yum install “@Chinese Support”

System->Input Method->Enable input method feature->Input Method
添加中文拼音后,重启系统即可

添加

这里主要使用yum安装方式,所以需要更新yum源

rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm  

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

关闭selinux

编辑

/etc/selinux/config
SELINUX=disabled #将参数改成这个

安装Nginx

yum install Nginx # 或者yum install Nginx18.x86_64
service Nginx start
chkconfig  Nginx on #设为开机启动

安装PHP

这里要安装PHP5.5以上
默认到源只能到5.3

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm 


yum install PHP55w.x86_64 PHP55w-cli.x86_64 PHP55w-common.x86_64 PHP55w-gd.x86_64 PHP55w-ldap.x86_64 PHP55w-mbstring.x86_64 PHP55w-mcrypt.x86_64 PHP55w-MysqL.x86_64 PHP55w-pdo.x86_64

yum install PHP55w-fpm 
chkconfig PHP-fpm on 
netstat -antpl (如果看到9000端口,PHP-FPM配置成功)

配置Nginx支持PHP

修改时区
vi /etc/PHP.ini #编辑
date.timezone = PRC

修改Nginx配置

# vi /etc/Nginx/conf.d/default.conf修改配置,添加以下配置
 location ~ \.PHP$ {
    root      your/web/path;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.PHP;
    fastcgi_param  SCRIPT_FILENAME  /your/web/path$fastcgi_script_name;
    include        fastcgi_params;
}
service Nginx reload

在默认目录下添加index.PHP

<?PHP PHPinfo(); ?>

访问localhost,配置正确则可以看见PHP配置页面

安装MysqL

安装源

wget http://repo.MysqL.com//MysqL57-community-release-el6-8.noarch.rpm

yum localinstall MysqL57-community-release-el6-8.noarch.rpm 

yum install MysqL-server

MysqLd_safe --skip-grant-tables#重置密码使用

update MysqL.user set authentication_string=password('123') where user='root' and Host = 'localhost';
flush privileges;


#登录以后会仍会报错,就使用以下命令再次重置密码
set global validate_password_policy=0;#降低密码验证等级
set password =password('root1234');

安装PHPmyadmin

yum install PHPmyadmin

配置Nginx
新建PHPmyadmin.conf,添加内容

server {
    listen       80 ;
    server_name  a.com;#自己的域名
    index       index.PHP;

    location / {
        root    /usr/share/PHPMyAdmin;#使用yum安装到目录
    }
    location ~ \.PHP$ {
        root /usr/share/PHPMyAdmin;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.PHP;
        fastcgi_param SCRIPT_FILENAME  /usr/share/PHPMyAdmin$fastcgi_script_name;

        include fastcgi_params;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
    location ~/\.ht{
        deny all;
    }
}

PHPstorm开启xdebug

yum install PHP-pecl-xdebug

#vi /etc/PHP.d/xdebug.ini
#添加以下代码
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_port=9999
output_buffering=off

xdebug.idekey=PHPSTORM

PHPstorm中,file->settings->PHP->debug->xdebug中port填写9999(和配置项中相同即可)

原文链接:https://www.f2er.com/centos/380764.html

猜你在找的CentOS相关文章