上次中,记录了lamp的环境的搭建和安装,这一次说一下lnmp环境的安装和搭建,下面是详细的安装步骤:
一. 先是Mysql的安装步骤,其实和上次的一样:
1): 编译安装MySQL+-------------------------------------------------------------------------------+| 操作 | 作用 | +-------------------------------------------------------------------------------+|shell> cd /usr/local/src | 进入软件包所在目录(不要照抄) ||-------------------------------------------------------------------------------||shell> groupadd mysql | 增加mysql组(如果有就不用加了) ||-------------------------------------------------------------------------------||shell> useradd mysql -g mysql | 增加mysql用户,并属于mysql组 ||-------------------------------------------------------------------------------||shell> tar -xzvf mysql-5.1.30.tar.gz | 解压mysql源码包 ||-------------------------------------------------------------------------------||shell> cd mysql-5.1.30 | 进入源码包 ||-------------------------------------------------------------------------------||shell> ./configure --prefix=/usr/local/mysql | 配置mysql编译选项, || --with-charset=utf8 | 指定安装路径及支持的字符集 || --with-extra-charsets=gbk,gb2312,binary | ||-------------------------------------------------------------------------------||shell> make | 编译 ||-------------------------------------------------------------------------------||shell> make install | 安装 |+-------------------------------------------------------------------------------+2):配置并初始化MySQL+---------------------------------------------------------------------------------------+| 操作 | 作用 | +---------------------------------------------------------------------------------------+|shell> cp support-files/my-medium.cnf /etc/my.cnf | 把MySQL配置文件复制到/etc下 ||---------------------------------------------------------------------------------------||shell> vi /etc/my.cnf 在'skip_federated'前加'#'号 | 注释掉这个错误的启动项,这是一个比较新式的存储引擎||---------------------------------------------------------------------------------------||shell> cd /usr/local/mysql | 进入mysql的安装目录 ||---------------------------------------------------------------------------------------||shell> chown -R mysql.mysql . | 修改属主属组为mysql,才能完成 || | 下一步的初始化数据库工作 ||---------------------------------------------------------------------------------------||shell> bin/mysql_install_db --user=mysql | 初始化数据数据库 || --datadir=/usr/local/mysql/var | ||---------------------------------------------------------------------------------------||shell> chown -R root . | 把var目录修改为mysql用户所有 ||shell> chown -R mysql var | 其他文件修改为root所有,保证安全||---------------------------------------------------------------------------------------||shell> bin/mysqld_safe --user=mysql & | 启动mysql |+---------------------------------------------------------------------------------------+3):测试数据库+-------------------------------------------------+-------------------------------------+| 操作 | 作用 | +-------------------------------------------------+-------------------------------------+|shell> bin/mysql -uroot | 以root用户连mysql,无密码 ||---------------------------------------------------------------------------------------||mysql> show databases; | 显示数据库 ||---------------------------------------------------------------------------------------|| +--------------------+ | | | | Database | | || +--------------------+ | 看到左面的信息,数据库就安装 || | information_schema | | 并启动成功了! || | mysql | | || | test | | || +--------------------+ | |+---------------------------------------------------------------------------------------+4):接上步,修改mysql密码(可不做此步,默认无密码)+-------------------------------------------------------------------------------+| 操作 | 作用 | +-------------------------------------------------------------------------------+|mysql>UPDATE user SET | || password=PASSWORD('new_password') | 修改root用户的密码 || WHERE user='root'; | ||-------------------------------------------------------------------------------+|mysql>flush privileges; | 清空权限缓存 |+-------------------------------------------------------------------------------+