2trdwq 发表于 2014-12-19 08:45:34

CentOS6.4+Apache+Mariadb+PHP搭建WordPress

---- LAMP ==> Linux Apache Mariadb PHP

-----安装前准备工作:

1
2
3
4
5
6
7
8
yum -y install gcc gcc-c++ zlib libxml2-devel libxml2 libmcrypt libmcrypt-devel libltdl libltdl-devel libpng libpng-devel freetype autoconf gd gd-devel ncurses*
--install jpeg
wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
tar -zxvf jpegsrc.v9a.tar.gz
cd jpeg-9a/
./configure --prefix=/data/server/jpeg
make
make install





------------ 安装 Mariadb
创建Mariadb运行账号:

1
2
groupadd mysql
useradd mysql -g mysql





要编译mariadb需要用到cmake

1
yum -y install cmake




如果没有,则到官网下载最新的:http://www.cmake.org/

1
2
3
4
tar xfcmake-x.x.tar.gz
cd cmake-x.x
./bootstrap
make && make install







1.源码安装:

1
2
3
4
5
wget http://mirror.mephi.ru/mariadb/mariadb-10.0.14/source/mariadb-10.0.14.tar.gz
tar -zxvf mariadb-10.0.14.tar.gz
cd mariadb-10.0.14
cmake . -DCMAKE_INSTALL_PREFIX=/data/server/mariadb -DMYSQL_DATADIR=/data/mariadb -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_SSL=system
make && make install






2.yum安装:
该文件的内容是参考官网,并从官网上生成的,设置安装源仓库的 具体的地址为:

https://downloads.mariadb.org/mariadb/repositories/
将下面代码添加到yum源中:

1
2
3
4
5
6
7
# MariaDB 10.1 CentOS repository list - created 2014-12-03 03:10 UTC
# http://mariadb.org/mariadb/repositories/

name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1






1
2
3
yum -y install MariaDB-server MariaDB-client
service mysql start
mysql -uroot -p# 默认密码为空







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.0-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database         |
+--------------------+
| information_schema |
| mysql            |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]>
MariaDB [(none)]> status;
--------------
mysqlVer 15.1 Distrib 10.1.0-MariaDB, for Linux (i686) using readline 5.1
Connection id:          7
Current database:
Current user:         root@localhost
SSL:                  Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:      ;
Server:               MariaDB
Server version:         10.1.0-MariaDB MariaDB Server
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db   characterset:    latin1
Client characterset:    utf8
Conn.characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:               7 min 56 sec
Threads: 1Questions: 20Slow queries: 0Opens: 0Flush tables: 1Open tables: 26Queries per second avg: 0.042
--------------






修改root密码:

1
mysqladmin -u root password 'test123'




修改数据存放目录:

1
service mysql stop




创建新的db目录:


1
mkdir /data/mariadb




拷贝默认数据库到新的位置:

1
cp -a /var/lib/mysql /data/mariadb




备份原来的配置文件:


1
2
cp -a /etc/my.cnf /etc/my.cnf_bak    # 该文件里面只是一条包含语句,真正要备份的是下面这个文件:
cp /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.cnf_bak





1
2
3
4
5
6
7
8
9
10
11
cat /etc/my.cnf.d/server.cnf |grep -v ^#


datadir = /data/mariadb/mysql
socket = /var/lib/mysql/mysql.sock
character_set_server = utf8




service mysql start    #启动Mariadb







------------ 安装Apache
wget http://apache.communilink.net//httpd/httpd-2.4.10.tar.bz2
wget http://ftp.cuhk.edu.hk/pub/packages/apache.org//apr/apr-1.5.1.tar.bz2
wget http://ftp.cuhk.edu.hk/pub/packages/apache.org//apr/apr-util-1.5.4.tar.bz2


1
2
3
4
5
6
7
8
9
10
11
12
13
tar -jxf apr-1.5.1.tar.bz2
cd apr-1.5.1
./configure --prefix=/data/server/apr --disable-ipv6
make && make install
tar -jxf apr-util-1.5.4.tar.bz2
cd apr-util-1.5.4
./configure --prefix=/data/server/apr-util --with-apr=/data/server/apr
make && make install
tar -jxf httpd-2.4.10.tar.bz2
cd httpd-2.4.10
./configure --prefix=/data/server/apache --enable-http --enable-ssl --enable-vhost-alias --enable-rewrite --with-apr=/data/server/apr --with-apr-util=/data/server/apr-util
make
make install




测试:

1
2
# curl http://127.0.0.1/
<html><body><h1>It works!</h1></body></html>




----------- 安装PHP


1
2
3
4
5
6
7
wgethttp://hk1.php.net/distributions/php-5.6.3.tar.bz2
tar -jxf php-5.6.3.tar.bz2
cd php-5.6.3
./configure --prefix=/data/server/php --with-apxs2=/data/server/apache/bin/apxs --disable-ipv6 --with-zlib --with-gd --with-jpeg-dir=/data/server/jpeg --with-png-dir --with-zlib-dir --with-freetype-dir --with-mysql --with-mysqli --enable-embedded-mysqli --enable-zip --enable-mysqlnd --with-gd
make
make install
cp ./php.ini-production /data/server/php/lib/php.ini






修改php默认时区:


1
2
vim /data/server/php/lib/php.ini
date.timezone = Asia/Shanghai# 去掉该参数注释,并设置时区为亚洲上海




修改apache配置文件,使其可以解析php程序:


1
2
3
4
5
AddType application/x-httpd-php .php# 在相应的地方添加该行
<IfModule dir_module>
DirectoryIndex index.html index.php# 添加:index.php
</IfModule>
LoadModule php5_module      modules/libphp5.so# 一般默认会添加,如果没有,自己手动添加到相应地方






----- 创建数据库:


1
2
3
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> grant all privileges on wordpress.* to wordpress2014@'localhost' identified by "mYbl0G@2014" with grant option ;
MariaDB [(none)]> flush privileges;




----- 创建wordpress


1
2
3
wget https://cn.wordpress.org/wordpress-4.0.1-zh_CN.tar.gz
tar -zxf wordpress-4.0.1-zh_CN.tar.gz
cp -ar wordpress /data/www/




http://localhost/wordpress/wp-admin

填写好数据库信息,提交,2分钟OK

页: [1]
查看完整版本: CentOS6.4+Apache+Mariadb+PHP搭建WordPress