CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001

时间:2022-09-23 13:11:22



httpd与php结合的方式有三种:

1、module:将php编译成httpd的模块,当Apache服务器收到客户端的动态资源请求时,httpd服务自身便可以依靠php模块来处理动态资源。

2、cgi:此种方式是当Apache服务器,每次收到客户端发来的动态资源请求时,将调用php生成一个子进程来处理客户端所请求的动态资源,因此n个请求便会在服务器端启动2n个进程,是对服务器资源极大程度的浪费,因此,此种结合方式很少用。

3、fpm:此种方式是基于fastcgi协议,php作为一个服务监听在某个套接字上,当Apache客户端解析到客户端所请求的资源是动态资源是,便将请求发送给php服务,由php服务处理动态内容,并响应给httpd服务,再由httpd服务将结果返回给客户端。此时的Apache服务器便是一个代理服务器。httpd2.4版本新增了一个mod_fcgi模块,此模块便是可让httpd与php基于fpm方式结合,httpd2.2版本若想基于fpm方式与httpd结合,需自行安装fcgi模块。


本机版本及IP地址信息:

[root@localhost ~]# uname -r2.6.32-504.el6.x86_64
[root@localhost ~]# cat /etc/redhat-release 
CentOS release 6.6 (Final)
[root@localhost ~]# ip addr show | awk -F'[ /]+' '/inet\>/&&!/127.0.0.1/ {print $3}'
172.16.113.14



安装次序:

   1、由于pgp与httpd若与模块方式结合,那么首先得现有httpd才能将php编译进httpd的内核

   2、若编译php支持mariadb的驱动,首先需要知道Mariadb的安装位置及其版本,才能编译相应的驱动。

因此,编译次序为 httpd---- > MariaDB --- >php ,mariadb和httpd的安装次序不分前后。



a、关闭iptables    //若对iptables规则熟悉,可忽略此条信息

b、关闭selinux    

        [root@localhost ~]# sed -i 's/\(SELINUX=\).\+/\1disabled/' /etc/sysconfig/selinux        [root@localhost ~]# setenforce 0

c、准备开发环境(需提前配置好yum源)

        Development tools

        Server Platform Development


A、将php编译进httpd的模块,实现LAMP结合,并搭建phpMyadmin,实现数据库图形借口管理


需要的源码包:

1、httpd-2.4.9.tar.bz2----httpd的源码包,由Apache官网下载  http://www.apache.org/

2、php-5.6.4.tar.xz    -----php的源码包,有php官网下载        http://www.php.net/

3、mariadb-5.5.43-linux-x86_64.tar.gz  --- mariadb的二进制版本包,由mariadb官网下载https://downloads.mariadb.org/

4、apr-1.5.0.tar.bz2 和apr-util-1.5.3.tar.bz2  此为httpd的运行环境,httpd的安装需要依赖于apr(Apache portable Run-time libraries,Apache可移植运行库),实现httpd的跨平台运行。由于htpd2.4需要较高版本的apr及apr-util,所以需将其升级,可通过epel源升级或者源码升级。此处选择源码升级。


CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001 


1、展开源码包到/usr/local/src

[root@localhost ~]# tar xf apr-1.5.0.tar.bz2 -C /usr/local/src/[root@localhost ~]# tar xf apr-util-1.5.3.tar.bz2 -C /usr/local/src/[root@localhost ~]# tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/src/[root@localhost ~]# tar xf php-5.6.4.tar.xz -C /usr/local/src/ [root@localhost ~]# unzip phpMyAdmin-4.0.5-all-languages.zip -d /usr/local/src/

2、httpd在url重写时可能需要用到pcre来支持perl语言的正则表达式,安装过程中需要依赖pere-devel包,因此,先装上此包:

[root@localhost ~]# yum install -y pcre-devel    //需提前配置好yum源

3、安装apr及apr-util包

[root@localhost ~]# cd /usr/local/src/apr-1.5.0/    //切换至apr解压目录[root@localhost apr-1.5.0]# ./configure --prefix=/usr/local/apr    //指明apr的安装位置[root@localhost apr-1.5.0]# make && make install     //编译并安装[root@localhost apr-1.5.0]# cd /usr/local/src/apr-util-1.5.3/    //切换至apr-util的解压目录[root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr    //指定安装目录及apr路径[root@localhost apr-util-1.5.3]# make && make install     //编译并安装


4、安装编译安装httpd

[root@localhost ~]# cd /usr/local/src/httpd-2.4.9/    //切换至httpd的解压目录[root@localhost httpd-2.4.9]# ./configure --help    //使用此选项查看编译时所支持的参数,由于条目过多,此处指选出需要用到的参数进行讲解--prefix=/usr/local/apache    //指明安装目录--sysconfdir=/etc/httpd24    //指定配置文件的安装路径,此处为了避免与rpm包所装的httpd冲突,将路径名取名为httpd24--enable-so         //支持httpd的模块化机制--enable-ssl     //启用支持ssl功能,实现https--enable-cgi     //支持cgi协议--enable-rewrite     //支持url重写--with-zlib     //支持传输压缩--with-pcre     //支持perl语言的正则表达式--with-apr=/usr/local/apr    //指明编译升级的apr的路径--with-apr-util=/usr/local/apr-util //指明编译升级的apr-util路径--enable-modules=most     //指明启动大多数的模块--enable-mpms-shared=all     //将所有mpm模块都编译进httpd(httpd2.4版本的新特性)--with-mpm=event    //默认使用event的MPM工作模型[root@localhost httpd-2.4.9]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event[root@localhost httpd-2.4.9]# make && make install     //编译并安装


5、为编译安装的httpd添加环境变量

[root@localhost httpd-2.4.9]# vim /etc/profile.d/httpd24.sh    //在/etc/profile.d/目录下创建一个以.sh结尾的文件,并编辑export PATH=/usr/local/apache/bin/:$PATH    //将此信息添加至改文件,并保存退出[root@localhost httpd-2.4.9]# source /etc/profile.d/httpd24.sh    //通知系统重新读取此文件现在便可以直接使用编译安装的httpd命令了。

6、编译配置文件,添加pidfile文件路径

[root@localhost httpd-2.4.9]# vim /etc/httpd24/httpd.conf Pidfile "/var/run/httpd/httpd.pid"        //在配置文件中添加该行,并保存退出

7、为编译安装的httpd提供服务管理脚本,放置于/etc/rc.d/init.d下,名为httpd.24

# chkconfig: - 85 15# description: The Apache HTTP Server Management script.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then        . /etc/sysconfig/httpdfiHTTPD_LANG=${HTTPD_LANG-"C"}INITLOG_ARGS=""apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0STOP_TIMEOUT=${STOP_TIMEOUT-10}start() {        echo -n $"Starting $prog: "        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS        RETVAL=$?        echo        [ $RETVAL = 0 ] && touch ${lockfile}        return $RETVAL}stop() {        echo -n $"Stopping $prog: "        killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd        RETVAL=$?                                                                                                                                                                          echo                                                                                                                                                                               [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}                                                                                                                            }                                                                                                                                                                                  reload() {                                                                                                                                                                             echo -n $"Reloading $prog: "                                                                                                                                                       if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then                                                                                                                             RETVAL=6                                                                                                                                                                           echo $"not reloading due to configuration syntax error"                                                                                                                            failure $"not reloading $httpd due to configuration syntax error"                                                                                                              else                                                                                                                                                                                   # Force LSB behaviour from killproc                                                                                                                                                LSB=1 killproc -p ${pidfile} $httpd -HUP                                                                                                                                           RETVAL=$?                                                                                                                                                                          if [ $RETVAL -eq 7 ]; then                                                                                                                                                             failure $"httpd shutdown"                    fi                                                                                                                                                                             fi                                                                                                                                                                                 echo                                                                                                                                                                           }                                                                                                                                                                                                                                                                                                                                                                     # See how we were called.                                                                                                                                                          case "$1" in                                                                                                                                                                         start)                                                                                                                                                                                   start                                                                                                                                                                              ;;                                                                                                                                                                           stop)                                                                                                                                                                                    stop                                                                                                                                                                               ;;                                                                                                                                                                           status)                                                                                                                                                                                  status -p ${pidfile} $httpd                                                                                                                                                        RETVAL=$?                                                                                                                                                                          ;;                                                                                                                                                                           restart)                                                                                                                                                                                 stop                                                                                                                                                                               start                                                                                                                                                                              ;;                                                                                                                                                                           condrestart|try-restart)                                                                                                                                                                 if status -p ${pidfile} $httpd >&/dev/null; then                                                                                                                                           stop                                                                                                                                                                               start                                                                                                                                                                      fi                                                                                                                                                                                 ;;                                                                                                                                                                           force-reload|reload)                                                                                                                                                                     reload                                                                                                                                                                             ;;                                                                                                                                                                           graceful|help|configtest|fullstatus)                                                                                                                                                     $apachectl $@                                                                                                                                                                      RETVAL=$?                                                                                                                                                                          ;;                                                                                                                                                                           *)                                                                                                                                                                                       echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"                                                   RETVAL=2                                                                                                                                                                   esac                                                                                                                                                                                                                                                                                                                                      exit $RETVAL

                                                                                  

8、将httpd24添加至开机自动启动列表,脚本启动httpd,进行测试:

[root@localhost ~]# chkconfig --add httpd24[root@localhost ~]# chkconfig --list httpd24httpd24         0:off   1:off   2:on    3:on    4:on    5:on    6:off[root@localhost httpd-2.4.9]# service httpd24 startStarting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message    //此处报错可忽略[  OK  ][root@localhost httpd-2.4.9]# ss -tnl | grep 80LISTEN     0      128                      :::80                      :::*     //80端口已处于监听状态

9、安装mariadb:此安装过程可查看mysql的展开目录中的INSTALL-BINARY 文档

[root@localhost httpd-2.4.9]# cd /usr/local/src/       //切换至src的目录[root@localhost src]# mv mariadb-5.5.43-linux-x86_64 /usr/local/mysql    //将mariadb的目录名改为mysql[root@localhost src]# groupadd -r -g 306 mysql    //添加mysql组为系统组[root@localhost src]# useradd -r -u 306 -g 306 mysql    //添加mysql用户为系统用户并添加至mysql组[root@localhost src]# chown -R mysql:mysql mysql    //将mysql目录及其子目录改为属主属组都为mysql[root@localhost src]# mkdir /mydata/data -pv    //创建mysql的数据库目录mkdir: created directory `/mydata'mkdir: created directory `/mydata/data'[root@localhost src]# cd mysql/[root@localhost src]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data    //以mysql用户安装mariaDB并指明数据库目录位置 [root@localhost mysql]# chown -R root .       //将mysql目录改为root属主[root@localhost mysql]# mkdir /etc/mysql    //创建mysql配置文件目录//mysql的配置文件查找顺序为:/etc/my.cnf -- > /etc/mysql/*.cnf ---> --defaults-file(若编译安装时指定此项) ---> ~/.my.cnf 启动mysql的用户家目录下,最后一个加载的配置参数覆盖前面的配置参数[root@localhost mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf    //展开目录下support-files目录中提供有几个配置模板,依照内存需求命令, 可根据需要拷贝为默认的配置文件 [root@localhost mysql]# vim /etc/mysql/my.cnf    //编辑配置文件,在[mysqld]容器中添加如下几个参数thread_concurrency = 8      //将此项改为自己cpu核心数量的两倍datadir = /mydata/data    //指明数据库目录innodb_file_per_table = yes    //开启innodb数据库每个表存储为一个文件skip_name_resolve = yes    //开启跳过名称自解析[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld    //提供服务管理脚本,此脚本为软件所提供[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld    //将服务脚本赋予可执行权限[root@localhost mysql]# chkconfig --add mysqld    //将mysqld添加至开机自动启动项[root@localhost mysql]# chkconfig mysqld on    //开启开机自动启动[root@localhost mysql]# chkconfig --list mysqldmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off[root@localhost mysql]# /etc/init.d/mysqld start    //启动mysqld服务[root@localhost mysql]# bin/mysql_secure_installation     //运行mariadb的安全初始化,以完成为root用户添加密码以及其他的安全操作 至此,mariadb已完成安装


10、编译安装php,将其安装为httpd的模块

[root@localhost php-5.6.4]# yum install -y libmcrypt-devel.x86_64 bzip2-devel    //在epel源中有提供//解决依赖关系,php可能用到bzip2来进行数据的压缩[root@localhost php-5.6.4]# yum install -y libxml2-devel    //编译安装若启用对xml文档的支持,则需安装此项[root@localhost mysql]# cd /usr/local/src/php-5.6.4/    //切换至php的展开目录此处依旧可使用./configure --help 查看编译安装时所支持的参数--prefix=/usr/local/php     //指明安装路径--with-mysql=/usr/local/mysql     //指定mysql的位置--with-openssl     //支持openssl--with-mysqli=/usr/local/mysql/bin/mysql_config     //对mysql进行交互的另外一种接口--enable-mbstring         //对多字节字符串支持,对中文支持,必须启用此项--with-freetype-dir         //支持freetype字体格式--with-jpeg-dir     //开启此功能,可以使用php直接处理jpeg格式的图片    --with-png-dir     //   开启此功能,可以支持php直接处理png格式的图片--with-zlib     // 支持zlip压缩,提高数据传输效率--with-libxml-dir=/usr     //支持处理xml文档--enable-xml      //启用xml功能--enable-sockets     //表示支持php支持socket进行通信

--with-apxs2=/usr/local/apache/bin/apxs    //此项表示将php编译成模块

 --with-mcrypt          //支持加密解密

--with-config-file-path=/etc     //指明php配置文件的放置位置

--with-config-file-scan-dir=/etc/php.d     //表示检索此位置下的.ini结尾的文件作为php的配置文件

--with-bz2      //支持bzip2格式的压缩

--enable-maintainer-zts    //若httpd以线程模式运行(worker或event)模式运行,此项必须!表示将php编译成zts模块

[root@localhost php-5.6.4]#./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts

[root@localhost php-5.6.4]#make -j 4 && make install    //编译并安装。可使用-j n 指明使用几颗cpu核心进行编译,加速编译过程

./configure过程中,若出现错误,一般都是因为所依赖的*-devel包未安装,因此,使用yum install安装即可。


[root@localhost php-5.6.4]# cp php.ini-production /etc/php.ini

 //提供php配置文件,此文件无需更改。

[root@localhost php-5.6.4]# vim /etc/httpd24/httpd.conf

  //编辑httpd配置文件,找到php的模块,确保是否php已安装成功

添加如下几项:

    AddType application/x-httpd-php .php    AddType application/x-httpd-source .phps    将DirectoryIndex index.html   改为    DirectoryIndex index.php index.html

保存退出。执行httpd -t

[root@localhost php-5.6.4]# httpd -t    //检查配置文件是否有误
[root@localhost php-5.6.4]# /etc/rc.d/init.d/httpd24 reload    //重读配置文件
[root@localhost php-5.6.4]# httpd -M |grep php    //检查php的模块是否已加载

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

 php5_module (shared)


编辑一个测试页,测试LAMP是否已结合成功----

[root@localhost php-5.6.4]# vim /usr/local/apache/htdocs/index.php

                                                       

<?php        $conn=mysql_connect('127.0.0.1','root','root');  //此处mysql链接账号密码为安装完成Mariadb后,运行安全初始化时设置的。        if ($conn)                echo "OK";        else                echo "Faulse";        phpinfo();?>


11、在浏览器中打开网页进行查看:出现如下页面,即表示搭建成功。

CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001


12、搭建基于主机名的虚拟主机安装phpMyadmin,实现mysql(MariaDB)图形化管理:

[root@localhost php-5.6.4]# vim /etc/httpd24/httpd.conf    //编辑httpd配置文件1)注释中心主机:#DocumentRoot "/usr/local/apache/htdocs"2)添加:    Include /etc/httpd24/vhosts.conf

13、创建并编辑虚拟主机配置文件:

[root@localhost php-5.6.4]# vim /etc/httpd24/vhosts.conf

<VirtualHost 172.16.113.14:80>

        DocumentRoot /web/vhosts/pma

        ServerName pma.su.com

        CustomLog "/var/log/httpd/pma_access.log" common

        ErrorLog "/var/log/httpd/pma_error.log"

</VirtualHost>

<Directory "/web/vhosts/pma">    //httpd2.4版本必须为网站目录授权才可访问

    AllowOverride None

    Options None

    Require all granted

</Directory>


[root@localhost php-5.6.4]# mkdir -pv /var/log/httpd     //创建日志文件目录

[root@localhost php-5.6.4]# mkdir -pv /web/vhosts/pma    //创建网站根目录

mkdir: created directory `/web'

mkdir: created directory `/web/vhosts'

mkdir: created directory `/web/vhosts/pma'

[root@localhost php-5.6.4]# httpd -t    //检查配置文件是否有误

[root@localhost pma]# /etc/rc.d/init.d/httpd24 restart    //重启httpd服务

[root@localhost php-5.6.4]# mv /usr/local/src/phpMyAdmin-4.0.5-all-languages/* /web/vhosts/pma/    

//将程序文件移动到网站根目录下

//配置phpMyadmin配置文件

[root@localhost pma]# cp config.sample.inc.php config.inc.php     

//将配置文件模板复制为配置文件(去掉sample)


[root@localhost pma]# vim config.inc.php       //编辑配置文件

$cfg['blowfish_secret'] = 'aadf$#23SDA$%8b7c6d';        //在此项添加一个随机数


编辑测试主机hosts文件(C:\Windows\System32\drivers\etc),添加如下信息,并保存

172.16.113.14pma.su.com


在浏览器输入pma.su.com访问即可。


14、为pma.su.com提供https服务:

a>搭建ca服务器

IP地址为172.16.113.101

[root@CentOS5 CA]# ls    //保证/etc/pki/CA目录下有这些文件及目录,并在serial中的第一行写入01

CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001 

[root@CentOS5 CA]# (umask 077;openssl genrsa -out private/cakey.pem -out cacert.pem -days 7300)

    //生成CA的私钥

[root@CentOS5 CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 7300    

    //生成CA的自签证书

b>在httpd服务器生成私钥,并生成证书申请请求:

[root@localhost ~]# mkdir /etc/httpd24/ssl

[root@localhost ~]# cd /etc/httpd24/ssl

[root@localhost ssl]# (umask 077;openssl genrsa -out httpd.key 2048)

//证书申请请求需填写国家等信息,需要注意的是,下面此项必须和网站的FQDN完全一致

Common Name (eg, your name or your server's hostname) []:pma.su.com

[root@localhost ssl]# scp httpd.csr root@172.16.113.101:/tmp/    //将证书申请请求发送至CA的tmp目录下

c>在CA服务器签发证书,并发送给httpd服务器

[root@CentOS5 CA]# openssl ca -in /tmp/httpd.csr -out certs/pma.su.com.crt -days 365    //CA签发证书

[root@CentOS5 CA]# scp certs/pma.su.com.crt root@172.16.113.14:/etc/httpd24/ssl



d>配置

[root@localhost ssl]# vim /etc/httpd24/extra/httpd-ssl.conf 


ServerName pma.su.com

ServerAdmin admin@su.com

ErrorLog "/var/logs/pma_error_log"

TransferLog "/var/logs/pma_access_log"

SSLCertificateFile "/etc/httpd24/ssl/pma.su.com.crt" 

SSLCertificateKeyFile "/etc/httpd24/ssl/httpd.key"  


e>编辑Apache配置文件,将下面几项注释去掉                      

Include /etc/httpd24/extra/httpd-ssl.conf  

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so  

LoadModule ssl_module modules/mod_ssl.so  


f>将CA的证书导出至测试机的浏览器进行测试即可




15、安装PHP加速器:

        原理:php的执行需要两步:1、编译 2、执行 ,其中编译得过程又分为三个步骤:1、扫描(查看是否存在语法错误);2、分析(分析哪些是php代码,哪些是数据);3、编译(编译成opcode);PHP加速器的原理是将php代码编译后的opcode缓存至内存中,并共享给其他请求使用,这样节省了php代码的执行步骤,从而实现了加速功能。


       测试1:

安装前,可使用ab命令测试httpd服务器每秒可以相应多少个请求:

模仿20个用户,1000个并发请求

CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001

此时,httpd服务器每秒种可响应33个请求。

        安装:

[root@localhost ~]# cd /usr/local/src/xcache-3.2.0/    //切换至xcache的展开目录

[root@localhost xcache-3.2.0]# /usr/local/php/bin/phpize     //生成configure文件

[root@localhost xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 

// 指明编译所用到的php配置文件的位置

[root@localhost xcache-3.2.0]# make && make install

[root@localhost xcache-3.2.0]# mkdir /etc/php.d    //创建php的配置扫描路径

[root@localhost xcache-3.2.0]# cp xcache.ini /etc/php.d/    //拷贝xcache源码包中的配置文件到php.d目录

[root@localhost xcache-3.2.0]# vim /etc/php.d/xcache.ini     将其中的extension项的库文件指向,指向安装xcache最后显示的路径

例如:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so

[root@localhost xcache-3.2.0]# service httpd24 restart    //重启httpd


    测试:模仿20个用户,1000个并发请求。

CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001

由此可见,加速效果已达到。



16、再次创建一个机遇域名的虚拟主机,搭建wordpress论坛:

[root@localhost ~]# vim /etc/httpd24/vhosts.conf     //编辑配置文件

<VirtualHost 172.16.113.14:80>

        DocumentRoot /web/vhosts/wp

        ServerName wp.su.com

        CustomLog "/var/log/httpd/wp_access.log" common

        ErrorLog "/var/log/httpd/wp_error.log"


<Directory "/">

    AllowOverride None

    Options None

    Require all granted

</Directory>


</VirtualHost>

[root@localhost ~]# mkdir /web/vhosts/wp

[root@localhost ~]# unzip wordpress-4.3.1-zh_CN.zip -d /web/vhosts/wp/    //将WordPress解压至wp.su.com的网站根目录中

[root@localhost ~]# cd /web/vhosts/wp

[root@localhost wp]#  mv wordpress/* ./      //将文件全部移动出来

[root@localhost wp]# cp wp-config-sample.php wp-config.php     //将配置模板复制为配置文件

[root@localhost wp]# vim wp-config.php    //编辑配置文件

CentOS6 编译安装LAMP(Apache-httpd2.4,Mariadb,php)_2015092001

[root@localhost wp]# /usr/local/mysql/bin/mysql -uroot -hlocalhost -p    //登录数据库

MariaDB [(none)]> create database wpdb;    //创建数据库‘wpdb’

在测试主机的hosts文件添加:

172.16.113.14wp.su.com


在浏览器输入主机名访问进行配置即可。



本文出自 “Linux初级” 博客,请务必保留此出处http://imsupeng.blog.51cto.com/10651675/1696939