码迷,mamicode.com
首页 > 其他好文 > 详细

LAMP架构

时间:2019-05-16 09:41:25      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:modules   ash   3.5   mys   ssl   sockets   wordpress   comm   use   

基于源码编译FCGI的模式的LAMP的wordpress和discuz!的多虚拟主机
1、准备

环境:一台主机apache,fgci服务器,一台主机MySQL server  
软件版本:mariadb-10.2.23-linux-x86_64.tar.gz  
         apr-1.7.0.tar.gz  
         apr-util-1.6.1.tar.gz  
         httpd-2.4.39.tar.bz2  
         php-7.3.5.tar.bz2  
         wordpress-5.2.tar.gz  
         Discuz_X3.3_SC_UTF8.zip  

2、编译安装httpd

主机A:192.168.2.6

    -、下载软件
[root@localhost data]# yum -y install gcc pcre-devel openssl-devel expat-devel autoconf libtool gcc-c++

root@localhost ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.bz2

[root@localhost ~]# wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.bz2

[root@localhost ~]# wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2

    -、解压
[root@localhost data]# tar -xvf httpd-2.4.39.tar.bz2
[root@localhost data]# tar xvf apr-1.7.0.tar.bz2
[root@localhost data]# tar xvf apr-util-1.6.1.tar.bz2 

    -、合并文件到httpd-2.4.39
[root@localhost data]# cp -r apr-1.7.0 httpd-2.4.39/srclib/apr
[root@localhost data]# cp -r apr-util-1.6.1 httpd-2.4.39/srclib/apr-util

    -、设置功能特性,开始编译
[root@localhost httpd-2.4.39]# ./configure > --prefix=/app/httpd24 > --enable-so > --enable-ssl > --enable-cgi > --enable-rewrite > --with-zlib > --with-pcre > --with-included-apr > --enable-modules=most > --enable-mpms-shared=all > --with-mpm=prefork 
[root@localhost httpd-2.4.39]# make -j 4 && make install

    -、加入环境变量,启动服务
[root@localhost httpd-2.4.39]# vim /etc/profile.d/httpd24.sh
PATH=/app/httpd24/bin:$PATH
[root@localhost ~]# . /etc/profile.d/httpd24.sh
[root@localhost6 ~]# apachectl start
[root@localhost ~]# ll /app/httpd24/htdocs/index.html   #主页面位置

    -浏览器访问测试
http://192.168.2.6/

    -、设置开机启动
[root@localhost conf]# ll /etc/rc.d/rc.local 
-rwxr-xr-x. 1 root root 236 May 12 10:05 /etc/rc.d/rc.local     #赋予执行权限
[root@localhost conf]# vim /etc/rc.d/rc.local
/app/httpd24/bin/apachectl start

    -、创建apache账号,供apache软件使用
[root@localhost ~]# useradd -r -s /sbin/nologin apache
[root@localhost ~]# vim /app/httpd24/conf/httpd.conf    #修改配置
User apache    #172行
Group apache    #173行

    -修改配置文件
[root@localhost ~]# vim /app/httpd24/conf/httpd.conf 
User apache         #172行
Group apache        #173行

LoadModule proxy_module modules/mod_proxy.so    #120行
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so  #124行
DirectoryIndex index.php index.html     #261行加入.php
AddType application/x-httpd-php .php    #尾部添加
AddType application/x-httpd-php-source .phps

<virtualhost *:80>
documentroot /data/wordpress
servername blog.huahua.com
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
<directory /data/wordpress>
require all granted
</directory>
</virtualhost>

<virtualhost *:80>
documentroot /data/discuz
servername forum.huahua.com
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
<directory /data/discuz>
require all granted
</directory>
</virtualhost>

[root@localhost ~]# apachectl restart

3、编译安装基于fcgi的php

主机A:192.168.2.6
    -安装依赖包
[root@localhost data]# yum -y install libxml2-devel bzip2-devel libmcrypt-devel

    -解压缩
[root@localhost data]# tar xvf php-7.3.5.tar.bz2
[root@localhost data]# cd php-7.3.5

    -编译安装
[root@localhost php-7.3.5]# ./configure --prefix=/app/php > --enable-mysqlnd > --with-mysqli=mysqlnd > --with-pdo-mysql=mysqlnd > --with-openssl > --with-freetype-dir > --with-jpeg-dir > --with-png-dir > --with-zlib > --with-libxml-dir=/usr > --with-config-file-path=/etc > --with-config-file-scan-dir=/etc/php.d > --enable-mbstring > --enable-xml > --enable-sockets > --enable-fpm > --enable-maintainer-zts > --disable-fileinfo
[root@localhost php-7.3.5]# make && make install

    -准备ini配置文件
[root@localhost php-7.3.5]# cp php.ini-production /etc/php.ini
[root@localhost php-7.3.5]# vim /etc/php.ini
date.timezone = "Asia/Shanghai"     #960行时区

[root@localhost php-7.3.5]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm                  #服务脚本
[root@localhost php-7.3.5]# chmod +x /etc/init.d/php-fpm 

[root@localhost php-7.3.5]# cd /app/php/etc      #进入编译路径
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf      #使配置文件生效
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf.default www.conf      #使配置文件生效

[root@localhost php-fpm.d]# vim www.conf
user = apache           #23行
group = apache          #24行
listen = 127.0.0.1:9000

[root@localhost data]# service php-fpm restart

4、二进制安装mariadb-server

主机B:192.168.2.16
    -解压到/usr/local/
[root@localhost ~]# tar xvf mariadb-10.2.23-linux-x86_64.tar.gz -C /usr/local/

    -进入目录
[root@localhost ~]# cd /usr/local/

    -创建软连接
[root@localhost local]# ln -s mariadb-10.2.23-linux-x86_64/ mysql

    -更改所有者,所属组
[root@localhost local]# chown -R root:root mysql/

    -创建用户、家目录
[root@localhost local]# useradd -r -s /sbin/nologin mysql -d/data/mysql
[root@localhost local]# mkdir /data/mysql -p
[root@localhost local]# chown mysql:mysql /data/mysql

    -运行脚本,指定数据存放位置
/usr/local/mysql/scripts/mysql_install_db
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql

    -创建配置文件
[root@localhost mysql]# mkdir /etc/mysql/
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# cp support-files/my-huge.cnf /etc/mysql/my.cnf
[root@localhost mysql]# vim /etc/mysql/my.cnf
[mysqld]
datadir=/data/mysql         #在mysqld加入数据路径  

    -作启动脚本
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

    -加入chkconfig
[root@localhost mysql]# chkconfig --add mysqld

    -加入PATH环境变量
[root@localhost mysql]# vim /etc/profile.d/lamp.sh
PATH=/usr/local/mysql/bin:$PATH
[root@localhost mysql]# . /etc/profile.d/lamp.sh

    -启动服务
[root@localhost mysql]# service mysqld start
[root@localhost mysql]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.23-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> 

    -跑安全加固脚本
[root@localhost mysql]# mysql_secure_installation

    -建库
MariaDB [(none)]> create database wordpress;

    -建授权账号
MariaDB [(none)]> grant all on wordpress.* to wpuser@‘192.168.2.6‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> grant all on ultrax.* to discuz@‘192.168.2.6‘ identified by ‘123456‘;

5、准备相关php程序文件

    -解压wordpress、Discuz
[root@localhost data]# tar xvf wordpress-5.2.tar.gz
[root@localhost data]# unzip Discuz_X3.3_SC_UTF8.zip

    -配置wordpress
[root@localhost data]# cd wordpress
[root@localhost wordpress]# cp -r wp-config-sample.php wp-config.php
[root@localhost wordpress]# vim wp-config.php       #连接数据库
/** The name of the database for WordPress */
define( ‘DB_NAME‘, ‘wordpress‘ );

/** MySQL database username */
define( ‘DB_USER‘, ‘wpuser‘ );

/** MySQL database password */
define( ‘DB_PASSWORD‘, ‘123456‘ );

/** MySQL hostname */
define( ‘DB_HOST‘, ‘192.168.2.16‘ );

/** Database Charset to use in creating database tables. */
define( ‘DB_CHARSET‘, ‘utf8‘ );

/** The Database Collate type.

    -配置Discuz!:
[root@localhost data]# mv upload/ discuz
[root@localhost data]# setfacl -R -m u:apache:rwx /data/discuz/

LAMP架构

标签:modules   ash   3.5   mys   ssl   sockets   wordpress   comm   use   

原文地址:https://blog.51cto.com/14230743/2395317

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!