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)
cuicui
上一篇 2017-10-16 08:48
下一篇 2017-10-16

相关推荐

  • MongoDB安装部署手稿

    Edit MongoDB 手册 MongoDB 手册 第一章 Introduction MongoDB入门学习目录(建议) Databases Collections Documents 第二章 部署安装 1. Import the MongoDB public key 2. Configure the package management system (…

    Linux干货 2016-03-26
  • 马哥linux0805作业内容

    在/date/testdir/里穿件的新文件自动属于g1组,组g2的成员如:alice能对这些新文件有读写权限,组g3的成员如:tom只能对新文件有读权限,其他用户(不属于g1,g2,g3)不能访问这个文件夹 设置user1,使之新建文件权限为rw——- 3.设置/testdir/f1的权限,使user1用户不可以读写执行,g1组可以…

    Linux干货 2016-08-11
  • 恐怖的C++语言

    Linus曾经(2007年9月)在新闻组gmane.comp.version-control.git里和一个微软的工程师(Dmitry Kakurin)争执过用C还是用C++,当时的那个微软的工程师主要是在做Git的Windows版,但他却发现Git的源码居然是C语言写的,而不是C++,于是他(Dmitry Kakurin)在Linux社区里发贴表示对Lin…

    Linux干货 2015-04-03
  • 基于BIND实现的DNS正反解析及主从DNS的配置

    基于BIND实现的DNS正反解析及主从DNS的配置 标签: DNS正反解析 DNS主从复制 测试环境 准备2台虚拟机,一台为主DNS,IP地址为:192.168.103.161。另一台为从DNS,IP地址为:192.168.103.162两台都装好bind,所需包有:bind,bind-utils,bind-libs 主DNS的配置文件 配置主文件/etc/…

    Linux干货 2016-04-11
  • 7月21号:CentOS6.8(及7)基础配置项+Linux入门(1)

    7月21号,马哥第二天,主要内容有三个部分:一、基本命令复习二、CentOS6.8(及7)基础配置项;三、linux入门(1) 一、基本命令复习    ls         查看文件内容  l查看文件详细信息  -a显示包含隐藏文…

    Linux干货 2016-08-05
  • 配额-and-RAID

    配置配额系统 控制单个用户,或组在某磁盘上所能占的最大空间大小 配额是基于磁盘分区的,不基于文件 如何基于软件控制配额:          1、设置分区挂载选项          &nbsp…

    Linux干货 2016-08-29