sdfsf 发表于 2017-10-25 08:50:02

CentOS7编译LAMP应用wordpress

软件环境:
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

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 测试php和mariadb连接
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.phpwp-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

页: [1]
查看完整版本: CentOS7编译LAMP应用wordpress