美文网首页我爱编程
LEMP服务器搭建二(PHP,MYSQL配置)

LEMP服务器搭建二(PHP,MYSQL配置)

作者: 心无执着 | 来源:发表于2017-04-18 14:35 被阅读0次

一、mysql的安装

1.下载mysql的repo源

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

2.安装mysql-community-release-el7-5.noarch.rpm包

(安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo)

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

3.安装mysql

#yum install mysql-server

4.重置密码

更改用户权限:

#chown -R root:root /var/lib/mysql

重启mysql:

#systemctl restart mysql.service

登陆mysql:

#mysql -u root

mysql> use mysql;

修改密码

mysql> update user set password=password('123456') where User='root';

赋权限给root,可用Navicat for MySQL访问数据库

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

mysql>flush privileges;

mysql> exit;

二、PHP的安装

1.安装epel

#yum install epel-release

2.安装php yum源

#rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm

3.安装php及扩展

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

4.安装php管理

#yum install php70w-fpm

三、配置nginx

1.修改nginx配置文件

#vi /usr/local/nginx/conf/nginx.conf

location ~.php$ {#匹配以.php结尾的url,~为任意字符串,$表示结束

​ fastcgi_pass 127.0.0.1:9000;

​ fastcgi_index index.php;

​fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

​ include    fastcgi_params;

​ }

2.修改php-fpm配置文件

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

user = apache

group = apache

修改为

user = www

​ group = www

重启nginx

#/usr/local/nginx/sbin/nginx -s reload

开启php-fpm

#systemctl start php-fpm.service

开启错误打印

#vi /etc/php.ini

display_errors = On

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

php_flag[display_errors] = on

#systemctl restart php-fpm.service



PHP,MYSQL完成

下一篇《LEMP服务器搭建三(swool扩展,websocket的小案例)》


相关文章

网友评论

    本文标题:LEMP服务器搭建二(PHP,MYSQL配置)

    本文链接:https://www.haomeiwen.com/subject/ewpfzttx.html