Home > php教程 > php手册 > body text

Centos下mysql+PHP环境搭建

WBOY
Release: 2016-06-06 19:52:10
Original
971 people have browsed it

所需软件 httpd mysql mysql-server php php-devel php-mysql phpMyAdmin 上面的前6项,yum一下就有了,都是默认安装。而phpMyAdmin提供了链接,手动安装。 Apache的基本配置 /etc/httpd/conf/httpd.conf 是apache的主要配置文件,修改基本的参数就OK,这里

所需软件

  1. httpd
  2. mysql
  3. mysql-server
  4. php
  5. php-devel
  6. php-mysql
  7. phpMyAdminCentos下mysql+PHP环境搭建

上面的前6项,yum一下就有了,都是默认安装。而phpMyAdmin提供了链接,手动安装。

Apache的基本配置

  1. /etc/httpd/conf/httpd.conf 是apache的主要配置文件,修改基本的参数就OK,这里对于IP就是localhost了。
  2. //www/html 是CentOS默认的“首页”所在目录,输入"http://localhost"时候所显示的数据。
  3. 其余的Apache配置在这里不需要,所以不详细介绍。
  4. Apache的启动 /etc/init.d/httpd start关闭/etc/init.d/httpd stop。测试 netstat -tunl | grep ‘:80’

php测试

可以在 /var/www/html/ 下面写入php文件,这里写一个测试文件

vim /etc/www/html/phpinfo.php

<?php phpinfo(); ?>
Copy after login

然后在浏览器输入http://localhost/phpinfo.php 若显示出基本信息则代表OK。

Mysql的启动和测试

  1. Mysql的启动:/etc/init.dmysqld start
  2. 测试:netstat -tunl | grep ':3306'
  3. 手动连接mysql : mysql -u root
  4. 设置root密码登入: mysqladmin -u root password 'password'
  5. 登入:mysql -u root -p
  6. 登入到mysql后,通过create database wordpress ; (注意加分号)创建一个数据库
  7. show databases ;查看数据库
  8. exit 退出

安装wordpress

  1. 解压woordpress.tar.bz2到 /var/www/html/目录下
  2. cp wp-config-sample.php  wp-config.php  备份配置文件
  3. # vi wp-config.php  #编辑配置文件,输入数据库名、用户名以及密码
    // ** MySQL设置 - 具体信息来自您正在使用的主机 ** //
    /** WordPress数据库的名称,替换掉 “putyourdbnamehere” */

    define('DB_NAME', 'wordpress');
    /** MySQL数据库用户名,替换掉 “usernamehere” */
    define('DB_USER', 'root');
    /** MySQL数据库密码,替换掉 “yourpasswordhere” */
    define('DB_PASSWORD', 'password');

安装phpmyadmin

    1. 把phpmyadmin的压缩文件解压到 /var/www/html/
    2. cd /var/www/html/phpMyAdmin/phpMyAdmin-3.4.10.1-all-languages/
      #进入到配置目录
    3. cp config.sample.inc.php config.inc.php #备份配置文件
    4. vi config.inc.php
      修改
      // $cfg['Servers'][$i]['controluser'] = 'pma';
      // $cfg['Servers'][$i]['controlpass'] = 'pmapass';

      $cfg['Servers'][$i]['controluser'] = 'root';  #mysql登录用户名
      $cfg['Servers'][$i]['controlpass'] = 'password';  #mysql登录密码
    5. 测试 :http://127.0.0.1/phpMyAdmin/phpMyAdmin-3.4.10.1-all-languages/
    6. 用帐号和密码登入,在这里面可以操作你的数据库,对于wordpress,我们已经在在命令行里建立了。

接下来就可以配置wordpress了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!