CentOS下搭建LAMP

实验:centos7.3实现lamp应用wordpress
环境 host1 httpd,php  host2 mariadb
1 yum install httpd php php-mysql
yum install mariadb-server
systemctl start httpd
systemctl start mariadb

2 创建数据库及用户
mysql> create database wpdb;
mysql> grant all on wpdb.* to wpuser@’%’ identified by “wppass”;

3 下载源
tar xvf wordpress-4.8.1-zh_CN.tar.gz -C /var/www/html/
cd /var/www/html
ln -s wordpress/ blog
setfacl -R -m u:apache:rwx wordpress/

4 http://websrv/blog/

实验: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.gz

两台主机:一台实现LAP ,一台实现MariaDB
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

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

实验:centos6.9实现基于源码编译安装LAMP(php模块方式)的wordpress应用

软件版本:apr-1.6.2.tar.gz httpd-2.4.27.tar.bz2 php-5.6.31.tar.xz xcache-3.2.0.tar.bz2
apr-util-1.6.0.tar.gz mariadb-5.5.57-linux-x86_64.tar.gz wordpress-4.8.1-zh_CN.tar.gz

1 编译httpd2.4
yum groupinstall “development tools”
yum install openssl-devel pcre-devel expat-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 –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

cp /etc/init.d/httpd /etc/init.d/httpd24

vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

chkconfig –add httpd24
chkconfig –list httpd24
service httpd24 start

2 二进制安装mariadb
tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-5.5.57-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

touch /var/log/mysqld.log
chown mysql /var/log/mysqld.log
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-5.6.31.tar.xz
cd php-5.6.31
./configure –prefix=/app/php \
–with-mysql=/usr/local/mysql \
–with-openssl \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–enable-mbstring \
–with-png-dir \
–with-jpeg-dir \
–with-freetype-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 \
–with-bz2

make -j 4 && make install

vi /etc/profile.d/lamp.sh
PATH=/app/php/bin:/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
. /etc/profile.d/lamp.sh

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

service httpd24 restart

4 测试PHP连接数据库
5 配置wordpress
6 登录测试
http://websrv/blog
测试性能
ab -c 10 -n 100 http://websrv/blog/
7 编译xcache 实现Php加速
tar xvf xcache-3.2.0.tar.bz2
cd xcache-3.2.0

phpize
./configure –enable-xcache –with-php-config=/app/php/bin/php-config
make && make install

mkdir /etc/php.d/
cp xcache.ini /etc/php.d/
vim /etc/php.d/xcache.ini
extension = /app/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so

service httpd24 restart
8 测试
ab -c 10 -n 100 http://websrv/blog/

实验:centos6.9实现基于源码编译安装LAMP(FPM模块方式)的wordpress应用
软件版本:apr-1.6.2.tar.gz httpd-2.4.27.tar.bz2 php-5.6.31.tar.xz xcache-3.2.0.tar.bz2
apr-util-1.6.0.tar.gz mariadb-5.5.57-linux-x86_64.tar.gz wordpress-4.8.1-zh_CN.tar.gz

1 编译httpd2.4
yum groupinstall “development tools”
yum install openssl-devel pcre-devel expat-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 –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

cp /etc/init.d/httpd /etc/init.d/httpd24

vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

chkconfig –add httpd24
chkconfig –list httpd24
service httpd24 start

2 二进制安装mariadb
tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-5.5.57-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

touch /var/log/mysqld.log
chown mysql /var/log/mysqld.log
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-5.6.31.tar.xz
cd php-5.6.31

./configure \
–prefix=/app/php5 \
–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 \
–enable-fpm \
–with-mcrypt \
–with-config-file-path=/etc/php5 \
–with-config-file-scan-dir=/etc/php5.d \
–with-bz2

make -j 4 && make install

vi /etc/profile.d/lamp.sh
PATH=/app/php5/bin:/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
. /etc/profile.d/lamp.sh

mkdir /etc/php5/
cp php.ini-production /etc/php5/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig –add php-fpm
chkconfig –list php-fpm

cd /app/php5/etc
cp php-fpm.conf.default php-fpm.conf

vim /etc/httpd24/httpd.conf
取消两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
在文件尾部加四行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off 关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
修改下面行

DirectoryIndex index.php index.html

service httpd24 restart

4 测试
vim /app/httpd24/htdocs/index.php
$conn = mysql_connect(‘localhost’,’root’,’centos’);
if ($conn)
echo “OK”;
else
echo “Failure”;
mysql_close();

phpinfo();
?>
5 配置wordpress
6 登录测试
http://websrv/blog
测试性能
ab -c 10 -n 100 http://websrv/blog/
7 编译xcache 实现Php加速
tar xvf xcache-3.2.0.tar.bz2
cd xcache-3.2.0

phpize
./configure –enable-xcache –with-php-config=/app/php5/bin/php-config
make && make install

mkdir /etc/php.d/
cp xcache.ini /etc/php5.d/
vim /etc/php5.d/xcache.ini
extension = /app/php5/lib/php/extensions/no-debug-non-zts-20131226/xcache.so

service php-fpm restart

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/87820

(1)
上一篇 2017-10-16 08:48
下一篇 2017-10-16 12:46

相关推荐

  • 浅谈Nginx(二)—http下server配置

    浅谈Nginx(二)—http下server配置 此文介绍Nginx下的http模块,着重介绍http模块下的server服务 ——–依据”马哥教育”主讲人马永亮导师的上课笔记整理——- 目录  一. http相关的基本配置:     1)…

    系统运维 2017-02-07
  • LVS的四种模型

    相关术语: vs:Virtual Server,Director,Dispatcher,Balancer rs:Real Server,upstream server,backend server lvs集群的类型: lvs-nat:修改请求报文的目标IP lvs-dr:操作封装新的MAC地址; lvs-tun:在原请求IP报文之外新加一个IP首部; lvs…

    Linux干货 2016-10-30
  • date(时间),timedatectl(时区),cal(日历)的用法

    date+%F 显示日期,   显示格式如 2017-07-15+%T 显示时间    显示格式如 15:00:15+%Y 显示年      显示格式如 2017+%m 月 +%d 日+%H 时+%M 分+%S 秒+%s 从linux初始到现在经历了多少秒+%w 显示数字形式的星期+%a …

    Linux干货 2017-07-14
  • N25-第一周 总结

    linux bassic The first week of blogging 概要 计算机与操作系统、linux发行版及他们之间联系与区别、Linux的哲学思想、linux系统上命令使用格式及基础命令介绍、linux命令帮助说明、FHS 一、计算机与操作系统 什么是计算机? 电子计算机(computer),亦称电脑,是一种利用电子学原理,根据一系列指令对数…

    Linux干货 2016-12-04
  • 26期全程班-第六周博客作业

    请详细总结vim编辑器的使用并完成以下练习题 1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; # cp /etc/rc.d/rc.sysinit /tmp # vim /tmp/rc.sysinit :%s@^\([[:space:]]\+\)@#\1@g 2…

    Linux干货 2017-03-07
  • 双主模型的lvs-dr高可用负载均衡集群

    实验目的:使用keepalived实现lvs-dr模型双主高可用集群 实验环境:两台virtual server(实现lvs的双主)、两台real server(安装web service,用于负载均衡)、一台clietn用于验证结果 注意:为了不影响实验结果,在实验开始前先关闭iptables和selinux 操作步骤: 一、配置IP 1.配置A主机的IP…

    2017-05-13