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

相关推荐

  • 8.3_Linux习题和作业

    课堂习题 1.当用户xiaoming对/testdir 目录无执行权限时,意味着无法做哪些操作? 答:不能cd进该目录 2.当用户xiaoqiang对/testdir 目录无读权限时,意味着无法做哪些操作? 答:不能查看目录内的文件列表,不能cd,也不能查看目录里面文件的元数据 3.当用户wangcai 对/testdir 目录无写权限时,该目录下的只读文件…

    Linux干货 2016-08-04
  • linux用户管理(一)

    作为一个专业的服务器发行版,CentOS上存在着n多个用户,作为一个专业的运维工程师,linux的用户管理和用户组的管理是做为一个SA必不可少的工作. 下面我们就先来谈谈linux中的用户管理: useradd可以在系统中新建一个用户 用法如下: useradd [选项] 用户名 常用选项: -u 指定用户的UID -g 指定用户的初始组ID -G…

    Linux干货 2017-04-03
  • ansible之Playbook中tags使用

    示例:httpd.yml– hosts: websrvsremote_user: roottasks:– name: Install httpdyum: name=httpd state=present – name: Install configure filecopy: src=files/httpd.conf des…

    Linux干货 2018-01-14
  • 常见RAID总结

    RAID浅析 目录索引 一、定义 二、特点 三、常用RAID级别      四、RAID实现方式 五、实际环境测试 一、定义: 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意。 独立磁盘冗余阵列(RAID,redundant array…

    Linux干货 2016-04-12
  • Linux基础知识之软件包管理(一)

    软件包管理 1.软件运行环境 运维工作的任务: 系统管理、库调用管理(开发接触的多,运维接触的少),安装配置某些程序包,让程序包运行并提供相应类型的服务 程序执行的过程:     程序源代码–>预处理–>编译–>汇编–>链接     预处理:将代码…

    Linux干货 2016-08-22
  • keepalived+varnish+haproxy+LNAMP

      nfs: 192.168.1.40 rp1: 192.168.1.41 rp2: 192.168.1.42 mariadb: 192.168.1.43 web1: 192.168.1.110 web2: 192.168.1.111 app1: 192.168.1.112 app2: 192.168.1.113 实验效果:用keepalived高…

    2018-02-18