---- LAMP ==> Linux Apache Mariadb PHP
-----安装前准备工作:
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 jpegwget http://www.ijg.org/files/jpegsrc.v9a.tar.gztar -zxvf jpegsrc.v9a.tar.gzcd jpeg-9a/./configure --prefix=/data/server/jpegmakemake install
------------ 安装 Mariadb
创建Mariadb运行账号:
groupadd mysqluseradd mysql -g mysql
要编译mariadb需要用到cmake
yum -y install cmake
如果没有,则到官网下载最新的:http://www.cmake.org/
tar xf cmake-x.x.tar.gzcd cmake-x.x./bootstrapmake && make install
1.源码安装:
wget http://mirror.mephi.ru/mariadb/mariadb-10.0.14/source/mariadb-10.0.14.tar.gztar -zxvf mariadb-10.0.14.tar.gzcd mariadb-10.0.14cmake . -DCMAKE_INSTALL_PREFIX=/data/server/mariadb -DMYSQL_DATADIR=/data/mariadb -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_SSL=system make && make install
2.yum安装:
该文件的内容是参考官网,并从官网上生成的,设置安装源仓库的 具体的地址为:
将下面代码添加到yum源中:
# MariaDB 10.1 CentOS repository list - created 2014-12-03 03:10 UTC# http://mariadb.org/mariadb/repositories/[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/10.1/centos6-x86gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1
yum -y install MariaDB-server MariaDB-clientservice mysql startmysql -uroot -p# 默认密码为空
[root@MyServer ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 3Server version: 10.1.0-MariaDB MariaDB ServerCopyright (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;--------------mysql Ver 15.1 Distrib 10.1.0-MariaDB, for Linux (i686) using readline 5.1Connection id: 7Current database:Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server: MariaDBServer version: 10.1.0-MariaDB MariaDB ServerProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: utf8Conn. characterset: utf8UNIX socket: /var/lib/mysql/mysql.sockUptime: 7 min 56 secThreads: 1 Questions: 20 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 26 Queries per second avg: 0.042--------------
修改root密码:
mysqladmin -u root password 'test123'
修改数据存放目录:
service mysql stop
创建新的db目录:
mkdir /data/mariadb
拷贝默认数据库到新的位置:
cp -a /var/lib/mysql /data/mariadb
备份原来的配置文件:
cp -a /etc/my.cnf /etc/my.cnf_bak # 该文件里面只是一条包含语句,真正要备份的是下面这个文件:cp /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.cnf_bak
cat /etc/my.cnf.d/server.cnf |grep -v ^#[server][mysqld]datadir = /data/mariadb/mysqlsocket = /var/lib/mysql/mysql.sock character_set_server = utf8 [embedded][mariadb][mariadb-10.1]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
tar -jxf apr-1.5.1.tar.bz2cd apr-1.5.1./configure --prefix=/data/server/apr --disable-ipv6make && make installtar -jxf apr-util-1.5.4.tar.bz2cd apr-util-1.5.4./configure --prefix=/data/server/apr-util --with-apr=/data/server/aprmake && make installtar -jxf httpd-2.4.10.tar.bz2cd 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-utilmakemake install
测试:
[root@MyServer opt]# curl http://127.0.0.1/It works!
----------- 安装PHP
wget http://hk1.php.net/distributions/php-5.6.3.tar.bz2tar -jxf php-5.6.3.tar.bz2cd 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-gdmakemake installcp ./php.ini-production /data/server/php/lib/php.ini
修改php默认时区:
vim /data/server/php/lib/php.inidate.timezone = Asia/Shanghai # 去掉该参数注释,并设置时区为亚洲上海
修改apache配置文件,使其可以解析php程序:
AddType application/x-httpd-php .php# 在相应的地方添加该行DirectoryIndex index.html index.php# 添加:index.phpLoadModule php5_module modules/libphp5.so# 一般默认会添加,如果没有,自己手动添加到相应地方
----- 创建数据库:
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
wget https://cn.wordpress.org/wordpress-4.0.1-zh_CN.tar.gztar -zxf wordpress-4.0.1-zh_CN.tar.gzcp -ar wordpress /data/www/
http://localhost/wordpress/wp-admin
填写好数据库信息,提交,2分钟OK