• 2-9-Mysql初步认实和搭建LAMP环境部署Ucenter和Ucenter-home网站


    学习一个服务的过程:
    1、 此服务器的概述:名字,功能,特点,端口号
    2、 安装
    3、 配置文件的位置
    4、 服务启劢关闭脚本,查看端口
    5、 此服务的使用方法
    6、 修改配置文件,实戓丼例
    7、 排错(从下到上,从内到外)

    本节所讲内容:
    •Mysql服务器常见概念
    •Mysql服务器安装及相关配置文件
    •实战:安装mysql数据库并去除安全隐患
    • 实战:搭建LAMP环境部署Ucenter和Ucenter-home网站
     
    服务端:xuegod63.cn IP:192.168.1.63
    客户端:xuegod64.cn IP:192.168.1.64
     
     
    MySQL服务概述:
    MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。
    MySQL是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(RelationalDatabase Management System:关系数据库管理系统)应用软件之一。
     
    MySQL是一种关联数据库管理系统,关联数据库将数据保存在丌同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
     
    MySQL所使用的SQL语言是用于访问数据库最常用标准化语言。MySQL软件采用了双授权政策,它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。由于其社区版的性能卓越,搭配PHP和Apache可组成良好的开发环境。
     
    双授权政策:开放源代码版本和商业版本。
    例如:很多公司出售应用软件,例如Microsoft、Apple和Oracle;
    Red HatIBM,则通过为其开放源代码软件提供销售支援、托管戒咨询等服务来进行赚钱。但鲜为人知的是,企业可以透过开放源代码发布仕们的软件,也可以同时销售该软件的商业版本。
     
    LAMP架构:
    Linux+Apache+Mysql+PHP
    官方网站:
    http://www.mysql.com/
     
    以rpm包的方式安装LAMP。
    一、安装需要的软件包
    [root@xuegod63 ~]#yum install httpd mysql-server mysql php php-mysql -y
    httpd # web服务器
    mysql-server#mysql数据库
    mysql # mysql服务器linux下客户端
    php #php相关文件
    php-mysql#???          #php程序连接mysql使用的模块
     
    查看一个包的作用
    查看php-mysql包作用
    1. [root@xuegod63 Packages]# rpm -pqi php-mysql-5.3.3-3.el6_1.3.x86_64.rpm
    2. warning: php-mysql-5.3.3-3.el6_1.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY 
    3. Name : php-mysql Relocations: (not relocatable) 
    4. Version : 5.3.3 Vendor: Red Hat, Inc. 
    5. Release : 3.el6_1.3 Build Date: Mon 24 Oct 2011 08:41:54 PM CST 
    6. Install Date: (not installed) Build Host: x86-004.build.bos.redhat.com 
    7. Group : Development/Languages Source RPM: php-5.3.3-3.el6_1.3.src.rpm 
    8. Size : 220619 License: PHP 
    9. Signature : RSA/8, Wed 02 Nov 2011 09:58:41 PM CST, Key ID 199e2f91fd431d51 
    10. Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> 
    11. URL : http://www.php.net/ 
    12. Summary : A module for PHP applications that use MySQL databases 百度翻译一下
     
    查看某个命令由哪个包安装
    1. [root@xuegod63 ~]#rpm -qf `which mysql `
     
    查看apache版本:
    1. [root@xuegod63 ~]#httpd -v
     
    查看mysql数据版客户端版本
    1. [root@xuegod63~]# mysql –V
     
    启劢服务LAMP相关服务:
    1. [root@xuegod63 ~]# service httpd restart 
    2. Stopping httpd: [FAILED] 
    3. Starting httpd: [ OK ] 
    4. [root@xuegod63 ~]# chkconfig httpd on 
    5. [root@xuegod63 ~]# service mysqld start 
    6. [root@xuegod63 ~]# chkconfig mysqld on
     
    测试数据库连接:
    连接mysql数据库,连接本机可以去掉-h
    #mysql
    戒:
    # mysql -h IP -uUSER -pPASS
    Mysql的超级管理员是root拥有最mysql数据库的最高权限。
    例:
    # mysql -u root
    mysql>exit;   #退出mysql 
     
     
    配置root密码
    1. [root@xuegod64~]# /usr/bin/mysqladmin -u root password "123456"
    测试:登录mysql
    1. [root@xuegod63kaixin]# mysql -u root -p
    或:
    1. [root@xuegod63kaixin]# mysql -u root -p123456
     
    MySQshowL安全配置向导
    安装完mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行几个设置:
      a)为root用户设置密码
      b)删除匿名账号
      c)取消root用户远程登录
      d)删除test库和对test库的访问权限
      e)刷新授权表使修改生效
    通过这几项的设置能够提高mysql库的安全。建议生产环境中mysql安装这完成后一定要运行一次mysql_secure_installation,详细步骤请参看下面的命令:
    NOTE: RUNNINGALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
    SERVERS IN PRODUCTION USE! PLEASE READ EACHSTEP CAREFULLY!
    In order to log into MySQL to secure it, we'llneed the current
    password for the root user. If you've justinstalled MySQL, and
    you haven't set the root password yet, thepassword will be blank,
    so you should just press enter here.
    Enter current password for root (enter fornone):
    <–初次运行直接回车
    OK, successfully used password, moving on…
    Setting the root password ensures that nobodycan log into the MySQL
    root user without the proper authorisation.
    Set root password? [Y/n] 
    <– 是否设置root用户密码刚才我已设置密码,我们输n
    ... skipping
    By default, aMySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have auser account created for
    them. This is intended only for testing, andto make the installation
    go a bit smoother. You should remove them beforemoving into a
    production environment.
    Remove anonymous users? [Y/n] 
    <– 是否删除匿名用户,生产环境建议删除,所以直接回车或Y
    … Success!
    Normally, root should only be allowed toconnect from 'localhost'. This
    ensures that someone cannot guess at the rootpassword from the network.
    Disallow root login remotely? [Y/n]
     <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
    … Success!
    By default, MySQL comes with a database named'test' that anyone can
    access. This is also intended only fortesting, and should be removed
    before moving into a production environment.
    Remove test database and access to it? [Y/n] 
    <– 是否删除test数据库,直接回车或Y
    - Dropping test database…
    … Success!
    - Removing privileges on test database…
    … Success!
    Reloading the privilege tables will ensurethat all changes made so far
    will take effect immediately.
    Reload privilege tables now? [Y/n] 
    <– 是否重新加载权限表,直接回车
    … Success!
    Cleaning up…
    All done! If you've completed all of the abovesteps, your MySQL
    installation should now be secure.
    Thanks for using MySQL!
     
    测试:
    1. [root@xuegod63 ~]# mysql -u root -p123456 
    2. mysql> show databases; #没有test数据库 #执行时,所有命令以;号结尾 
    3. +--------------------+ 
    4. | Database | 
    5. +--------------------+ 
    6. | information_schema | 
    7. | mysql | 
    8. | ucenter | 
    9. +--------------------+ 
    10. 3 rows in set (0.00 sec) 
    11. mysql> exit #退出命令可以加分号,也可以不加分号。
     
    测试网站是否支持PHP
    1. # cd /var/www/html/ 
    2. [root@stu003 html]# vim index.php 
    3. [root@stu003 html]# vim index.php 
    4. <?php 
    5. phpinfo(); 
    6. ?> 
    7. 测试:
    8. http://192.168.1.63/index.php


    测试:
    http://192.168.1.63/index.php
    搭建LAMP环境部署Ucenter和Ucenter-home网站,搭建一个类人人网的社交网站

    http://faq.comsenz.com/viewtopic/noviceguide/tab/prepare
    UCenter 用户中心实现用户的统一登录登出,积分的兑换,TAG的互通等,在安装UCenter Home、Discuz!、SupeSite、X-Space 等应用前必须先安装UCenter。本教程讲解的即是如何全新安装UCenter 1.5.0。
    http://www.discuz.net
    Discuz! 论坛,百万站长的选择,定会给您带来非凡的论坛体验。Discuz! 7.0.0 的推出使Discuz! 的用户体验又上升到了一个新的高度。本教程讲解的即是如何全新安装Discuz!7.0.0 FULL(集成了UCenter 安装的版本)。
    UCenterHome 个人家园,给社区中的会员一个可以安家的地方,在这里会员可以交朋友,写记录,发日志,贴照片,玩游戏...使会员可以牢牢的黏在你的社区里。本教程讲解的即是如何全新安装UCenterHome 1.5。
    SupeSite社区门户,实现CMS 的功能,拥有强大的模型功能,对Discuz! 和UCenter Home 的完美聚合,是您将社区中所有信息进行整合展示的最佳平台。本教程讲解的即是如何全新安装SupeSite
    7.0
    上传
    到服务器上/root目录下:
    1. [root@xuegod63 ~]# unzip -d ./ucenter UCenter_1.5.0_SC_UTF8.zip # 解压缩到./ucenter 
    2. [root@xuegod63 ~]# cd ./ucenter 
    3. [root@xuegod63 ucenter]# ls 
    4. advanced readme upload utilities 
    5. [root@xuegod63 ~]#mkdir /var/www/html/ucadmin   #创建目录
    6. [root@xuegod63 ucenter]# mv upload/ /var/www/html/ucadmin 
    7. [root@xuegod63 ucenter]# cd /var/www/html/ucadmin 
    8. [root@xuegod63 ucadmin]# ls 
    9. admin.php control images js plugin upgrade 
    10. api crossdomain.xml index.php lib release view 
    11. avatar.php data install model robots.txt 

    # robots.txt 网站根目录下,robots.txt 文件作用。
    Robots协议(也称为爬虫协议、机器人协议等)全称是网络爬虫排除标准(Robots Exclusion Protocol),网站通过Robots协议告诉搜索引擎哪些页面可以抓取,哪些页面不能抓取。
    robots.txt文件是一个文本文件,使用任何一个常见的文本编辑器,比如Windows系统自带的Notepad,就可以创建和编辑它[1] 。robots.txt是一个协议,而不是一个命令。robots.txt是搜索引擎中访问网站的时候要查看的第一个文件。robots.txt文件告诉蜘蛛程序在服务器上什么文件是可以被查看的。
    但robots.txt不是命令,也不是防火墙,如同守门人无法阻止窃贼等恶意闯入者。
     
    修改文件权限:
    1. [root@xuegod63 ucadmin]# ls -ld data 
    2. drwxrwxrwx 8 root root 4096 2009-01-22 data 
    3. [root@xuegod63 html]# ps -aux | grep httpd 
    4. Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 
    5. root 3736 0.0 0.7 260340 9040 ? Ss 20:06 0:00 /usr/sbin/httpd 
    6. apache 3741 0.0 0.6 260492 7412 ? S 20:06 0:00 /usr/sbin/httpd 
    7. apache 3742 0.0 0.5 260340 6296 ? S 20:06 0:00 /usr/sbin/httpd
    8. [root@xuegod63 html]# id apache 
    9. uid=48(apache) gid=48(apache) groups=48(apache) 
    10. [root@xuegod63 ucadmin]# chown apache:apache data/ -R 
    11. 或: 
    12. [root@xuegod63 ucadmin]# chmod -R 777 data # 

    为安全正确做法应该是chown –R apache:apachedata。后面安装好后测试。
     
    安装网站模版:
    安装UCenter:


    要安这个打开:
    1. [root@xuegod63 ~]# vim /etc/php.ini #php运用程序的配置文件 
    2. 改:229 short_open_tag = Off
    3. 为:230 short_open_tag = On
    开启PHP短标签功能。
    决定是否允许使用,代码开始标志的缩写形式(<? 。。。?>)
    PHP 代码开始标志的完整形式为:<?php。。。?>
    #重新加载配置文件
    1. [root@xuegod63 ~]# service httpd restart 
    2. Stopping httpd: [ OK ] 
    3. Starting httpd: [ OK ]



    需要这个data目录可写:

    注:这个注册码很不清楚,多按F5刷新几次就可以了
    要记录创始人用户名:UCenterAdministrator 密码:123456
    创建一个用户和密码。用于管理UCenter Home

    创建一个用户和密码

     
    第二步: 安装UCenter_Home_
    1. [root@xuegod63 ~]# unzip -d ./ucenter_home UCenter_Home_2.0_SC_UTF8.zip 
    2. [root@xuegod63 ~]# cd ucenter_home 
    3. [root@xuegod63 uchome]# ls 
    4. 2.0_changelog.txt readme.txt update upload 
    5. [root@xuegod63 uchome]# mv upload/* /var/www/html/   #拷贝过去也行
    6. [root@xuegod63 uchome]# cd /var/www/html/
    7. [root@xuegod63 html]# ls 
    8. admin cp.php index.php network.php userapp.php 
    9. admincp.php crossdomain.xml install rss.php ver.php 
    10. api data invite.php source xmlrpc.php 
    11. app.php do.php js.php space.php 
    12. attachment editor.php language template 
    13. common.php help.php link.php theme 
    14. config.new.php image magic.php uc_client 
    15. [root@xuegod63 html]# cp config.new.php config.php 
    16. [root@xuegod63 html]# chown apache:apache config.php 
    17. [root@xuegod63 html]# chown apache:apache  attachment/  data/  uc_client/ -R
     
    UCenter 的URL:http://192.168.1.63/ucadmin
    UCetter密码:123456
    配置httpd虚拟主机。
    1. vim /etc/hosts
    2. vim/etc/httpd/conf/httpd.conf 添加两个基于域名的虚拟主机。
    改:
    1. #NameVirtualHost
    2. *:80

    为:

    1. NameVirtualHost
    2. *:80
    添加两个虚拟主机
    第一个:
    1. <VirtualHost *:80>
    2. ServerAdmin webmaster@dummy-host.example.com
    3. DocumentRoot /var/www/html/ucadmin
    4. ServerName admin.xuegod.cn
    5. ErrorLog logs/dummy-host.example.com-error_log
    6. CustomLog logs/dummy-host.example.com-access_log common
    7. </VirtualHost>
    第二个:
    1. <VirtualHost *:80>
    2. ServerAdmin webmaster@dummy-host.example.com
    3. DocumentRoot /var/www/html/
    4. ServerName www.xuegod63.cn
    5. ErrorLog logs/dummy-host.example.com-error_log
    6. CustomLog logs/dummy
    7. </VirtualHost>
     

     这样就实现admin.xuegod.cn访问用户管理中心;www.xuegod.cn访问个人主页了。

  • 相关阅读:
    numpy中linspace用法 (等差数列创建函数)
    Ubuntu环境下 matplotlib 图例中文乱码
    转载: 广义逆矩阵
    matplotlib.pyplot中add_subplot方法参数111的含义
    转载:(论文) 二次指数平滑法中确定初始值的简便方法
    图像处理之 opencv 学习---opencv 中的常用算法
    图像处理之 opencv 学习---矩阵的操作
    编译异常之static和extern---more than one storage class specified
    格式转换至yuv422转 yuv420
    阶段3 3.SpringMVC·_02.参数绑定及自定义类型转换_6 自定义类型转换器代码编写
  • 原文地址:https://www.cnblogs.com/zhanghe9527/p/6893916.html
Copyright © 2020-2023  润新知