当前位置:首页 » 《资源分享》 » 正文

安装Mysql与nginx结合的小型服务_kali_yao的博客

4 人参与  2021年10月14日 09:03  分类 : 《资源分享》  评论

点击全文阅读


配置MySQL

1.准备网络yum源(准备物理机或一台虚拟机作为仓库服务器)

[root@zzgrhel8 ~]# yum install -y httpd php php-mysqlnd php-xml php-json createrepo
[root@zzgrhel8 ~]# systemctl start httpd
[root@zzgrhel8 ~]# systemctl enable httpd
[root@zzgrhel8 ~]# mkdir /var/www/html/mysql
[root@zzgrhel8 ~]# cd /linux-soft/4/mysql/
[root@zzgrhel8 ~]# tar xf mysql-5.7.17.tar -C /var/www/html/mysql/
[root@zzgrhel8 ~]# cd /var/www/html/mysql/
[root@zzgrhel8 mysql]# createrepo -d .

2.在mysql服务器上安装并启动mysql-community 5.7

[root@mysql1 ~]# vim /etc/yum.repos.d/mysql.repo
[mysql]
name=mysql5.7
baseurl=http://你主机的ip地址/mysql
enabled=1
gpgcheck=0
[root@mysql1 ~]# yum install mysql-community*
[root@mysql1 ~]# systemctl start mysqld
[root@mysql1 ~]# systemctl enable mysqld

3.修改mysql密码,导入案例数据库

# 启动Mysql服务时,自动生成了随机密码,写入日志mysqld.log。
# 在mysqld.log中查看生成的密码
[root@mysql1 ~]# grep -i password /var/log/mysqld.log
# 修改数据库的root用户密码为NSD2021@tedu.cn
[root@mysql1 ~]# mysqladmin -uroot -p'A8cCwrjefY(v' password NSD2021@tedu.cn
创建数据库

# 授权root用户可以通过任何地址访问
mysql> grant all on *.* to 'root'@'%' identified by 'NSD2021@tedu.cn';
# 创建名为mybbs的数据库
mysql> create database mybbs default charset utf8mb4;
mysql> use mybbs ;
# 创建名为posts的表,有四个字段,用于存储留言
mysql> create table posts( id int primary key auto_increment, title varchar(50), pub_date datetime,  content text);

配置nginx服务器

# 安装编译器
[root@nginx1 ~]# yum install -y gcc pcre-devel zlib-devel
​
# 编译安装nginx
[root@nginx1 ~]# tar xf nginx-1.12.2.tar.gz
[root@nginx1 ~]# cd nginx-1.12.2
[root@nginx1 nginx-1.12.2]# ./configure
[root@nginx1 nginx-1.12.2]# make && make install
​
# 安装并启动php-fpm
[root@nginx1 ~]# yum install -y php-fpm php-mysql
[root@nginx1 ~]# systemctl start php-fpm
[root@nginx1 ~]# systemctl enable php-fpm
​
# 修改配置文件
[root@nginx1 ~]# vim +65 /usr/local/nginx/conf/nginx.conf
       location ~ \.php$ {
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
       #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           include        fastcgi.conf;
       }
​
# 启动nginx服务
[root@nginx1 ~]# /usr/local/nginx/sbin/nginx -t  # 语法检查
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@nginx1 ~]# /usr/local/nginx/sbin/nginx

修改php首页

# 拷贝php_mysql_bbs目录下所有内容到nginx的文档目录
[root@nginx1 ~]# cp -r tedu_nsd/software/php_mysql_bbs/* /usr/local/nginx/html/
​
# 修改php页面,使其可以连接到数据库
[root@nginx1 ~]# cd /usr/local/nginx/html/
[root@nginx1 html]# vim index.php  # 只修改第2行
... ...
//以下函数的三个参数分别为:服务器地址、用户名、密码
$con = mysql_connect("localhost","root","NSD2021@tedu.cn");
... ...



# 使用浏览器访问http://web服务器地址/index.php


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/29862.html

修改  数据库  密码  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新文章

  • 女士的玩具推文_杜小灵白月光杜雪必读文_小说后续在线阅读_无删减免费完结_
  • 女儿要给我养老,我却反手把她告上法庭每日分享_林梦王浩养老一口气完结_小说后续在线阅读_无删减免费完结_
  • 闻妻有两意(林鹿小柿子)_闻妻有两意
  • 我的死党是刘秀?这皇位我不篡了(李哲王莽)全书免费_(李哲王莽)我的死党是刘秀?这皇位我不篡了后续(李哲王莽)
  • 逃荒路末世女王带着空间养儿女(周铁山王寡妇阿蛮)_逃荒路末世女王带着空间养儿女(周铁山王寡妇阿蛮)
  • 霍远凡肖灿续集(霍远凡肖灿)章节前文+全书阅读(丈夫逼我流产,我以死谢罪)最新连载
  • 老公给我13.14亲密付,我堕胎再婚后他悔疯了每日分享_苏暖顾川林晚晚超长版_小说后续在线阅读_无删减免费完结_
  • (白瑶,李玄胤,冰冷)白瑶,李玄胤,冰冷小说(九尾渡红尘)无套路无弹窗全部章节列表
  • (此去经年无故人)南初陆南城:结局+番外精品选集起点章节+阅读即将发布预订
  • 沈凝夏叶晚怡附加完整在线阅读(归雁不栖故人枝)最近更新列表
  • 剧情人物是时初,白浩雄的玄幻言情小说《召诸神,踏万界,天命帝女逆乾坤》,由网络作家&ldquo;海鸥&rdquo;所著,情节扣人心弦,本站TXT全本,欢迎阅读!本书共计381345字,185章节,:结局+番外免费品鉴:结局+番外评价五颗星
  • 凤青禾,江明远,***枢小说(别人修仙我捡漏,卷王们破防了)最近更新(凤青禾,江明远,***枢)整本无套路阅读

    关于我们 | 我要投稿 | 免责申明

    Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1