码迷,mamicode.com
首页 > 数据库 > 详细

傻瓜式搭建php+nginx+mysql服务器环境

时间:2019-03-12 12:39:00      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:listening   rpm   stop   bsp   root用户   span   自己   with   log   

1.安装nginx

1.安装yum

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安装nginx

yum install -y nginx

3.启动nginx并设置开机自动运行

systemctl start nginx #启动,restart-重启,stop-停止

systemctl enable nginx #开机启动

4.查看版本及运行状态

nginx -v #查看版本

ps -ef | grep nginx #查看运行状态

2.安装php7

1.安装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

2.查看php7 yum组件,示例安装php7.2

yum search php72w

3.选择自己需要的组件安装,php72w.x86_64  php72w-fpm.x86_64 为核心程序必装

yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64

4.启动php并设为开机启动

systemctl start php-fpm #启动,restart-重启,stop-停止

systemctl enable php-fpm #开机启动

5.查看版本及运行状态

php-fpm -v #查看版本

ps -ef | grep php-fpm #查看运行状态

.修改nginx配置

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

找到第一个location中的这一行

index  index.html index.htm;

修改为:

index  index.php index.html index.htm; #添加index.php

2.

FastCGI server这行下面的location的注释去掉,并修改成下面这样子

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

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_params;

}

service nginx restart   #重启nginx

service php-fpm start   #开启php-fpm

3.

在网站根目录新建index.php文件

vim /usr/share/nginx/html/index.php

4.

输入内容:

<?php

phpinfo();

5.

在浏览器中输入虚拟机ip,已经可以看到phpinfo的信息了 

3.安装MYSQL
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum install mysql-community-server

//开启mysql
service mysqld start

//查看mysql的root账号的密码
grep ‘temporary password‘ /var/log/mysqld.log

//登录mysql
mysql -uroot -p

//修改密码
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘;

//修改root用户可远程登录
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;

//刷新
flush privileges;

 

转自:https://www.cnblogs.com/crazytata/p/9686490.html

https://www.cnblogs.com/ampl/p/9881660.html;

傻瓜式搭建php+nginx+mysql服务器环境

标签:listening   rpm   stop   bsp   root用户   span   自己   with   log   

原文地址:https://www.cnblogs.com/muzitoutou/p/10515740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!