实验:centos7.3实现基于源码编译安装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.gza

两台主机:一台实现LAP ,一台实现M

1 源码编译安装Httpd2.4

yum groupinstall "development tools"
yum install openssl-devel expat-devel pcre-devel

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.0 httpd-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 二进制安装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
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

vi /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.* to wpuser@'192.168.25.%' identified by 'centos';
grant all on wpdb.* to wpuser@'127.%' identified by 'centos';
grant all on wpdb.* to wpuser@'localhost' identified by 'centos';



3 源码编译安装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
修改下面行

    DirectoryIndex index.php index.html

apachectl stop
apachectl


4 测试php和mariadb连接


vim /app/httpd24/htdocs/index.php

LAMP

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');

/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'centos');

/** MySQL主机 */
define('DB_HOST', 'localhost');

6 登录测试

http://websrv/blog
测试性能
ab -c 10 -n 100 http://websrv/blog/



你可能感兴趣的:(LAMP)