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

相关推荐

  • Linux初识

    N22-熊宝–http://www.178linux.com/author/echeng1514 –马哥教育网络班22期–第1周课程练习   1、描述计算机的组成及其功能: 2、按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别: Linux有众多的发行版,都是基于不同的内核版本,做了许多改…

    Linux干货 2016-08-15
  • 第七周作业

    1、创建一个10G分区,并格式为ext4文件系统;  (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@localhost ~]# fdisk /dev/sdb #创建10G分区 Welcome to fdisk (util-linux 2.23.2). Changes wi…

    Linux干货 2017-02-19
  • SQL Server 2012 故障转移群集最佳实践

    一、Windows server  2012 系统主域的安装配置 功能介绍:  SQL Server 故障转移群集在网络上显示为一台计算机上的单个 SQL Server 实例。在群集内部,一次只有一个节点拥有群集资源组,满足针对该故障转移群集实例的所有客户端请求。在出现故障(硬件故障、操作系统故障、应用程序或服务故障)或进行计划升级时,组…

    Linux干货 2015-10-27
  • HSRP vs VRRP

    HSRP:(Hot Standby Router Protocol)-热备份路由协议 是cisco平台一种特有的技术,是cisco的私有协议。 VRRP:(Virtual Router Redundancy Protocol)-虚拟路由冗余协议 是国际标准,由IETF提出的解决局域网中配置静态网关出现单点失效现象的路由协议。 ----------------…

    Linux干货 2016-10-19
  • 磁盘阵列RAID

    磁盘阵列RAID 什么是RAID RAID的全称是Redundant Array of Inexpensive Disks 可以释义为 廉价磁盘冗余阵列,后来的RAID里的字母I被认为是Independent,即独立的磁盘冗余阵列。 RAID的作用 由于服务器中磁盘读写率太大,所以磁盘经常损坏,raid可以让坏了一块磁盘时,服务器不至于岩机。当然这只是其中的…

    Linux干货 2017-06-18
  • 马哥教育网络班21期+第三周课程练习

    列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登陆多次,只显示一次即可。 ~]# who|cut -d" " -f1|sort -u 2  取出最后登录当前系统的用户的相关信息。    ~]# id `last|head&nbs…

    Linux干货 2016-07-29