Table of Contents
CentOS下搭建PHP环境与WordPress博客程序的全流程总结,centoswordpress
Home php教程 php手册 CentOS下搭建PHP环境与WordPress博客程序的全流程总结,centoswordpress

CentOS下搭建PHP环境与WordPress博客程序的全流程总结,centoswordpress

Jun 13, 2016 am 08:41 AM
php wordpress

CentOS下搭建PHP环境与WordPress博客程序的全流程总结,centoswordpress

环境

  • 服务器操作系统:CentOS 7.0
  • 博客部署服务器:Apache
  • 后台语言:PHP
  • 数据库:MySql
  • 前端框架:WordPress

步骤

一、安装Apache

安装 Apache 很简单,只需要在终端输入以下命令就可以了:

sudo yum install httpd
Copy after login

sudo 的意思是用 root 用户做什么操作,yum install 是在线安装;然后输入 yes 就确认下载安装了。
安装完毕之后我们需要启动服务:

sudo service httpd start
Copy after login

当启动服务器完成之后,先别着急往下弄,可以直接在浏览器中输入服务器的 ip 地址,应该就可以看到 Apache 的欢迎页面了。
This page is used to test the operation of the Apache HTTP server after it has been installed………等等
如果你的 ip 地址已经和域名绑定了,那么在浏览器中输入你的域名也可以访问了,是不是很酷,就是这么简单,咱们继续。
二、安装 MySql
安装 MySql,并启动 MySql

sudo yum install mysql-server
sudo service mysqld start
Copy after login

通过上面的命令就可以安装并启动了 mysql,安装 mysql 的时候会询问你一些简单的配置,输入 enter 和 yes 一路下来就 OK 了。
三、安装 PHP 以及相关 PHP 组件
先安装 PHP

sudo yum install php php-mysql
Copy after login

安装 PHP 相关组件

yum install php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Copy after login

我先安装了这几个组件,为以后使用,你要想了解所有的 PHP 组件的话,可以使用如下命令搜索:

yum search php-
Copy after login

四、开机默认启动 Apache 和 Mysql 服务
使用如下命令即可选择开机启动 Apache 和 Mysql:

sudo chkconfig http on
sudo chkconfig mysql on
Copy after login

五、测试 PHP 是否安装成功
建立一个 info.php 文件:

sudo vim /var/www/html/info.php
Copy after login

然后输入 i 进入编辑模式,在文件中写入下面的 PHP 命令:

<&#63;php
phpinfo();
&#63;>
Copy after login

然后按 esc 键进入命令模式, 按下 Shift 键和两次 z 键,就退出保存文件。
在浏览器中输入 IP地址/info.php,例如:123.56.183.34/info.php 回车,就可以看到 PHP 的信息了。
六、下载 WordPress
中文官方网站是cn.wordpress.org
通过下面的命令下载:

wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip
Copy after login

七、解压
使用 unzip 来解压文件:

unzip wordpress-3.8-zh_CN.zip
Copy after login

八、在 Mysql 中新建数据库

mysql -u root -p
Copy after login

通过上面的命令进入数据库,然后输入密码:password
然后创建一个叫 wordpress 的数据库

create database wordpress;
Copy after login

九、修改 wp-content.php 文件
按照下面的形式修改 wp-content.php 文件,

/** MySQL数据库名:wordpress */
define(‘DB_NAME', ‘wordpress'); 
/** MySQL数据库用户名 :root*/
define(‘DB_USER', ‘root'); 
/** MySQL数据库密码 :password*/
define(‘DB_PASSWORD', ‘password');
/** MySQL主机(不用修改) */
define(‘DB_HOST', ‘localhost');
Copy after login

十、把文件复制到 /var/www/html 目录下

cp -rf wordpress/* /var/www/html/
Copy after login

十一、测试
在浏览器中输入服务器的 ip 即可查看到自己主页。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

CakePHP Logging CakePHP Logging Sep 10, 2024 pm 05:26 PM

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles