首页 > 其他 > 详细

CentOS7编译LAMP应用wordpress  

时间:2017-10-24 22:18:51      阅读:442      评论:0      收藏:0      [点我收藏+]


软件环境:

apr-1.6.2.tar.gz      

httpd-2.4.27.tar.bz2              

php-7.1.10.tar.xz

apr-util-1.6.0.tar.gz

mariadb-10.2.8-linux-x86_64.tar.gz 

wordpress-4.8.1-zh_CN.tar.gz

两台主机:cneots6实现LAP ,cnetos7实现M

 

1 centos6 源码编译安装Httpd2.4

yum groupinstall "development tools"

yum install openssl-devel expat-develpcre-devel

新建文件夹mkdir src

tar xvf apr-1.6.2.tar.gz

tar xvf apr-util-1.6.0.tar.gz

tar xvf httpd-2.4.27.tar.bz2

技术分享

cp -r apr-1.6.2 httpd-2.4.27/srclib/apr

cp -r apr-util-1.6.0httpd-2.4.27/srclib/apr-util

技术分享

cd httpd-2.4.27/

./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-rewrite --with-zlib--with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork

make -j 4 && make install

 

vim /etc/profile.d/lamp.sh

PATH=/app/httpd24/bin/:$PATH

. /etc/profile.d/lamp.sh

apachectl

ss -tnl

 

2 . centos7 : 二进制安装mariadb

数据库必须放在指定的文件夹下tar xvf mariadb-10.2.8-linux-x86_64.tar.gz  -C/usr/local/

cd /usr/local

ln -s mariadb-10.2.8-linux-x86_64/ mysql

若没有mysql用户就要添加 useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql

技术分享

cd mysql/

scripts/mysql_install_db--datadir=/app/mysqldb --user=mysql

mkdir /etc/mysql

cp support-files/my-large.cnf   /etc/mysql/my.cnf

vim /etc/mysql/my.cnf

[mysqld]

datadir = /app/mysqldb

innodb_file_per_table = ON

skip_name_resolve = ON

 

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig --list

service mysqld start

 

mkdir /var/log/mariadb

chown mysql /var/log/mariadb/

service mysqld start

技术分享 

因为数据库在/usr/local/,使用起来不方便,所以把它写入变量。vim /etc/profile.d/lamp.sh

PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH

. /etc/profile.d/lamp.sh

 

mysql_secure_installation

 

mysql -uroot -pcentos

create datebase wpdb;

grant all on wpdb.* towpuser@‘192.168.25.%‘ identified by ‘centos‘;

技术分享

3 cnetos6 源码编译安装Php

yum install libxml2-devel bzip2-devel libmcrypt-devel

tar xvf php-7.1.10.tar.xz

cd php-7.1.10/

 

./configure \--prefix=/app/php \--enable-mysqlnd \--with-mysqli=mysqlnd \--with-openssl \

--with-pdo-mysql=mysqlnd \--enable-mbstring \--with-freetype-dir \--with-jpeg-dir \

--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml --enable-sockets \--with

apxs2=/app/httpd24/bin/apxs \--with-mcrypt \--with-config-file-path=/etc \--with-config-file-scan-dir=/etc/php.d \--enable-maintainer-zts \--disable-fileinfo

make -j 4 && make install

 

cp php.ini-production /etc/php.ini

vim /etc/httpd24/httpd.conf

在文件尾部加两行

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source.phps

修改下面行

<IfModule dir_module>

   DirectoryIndex index.php index.html

</IfModule>

技术分享

apachectl stop

apachectl

 

4 测试phpmariadb连接

vim /app/httpd24/htdocs/index.php

<html><body><h1>LAMP</h1></body></html>

<?php

$mysqli=newmysqli("localhost","root","centos");

if(mysqli_connect_errno()){

echo "连接数据库失败!";

$mysqli=null;

exit;

}

echo "连接数据库成功!";

$mysqli->close();

phpinfo();

?>

5. 配置wordpress

tar xvf wordpress-4.8.1-zh_CN.tar.gz  -C /app/httpd24/htdocs

cd /app/httpd24/htdocs

mv wordpress/ blog/

技术分享 

cd /app/httpd24/htdocs/blog/

cp wp-config-sample.php  wp-config.php

vim wp-config.php

define(‘DB_NAME‘, ‘wpdb‘);

 技术分享

6 登录测试

http://192.168.136.169/blog 出现下面的页面说明成功了。

技术分享

测试性能

ab -c 10 -n 100 http://websrv/blog/

注意:源码httpd编译的时候,如果机器上原来有httpd,他的启动方式是service httpd start,二进制编译的启动要用apachectl ,如果要想用service启动,就要cd /etc/init.d/ vim httpd24修改配置文件

技术分享

加入列表: chkconfig --add httpd24

开机启动:chkdconfig httpd24 on


本文出自 “13162732” 博客,请务必保留此出处http://13172732.blog.51cto.com/13162732/1975791

CentOS7编译LAMP应用wordpress  

原文:http://13172732.blog.51cto.com/13162732/1975791

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!