您的位置:新葡亰496net > 电脑系统 > Centos7上编写翻译安装LAMP,Linux下软件安装的三种

Centos7上编写翻译安装LAMP,Linux下软件安装的三种

发布时间:2019-06-21 11:27编辑:电脑系统浏览(67)

     

    系统版本:CentOS 6.9

    • CentOS 7.3条件LAMP源码编写翻译安装WordPress
    • CentOS 6.9景况LAMP源码编写翻译安装WordPress(php module形式)
    • CentOS 6.9景况LAMP源码编写翻译安装WordPress(php fpm形式)

    试验景况:
    虚拟机CentOS7,ip为172.16.250.103

    一.源码安装

    前言

    近期没更新新篇幅了,前几天就来点干活,过多的也不说了上边最先干!干!干!

     

    软件包

    一、CentOS 7.3条件LAMP源码编写翻译安装WordPress

    官网络下载软件包:

    步骤:

    桑土盘算条件

    centos7.5
    apr-1.6.3.tar.gz 
    apr-util-1.6.1.tar.gz     
    httpd-2.4.34.tar.bz2                
    php-7.1.18.tar.bz2
    mariadb-10.2.16-linux-x86_64.tar.gz 
    wordpress-4.9.4-zh_CN.tar.gz

    apr-1.6.2.tar.gz
    apr-util-1.6.0.tar.gz
    httpd-2.4.27.tar.bz2
    mariadb-5.5.57-linux-x86_64.tar.gz
    php-5.6.31.tar.bz2
    wordpress-4.8.1-zh_CN.zip

    (一)意况希图

    • 搭建遭遇:
      主机1:负责httpd, php, wordpress (IP: 192.168.136.130)
      主机2:负责MariaDB (IP: 192.168.136.230)

    • 软件条件:
      apr-1.6.2.tar.gz
      apr-util-1.6.0.tar.gz
      httpd-2.4.27.tar.bz2
      php-7.1.10.tar.xz
      wordpress-4.8.1-zh_CN.tar.gz
      mariadb-10.2.8-linux-x86_Centos7上编写翻译安装LAMP,Linux下软件安装的三种方法。64.tar.gz

    • apr-1.5.2.tar.bz2
    • apr-util-1.5.4.tar.bz2
    • httpd-2.4.27.tar.bz2
    • mariadb-10.2.7-linux-x86_64.tar.gz
    • php-7.1.8.tar.bz2
    • wordpress-4.8-zh_CN.tar.gz
    • xcache-3.2.0.tar.gz
    1. 下载,解压源码(常见的源码打包格式:.tar.gz/.tar.bz2);

    编译HTTP

    编译安装httpd

    (二)源码编写翻译安装httpd2.4

    • 安装开采境况
    yum groupinstall "development tools"
    yum install openssl-devel expat-devel pcre-devel
    
    • 解压缩源码包
    tar xvf apr-1.6.2.tar.gz -C /usr/local/src
    tar xvf apr-util-1.6.0.tar.gz  -C /usr/local/src
    tar xvf httpd-2.4.27.tar.bz -C /usr/local/src
    cd /usr/local/src
    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
    

    图片 1

    图片 2

    • 修改遭逢变量
    vim /etc/profile.d/lamp.sh
    PATH=/app/httpd24/bin/:$PATH
    . /etc/profile.d/lamp.sh
    apachectl start
    ss -ntlp
    
    • 安装开机运营脚本
    vim /etc/rc.d/rc.local
    /app/httpd24/bin/apachectl start
    chmod  x /etc/rc.d/rc.local
    
    • 安装协理文件路线
    vim /etc/man_db.conf
    MANDATORY_MANPATH    /app/httpd24/man
    

    地点的软件包除了mariadb是二进制包,别的的包都以源码包,如今已下载达成,放在/root/src目录下:

    能够直接下载源码再上传至linux服务器,或许在联网状态下,直接通过wget等一声令下获取源码安装包;源码解压后会有README文件,应先阅读;

    1、安装包组以及有关包

    yum groupinstall "development tools"
    yum install pcre-devel openssl-devel expat-devel
    

     

    积谷防饥干活
    编写翻译软件须求采取开采包组Development tools,在编写翻译httpd中,会依赖openssl-devel pcre-devel expat-devel四个devel包,提前设置,幸免进度中报错。

    (三)二进制安装玛丽亚DB

    • 解压缩二进制包至内定目录
    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 -d /app/mysqldb -s /sbin/nologin mysql -m
    cd mysql/
    scripts/mysql_install_db  --datadir=/app/mysqldb --user=mysql
    

    图片 3

    • 编辑配置文件
    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 mysqld
    
    • 安装日志目录,并运行服务
    mkdir /var/log/mariadb
    chown mysql /var/log/mariadb/
    service mysqld start
    ss -ntlp
    
    • 安装境况变量
    vim /etc/profile.d/lamp.sh
    PATH=/usr/local/mysql/bin:$PATH
    source /etc/profile.d/lamp.sh 
    
    • 布局数据库,创设WordPress的数据库
    mysql_secure_installation
    
    mysql -uroot -p
    MariaDB [(none)]> create database wpdb;
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'192.168.136.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'127.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'localhost' identified by 'centos';
    

    图片 4

    [root@Centos7 src]#pwd
    /root/src
    [root@Centos7 src]#ls
    apr-1.5.2.tar.bz2       mariadb-10.2.7-linux-x86_64.tar.gz  wordpress-4.8-zh_CN.tar.gz
    apr-util-1.5.4.tar.bz2  httpd-2.4.27.tar.bz2  php-7.1.8.tar.bz2   xcache-3.2.0.tar.gz
    
    1. 深入分析安装平台景况(运维configure文件: ./configure)

    2、创造用户与解压

    useradd  -r -s /sbin/nologin apache 
    tar xf httpd-2.4.34.tar.bz2 
    tar xf apr-1.6.3.tar.gz 
    tar xf apr-util-1.6.1.tar.gz 
    

     

    [root@6mini ~]# yum groupinstall "Development tools"
    [root@6mini ~]# yum install openssl-devel pcre-devel expat-devel
    

    (四)源码编写翻译安装php

    • 编译情形希图
    yum install libxml2-devel bzip2-devel libmcrypt-devel
    tar xvf php-7.1.10.tar.xz -C /usr/local/src/
    cd /usr/local/src/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
    

    图片 5

    图片 6

    • 编排配置文件
    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
    // 修改下面行
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
    
    apachectl stop
    apachectl start
    ss -ntlp
    

    一、编写翻译安装httpd

    1、解压httpd、apr、apr-util四个安装包

    [root@Centos7 src]#tar xvf httpd-2.4.27.tar.bz2
    [root@Centos7 src]#tar xvf apr-1.5.2.tar.bz2
    [root@Centos7 src]#tar xvf apr-util-1.5.4.tar.bz2
    

    2、把apr和apr-util解压出来的目录移动到httpd-2.4.27/srclib/apr这一个目录下

    [root@Centos7 src]#mv apr-1.5.2 httpd-2.4.27/srclib/apr
    [root@Centos7 src]#mv apr-util-1.5.4 httpd-2.4.27/srclib/apr-util
    

    3、进入httpd-2.4.27目录,执行./configure,检查当前境遇,生成Makefile
    设若提醒贫乏某些模块大概软件,遵照供给装上,然再实行./configure,直到未有报错。

    [root@Centos7 src]#cd httpd-2.4.27/
    [root@Centos7 httpd-2.4.27]#./configure --prefix=/app/apache24  --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
    

    4、编写翻译安装

    [root@Centos7 httpd-2.4.27]#make &&make install
    

    5、修改PATH,把/app/apache24/bin添加到PATH变量里

    [root@Centos7 app]#vim /etc/profile.d/app.sh
    export PATH=/app/apache24/bin:$PATH
    [root@Centos7 app]#. /etc/profile.d/app.sh
    

    6、到此处我们就足以运行httpd了,由于大家团结编写翻译安装的,并未增加期服用务脚本。因而大家只可以用Apache自带的吩咐运转服务。可以看看80端口已开荒。至此httpd已编写翻译安装到位。

    [root@Centos7 app]#apachectl start
    [root@Centos7 app]#ss -ntl|grep 80
    LISTEN     0      128         :::80                      :::*            
    

    Centos7上编写翻译安装LAMP,Linux下软件安装的三种方法。(1)解压源码后跻身源码所在文件夹,运营./configure命令,举办情况测试,借使提醒贫乏某个安装包就进展设置,直至测试通过.

    3、移动apr目录

    mv apr-1.6.3 httpd-2.4.34/srclib/apr
    mv apr-util-1.6.1 httpd-2.4.34/srclib/apr-util
    

     

    解压apr-1.6.2.tar.gz、apr-util-1.6.0.tar.gz和httpd-2.4.27.tar.bz2,复制apr-1.6.2到httpd-2.4.27,并改名换姓为apr,复制apr-util-1.6.0到httpd-2.4.27,并更名称叫apr-util

    (五)测试php与MariaDB的连接

    vim /app/httpd24/htdocs/index.php
    <?php
    $mysqli=new mysqli("192.168.136.230","wpadmin","centos");
    if(mysqli_connect_errno()){
    echo "连接数据库失败!";
    $mysqli=null;
    exit;
    }
    echo "连接数据库成功!";
    $mysqli->close();
    phpinfo();
    ?>
    

    图片 7

    二、安装mariadb

    出于本人用的软件包是官英特网一度编写翻译好的二进制包,编译时选定的目录是/usr/local/,因而小编也解压到这一个目录下(不然安装后大多配备文件设置的和装置目录不均等)
    去除原来安装的mariadb

    [root@Centos7 src]#rpm -qa "mariadb*"
    [root@Centos7 src]#yum remove  mariadb*
    

    1、解压mariadb软件包到//usr/local/

    [root@Centos7 src]#tar xvf mariadb-10.2.7-linux-x86_64.tar.gz  -C /usr/local/
    [root@Centos7 src]# cd /usr/local/
    [root@Centos7 local]#ln -s mariadb-10.2.7-linux-x86_64/ mysql
    

    2、创设mysql用户,钦定shell类型为nologin,并创办家目录为/app/mysqldb

    [root@Centos7 local]#useradd -r mysql -s /sbin/nologin -d /app/mysqldb -m 
    [root@Centos7 local]#ll -d /app/mysqldb/
    drwx------. 2 mysql mysql 4096 Aug  9 08:17 /app/mysqldb/
    

    3、安装,钦赐数据库目录以及服务用户

    [root@Centos7 local]#cd mysql
    [root@Centos7 mysql]#./scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
    

    4、希图安顿文件

    [root@Centos7 mysql]#mkdir /etc/mysql
    [root@Centos7 mysql]#cp support-files/my-huge.cnf /etc/mysql/my.cnf
    [root@Centos7 mysql]#vim /etc/mysql/my.cnf 
    #在[mysqld]这一行下添加以下三行
    datadir =/app/mysqldb
    innodb_file_per_table = ON
    skip_name_resolve = ON
    

    5、增多运营服务脚本

    [root@Centos7 mysql]#cp support-files/mysql.server /etc/init.d/mysqld
    [root@Centos7 mysql]#chkconfig --add mysqld
    

    6、修改PATH路径

    [root@Centos7 mysql]#vim /etc/profile.d/app.sh 
    export PATH=/usr/local/mysql/bin:/app/apache24/bin:$PATH
    [root@Centos7 mysql]#. /etc/profile.d/app.sh
    

    7、运营服务

    [root@Centos7 mysql]#service mysqld start
    Starting mysqld (via systemctl):                           [  OK  ]
    [root@Centos7 mysql]#ss -ntl |grep 3306
    LISTEN     0      80          :::3306                    :::*    
    可以看到3306端口已打开
    

    8、修改mysql的root账号密码
    下边会用到那么些root账号和密码测试

    [root@Centos7 mysql]#mysql_secure_installation
    设置root密码为666666
    

    始建博客的数据库和用户

    [root@Centos7 mysql]mysql -uroot -p666666
    MariaDB [(none)]> create database blogdb;     
    MariaDB [(none)]>grant all on blogdb.* to wpuser@'localhost' identified by  "666666";    
    

    (2)还是可以在./configure前边加上软件的装置路线及安装所需的模块等采纳,来定制用户须求的软件作用;(./configure --prefix=/usr/local/ #指虞诩装路线,还足以在这里加上"",采用需编写翻译的模块)

    4、源码编写翻译

    cd httpd-2.4.34/
    
    ./configure --prefix=/app/httpd24 
    --enable-so 
    --enable-ssl 
    --enable-cgi 
    --enable-rewrite 
    --with-zlib 
    --with-pcre 
    --enable-modules=most 
    --enable-mpms-shared=all 
    --with-mpm=prefork 
    --with-included-apr
    
    make && make install 
    

     

    [root@6mini ~]# tar xvf apr-1.6.2.tar.gz 
    [root@6mini ~]# tar xvf apr-util-1.6.0.tar.gz 
    [root@6mini ~]# tar xvf httpd-2.4.27.tar.bz2 
    

    (六)安装配备WordPress

    • 解压缩软件包至网页存放目录
    tar -xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs/
    cd /app/httpd24/htdocs/
    ln -s wordpress/ blog
    cd blog/
    
    • 编辑安装配备文件
    cp wp-config-sample.php wp-config.php
    vim wp-config.php
    // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
    /** WordPress数据库的名称 */
    define('DB_NAME', 'wpdb');
    
    /** MySQL数据库用户名 */
    define('DB_USER', 'wpadmin');
    
    /** MySQL数据库密码 */
    define('DB_PASSWORD', 'centos');
    
    /** MySQL主机 */
    define('DB_HOST', '192.168.136.230');
    
    • 浏览器展开http://192.168.136.130/blog/,遵照提醒填入音讯开头设置

    图片 8

    • WordPress安装成功后,博客展现分界面

    图片 9

    • ab测试品质
      ab -c 10 -n 100 http://192.168.136.130/blog/

    图片 10

    三、编译PHP

    1、解压源码包

    [root@Centos7 src]#ls
    apr-1.5.2.tar.bz2       httpd-2.4.27.tar.bz2                php-7.1.8.tar.bz2
    apr-util-1.5.4.tar.bz2  mariadb-10.2.7-linux-x86_64.tar.gz  wordpress-4.8-zh_CN.tar.gz
    httpd-2.4.27            php-7.1.8                           xcache-3.2.0.tar.gz
    [root@Centos7 src]#tar xvf php-7.1.8.tar.bz2
    

    2、./configure

    [root@Centos7 src]#cd php-7.1.8/
    [root@Centos7 php-7.1.8]#./configure --prefix=/app/php --enable-mysqlnd  --with-mysqli=mysqlnd   --with-openssl --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/apache24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
    如果提示找不到文件,请按照提示安装包
    安装好包后,继续上面./configure操作
    

    3、make && make install

    [root@Centos7 php-7.1.8]#make && make install
    

    4、拷贝配置文件

    [root@Centos7 php-7.1.8]cp php.ini-production  /etc/php.ini
    

    5、修改httpd配置文件

    [root@Centos7 php-7.1.8]vim /app/httpd24/conf/httpd.conf
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
    

    6、测试php
    "root","666666"分别是自个儿上面安装的mysql数据库的账号和密码

    vim /app/httpd24/htdocs/index.php 
    <?php
    $mysqli=new mysqli("127.0.0.1","root","666666");
    if(mysqli_connect_errno()){
    echo "连接数据库失败!";
    $mysqli=null;
    exit;
    }
    echo "连接数据库成功!";
    $mysqli->close();
    ?>
    

    用浏览器访问一下,使用php连接数据库成功

    图片 11

    image.png

    (3):经常软件安装都亟待GCC或CC编写翻译器;那个编写翻译器一般在安装系统时定制安装包中的开垦工具选项下;

    5、设置景况变量

    echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/lamp.sh
    

     

    编写翻译安装httpd,配置景况变量

    二、CentOS 6.9情形LAMP源码编写翻译安装WordPress(php module方式)

    四、部署WordPress

    1、解压,把解压出来的目录移动到/app/apache24/htdocs/目录下,改名字为blog

    [root@Centos7 ~]#cd /root/src/
    [root@Centos7 src]#tar xf wordpress-4.8-zh_CN.tar.gz 
    [root@Centos7 src]mv wordpress /app/apache24/htdocs/blog
    

    2、设置配置文件

    [root@Centos7 src]#cd /app/apache24/htdocs/blog/
    [root@Centos7 blog]cp wp-config-sample.php wp-config.php 
    [root@Centos7 blog]vim wp-config.php 
    
    define('DB_NAME', 'blogdb');
    
    /** MySQL数据库用户名 */
    define('DB_USER', 'wpuser');
    
    /** MySQL数据库密码 */
    define('DB_PASSWORD', '666666');
    
    /** MySQL主机 */
    define('DB_HOST', 'localhost');
    

    也得以用另一种情势,给予daemon读写实践权限

    [root@Centos7 ~]setfacl -m u:daemon:rwx /app/apache24/htdocs/blog/
    

    3、测试
    自己的ip是172.16.250.103,访问一下http://172.16.250.103/blog/
    能够见见陈设成功。

    图片 12

    image.png

    1. 编译(make)

    6、编辑配置文件

    vim /app/httpd24/conf/httpd.conf
    
    user apache
    group apache
    
    
    取消下面注释
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
    
    在下面行添加index.php
    IfModule dir_module>
        DirectoryIndex index.php index.html                                                                                       
    </IfModule>
    
    添加子配置文件
    Include conf/extra/php.conf
    

     

    [root@6mini 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
    [root@6mini httpd-2.4.27]# make -j 2 && make install
    
    [root@6mini httpd-2.4.27]# vim /etc/profile.d/lamp.sh
    PASH=/app/httpd24/bin/:$PASH
    
    [root@6mini httpd-2.4.27]# . /etc/profile.d/lamp.sh
    [root@6mini httpd-2.4.27]# echo $PASH
    /app/httpd24/bin/:
    

    (一)意况准备

    • 搭建遭受:
      主机1:负责httpd, php, wordpress (IP: 192.168.136.129)
      主机2:负责MariaDB (IP: 192.168.136.229)

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

    进入软件安装的文本夹,运转make命令;

    7、编辑子配置文件

    vim  /app/httpd24/conf/extra/php.conf
    
    添加以下内容
    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
    

     

    构建httpd运转程序
    复制别的主机上httpd的起步程序到日前主机并更名字为httpd24

    (二)源码编写翻译安装httpd2.4

    • 安装开拓景况
    yum groupinstall "development tools"
    yum install openssl-devel expat-devel pcre-devel
    
    • 解压缩源码包
    tar xvf apr-1.6.2.tar.gz -C /usr/local/src
    tar xvf apr-util-1.6.0.tar.gz  -C /usr/local/src
    tar xvf httpd-2.4.27.tar.bz -C /usr/local/src
    cd /usr/local/src
    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
    

    图片 13

    图片 14

    • 修改情状变量
    vim /etc/profile.d/lamp.sh
    PATH=/app/httpd24/bin/:$PATH
    . /etc/profile.d/lamp.sh
    
    • 安装运维脚本
    scp /etc/init.d/httpd  192.168.136.129:/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
    ss -ntlp
    
    • 安装补助文件路线
    vim /etc/man.config
    MANPATH /app/httpd24/man
    
    1. 安装(make install)

    8、运行服务

    apachectl
    

     

     

    [root@MiniLinux ~]#scp /etc/init.d/httpd 192.168.163.105:/etc/init.d/
    The authenticity of host '192.168.163.105 (192.168.163.105)' can't be established.
    RSA key fingerprint is b5:df:3d:28:80:8e:d4:81:3b:f2:56:81:77:6d:7d:8a.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.163.105' (RSA) to the list of known hosts.
    root@192.168.163.105's password: 
    httpd                                                      100% 3488     3.4KB/s   00:00
    
    [root@6mini httpd-2.4.27]# mv /etc/init.d/httpd /etc/init.d/httpd24
    

    (三)二进制安装玛丽亚DB

    • 解压缩二进制包至钦点目录
    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 -d /app/mysqldb -s /sbin/nologin mysql -m
    cd mysql/
    scripts/mysql_install_db  --datadir=/app/mysqldb --user=mysql
    

    图片 15

    • 编排配置文件
    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 mysqld
    
    • 设置日志目录,并运行服务
    touch /var/log/mysqld.log
    chown mysql /var/log/mysqld.log
    service mysqld start
    ss -ntlp
    
    • 设置情状变量
    vim /etc/profile.d/lamp.sh
    PATH=/usr/local/mysql/bin:$PATH
    source /etc/profile.d/lamp.sh 
    
    • 配备数据库,建立WordPress的数据库
    mysql_secure_installation
    
    mysql -uroot -p
    MariaDB [(none)]> create database wpdb;
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'192.168.136.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'127.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'localhost' identified by 'centos';
    

    图片 16

    进去软件设置的文书夹,运行make install命令;

    二进制安装MYSQL

    启动httpd24
    修改httpd24的起步配置文件

    (四)源码编写翻译安装php

    • 编译情况策动
    yum install libxml2-devel bzip2-devel libmcrypt-devel
    tar xvf php-5.6.4.tar.xz -C /usr/local/src/
    cd /usr/local/src/php-5.6.4/
    
    • 编译安装
    ./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
    

    图片 17

    图片 18

    • 安装景况变量
    vim /etc/profile.d/lamp.sh
    PATH=/app/php/bin:/app/httpd24/bin:$PATH
    source /etc/profile.d/lamp.sh
    
    • 编写配置文件
    cp php.ini-production /etc/php.ini
    
    vim /app/httpd24/conf/httpd.conf
    // 在文件尾部加两行
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    // 修改下面行
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
    
    service httpd24 restart
    ss -ntlp
    

    举例:安装redis (redis-3.0.0.tar.gz)

    1、在前几篇里有提到详细的设置进度,这里就一贯职业代码

    useradd -r -s /sbin/nologin mysql
    
    tar xvf mariadb-10.2.16-linux-x86_64.tar.gz  -C /usr/local/
    
    cd /usr/local/
    
    ln -s mariadb-10.2.16-linux-x86_64/ mysql
    
    chown -R mysql.mysql mysql/
    
    mkdir /app/mysql
    
    chown mysql.mysql /app/mysql
    
    cd /usr/local/mysql/
    
    scripts/mysql_install_db  --datadir=/app/mysql --user=mysql
    
    mkdir /etc/mysql/  
    
    cp support-files/my-huge.cnf  /etc/mysql/my.cnf
    
    vim /etc/mysql/my.cnf
    
    datadir=/app/mysql 
    
    cp support-files/mysql.server  /etc/init.d/mysqld
    
    chkconfig --add mysqld
    
    chkconfig --list
    
    service mysqld start
    
    vim /etc/profile.d/lamp.sh 
    
    PATH=/app/httpd24/bin:/usr/local/mysql/bin:$PATH
    
    mysql -e "create database wpdb;grant all on wpdb.* to wpuser@'localhost' identified by 'centos'"
    

     

    备考:这里能够跑下mysql安全脚本,做下安全加固--请看https://www.cnblogs.com/xsuid/p/9368389.html

     

    [root@6mini httpd-2.4.27]#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}
    

    (五)测试php与MariaDB的连接

    vim /app/httpd24/htdocs/index.php
    <?php
    $mysqli=new mysqli("192.168.136.229","wpadmin","centos");
    if(mysqli_connect_errno()){
    echo "连接数据库失败!";
    $mysqli=null;
    exit;
    }
    echo "连接数据库成功!";
    $mysqli->close();
    phpinfo();
    ?>
    

    图片 19

    • 将下载好的源码文件上传至Linux,(通过SecureCRT, put 路线),会一贯上传至Linux的用户目录(主目录)下;
    • 解压文件:tar -zxvf redis-3.0.0.tar.gz
    • 编写翻译:进入解压后的公文夹里,运营make,会将.c文件编写翻译为.o文件;
    • 设置(能够在此步骤指虞诩装路线,未有会创设): make prefix=/usr/local/redis install;安装到位后在/usr/local/redis/bin/下会开采多少个可实施文件:
      • redis-benchmark --品质测试工具;
      • redis-check-aof --AOF文件修复工具;
      • redis-check-dump --RDB文件检查工具;
      • redis-cli --命令行客户端;
      • redis-server --redis服务器运行命令
    • 从解压的源码文件夹里copy配置文件(redis.conf)至/usr/local/redis/文件夹下;进入解压后的源码文件夹,cp redis.conf /usr/local/redis
    • 修改配置文件,今后端格局运行.(修改配置文件为:daemonize yes)
    • 开发银行redis: 进入安装文件夹,./bin/redis-server ./redis.conf

    PHP编写翻译安装

    把httpd24增加到服务列表

    (六)安装配备WordPress

    • 解压缩软件包至网页存放目录
    tar -xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs/
    cd /app/httpd24/htdocs/
    ln -s wordpress/ blog
    cd blog/
    
    • 编辑安装配备文件
    cp wp-config-sample.php wp-config.php
    vim wp-config.php
    // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
    /** WordPress数据库的名称 */
    define('DB_NAME', 'wpdb');
    
    /** MySQL数据库用户名 */
    define('DB_USER', 'wpadmin');
    
    /** MySQL数据库密码 */
    define('DB_PASSWORD', 'centos');
    
    /** MySQL主机 */
    define('DB_HOST', '192.168.136.229');
    
    • 浏览器展开http://192.168.136.129/blog/,依据提醒填入音讯开端设置

    图片 20

    • WordPress安装成功后,博客显示分界面

    图片 21

    • ab测试品质
      ab -c 10 -n 100 http://192.168.136.129/blog/

    图片 22

    二.RPM包格局安装(使用RPM工具,安装.rpm/.src.rpm格式的文本)

    1、安装包与解压

    yum install libxml2-devel bzip2-devel libmcrypt-devel
    
    tar xvf php-7.1.18.tar.bz2 
    

     

    [root@6mini httpd-2.4.27]#chkconfig --add httpd24
    [root@6mini httpd-2.4.27]#chkconfig --list
    auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
    blk-availability    0:off   1:on    2:on    3:on    4:on    5:on    6:off
    crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
    httpd24         0:off   1:off   2:off   3:off   4:off   5:off   6:off
    

    (七)编写翻译安装xcache

    • 解压缩源码包
    tar xvf xcache-3.2.0.tar.bz2 -C /usr/local/src
    cd /usr/local/src/xcache-3.2.0/
    
    • 编写翻译安装
    phpize     //生成configure文件
    ./configure  --enable-xcache --with-php-config=/app/php/bin/php-config
    make && make install
    

    图片 23

    图片 24

    • 安装后布署
    mkdir /etc/php.d
    cp xcache.ini /etc/php.d/
    vim /etc/php.d/xcache.ini
    extension = /app/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
    
    service httpd24 restart
    
    • ab测试品质
      ab -c 10 -n 100 http://192.168.136.129/blog/

    图片 25

    步骤:

    2、源码编写翻译

    cd php-7.1.18/
    ./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 
    --enable-fpm 
    --with-config-file-path=/etc 
    --with-config-file-scan-dir=/etc/php.d 
    --enable-maintainer-zts 
    --disable-fileinfo
    
    make -j 4 && make install
    

     

    关门防火墙和selinux

    三、CentOS 6.9情状LAMP源码编写翻译安装WordPress(php fpm方式)

    1. 安装从前先查询是不是带有相关软件:rpm -qa | grep -i
    2. 留存则移除:rpm -e --nodeps 软件名 #nodeps:不表明套件间的交互关联性
    3. 存在老版本,则更新: rpm -Uvh
    4. 安装:rpm -ivh

    3、意况变量

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

     

    [root@6mini httpd-2.4.27]#iptables -F
    [root@6mini httpd-2.4.27]#iptables -L
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination   
    
    [root@6mini httpd-2.4.27]#vim /etc/selinux/config
    SELINUX=disabled
    [root@6mini httpd-2.4.27]#setenforce 0
    [root@6mini httpd-2.4.27]#getenforce 
    Permissive
    

    (一)意况准备

    • 搭建情形:
      主机1:负责httpd, php, wordpress (IP: 192.168.136.129)
      主机2:负责MariaDB (IP: 192.168.136.229)

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

    三.yum安装

    4、php设置

    cp php.ini-production /etc/php.ini
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    PHP配置文件
    
    chmod  x /etc/init.d/php-fpm
    chkconfig --add php-fpm
    chkconfig php-fpm on
    启动程序
    
    cd /app/php/etc
    cp php-fpm.conf.default php-fpm.conf
    cp php-fpm.d/www.conf.default php-fpm.d/www.conf
    php fastcgi配置文件,根据情况来更改
    

    图片 26

    图片 27

    图片 28

     

    检查/app/httpd24/logs/是否变动

    (二)源码编译安装httpd2.4

    • 设置开荒条件
    yum groupinstall "development tools"
    yum install openssl-devel expat-devel pcre-devel
    
    • 解压缩源码包
    tar xvf apr-1.6.2.tar.gz -C /usr/local/src
    tar xvf apr-util-1.6.0.tar.gz  -C /usr/local/src
    tar xvf httpd-2.4.27.tar.bz -C /usr/local/src
    cd /usr/local/src
    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
    
    • 设置运营脚本
    scp /etc/init.d/httpd  192.168.136.129:/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
    ss -ntlp
    
    • 安装扶助文件路线
    vim /etc/man.config
    MANPATH /app/httpd24/man
    

    因此yum实行软件安装或系统进级的面目便是通过yum命令下载钦点的长途互连网主机上的RPM包,然后自动进行安装,同进消除互相间的正视性关系.

    5、运转服务

    service php-fpm start
    

     

    [root@6mini httpd-2.4.27]#ll /app/httpd24/logs/
    total 8
    -rw-r--r--. 1 root root   0 Oct 16 16:37 access_log
    -rw-r--r--. 1 root root 246 Oct 16 16:37 error_log
    -rw-r--r--. 1 root root   6 Oct 16 16:37 httpd.pid
    

    (三)二进制安装玛丽亚DB

    • 解压缩二进制包至钦定目录
    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 -d /app/mysqldb -s /sbin/nologin mysql -m
    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 mysqld
    
    • 安装日志目录,并运营服务
    touch /var/log/mysqld.log
    chown mysql /var/log/mysqld.log
    service mysqld start
    ss -ntlp
    
    • 设置遭受变量
    vim /etc/profile.d/lamp.sh
    PATH=/usr/local/mysql/bin:$PATH
    source /etc/profile.d/lamp.sh 
    
    • 配备数据库,建构WordPress的数据库
    mysql_secure_installation
    
    mysql -uroot -p
    MariaDB [(none)]> create database wpdb;
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'192.168.136.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'127.%' identified by 'centos';
    MariaDB [(none)]> grant all on wpdb.* to wpadmin@'localhost' identified by 'centos';
    

    主导用法:

    安装wordpress

    tar xvf wordpress-4.9.4-zh_CN.tar.gz
    
    cp -a wordpress/* /app/httpd24/htdocs/
    
    cd /app/httpd24/htdocs/
    
    mv wp-config-sample.php wp-config.php 
    
    vim wp-config.php
    
    根据上面mysql创建信息更改
    

    图片 29

     

    运用curl检查httpd是或不是能健康使用

    (四)源码编写翻译安装php

    • 编写翻译境况策动
    yum install libxml2-devel bzip2-devel libmcrypt-devel
    tar xvf php-5.6.4.tar.xz -C /usr/local/src/
    cd /usr/local/src/php-5.6.4/
    
    • 编写翻译安装
    ./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 --enable-fpm --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
    

    图片 30

    图片 31

    • 设置景况变量
    vim /etc/profile.d/lamp.sh
    PATH=/app/php/bin:/app/httpd24/bin:$PATH
    source /etc/profile.d/lamp.sh
    
    • 安插运营脚本
    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
    
    • 编纂配置文件
    cp php.ini-production /etc/php.ini
    cd /app/php/etc/
    cp php-fpm.conf.default php-fpm.conf
    
    vim /app/httpd24/conf/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
    // 修改下面行
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
    
    service php-fpm start
    service httpd24 restart
    ss -ntlp
    
    1. 安装rpm包,如dhcp: yum install dhcp
    2. 去除rpm包及依赖包: yum remove dhcp
    3. 自己争辩可更新的rpm包:yum check-update
    4. 创新具备:yum update
    5. 更新内定的rpm包:yum update dhcp
    6. 大面积晋级版本,包蕴陈旧的包: yum upgrade
    7. 列出已经设置的有着rpm包: yum list installed
    8. 招来匹配特定字符的rpm包的详细新闻: yum search wget
    9. 寻找包蕴特定文件名的rpm包: yum provides realplay

    外加虚拟主机的达成

    编辑文件
    vim /etc/httpd/conf.d/vhosts.conf
    DirectoryIndex  index.php
    <VirtualHost *:80>
    ServerName www.pma.com
    DocumentRoot /var/www/html/
    ProxyRequests Off
    ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/pma/$1
    <Directory "/var/www/html">
    Require all granted
    </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName www.wordpress.com
    DocumentRoot /var/www/html/
    ProxyRequests Off
    ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/wordpress/$1
    <Directory "/var/www/html">
    Require all granted
    </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName www.forum.com
    DocumentRoot /var/www/html/
    ProxyRequests Off
    ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/forum/$1
    <Directory "/var/www/html">
    Require all granted
    </Directory>
    </VirtualHost>
    

     

     

    [root@6mini httpd-2.4.27]#curl 192.168.163.105
    <html><body><h1>It works!</h1></body></html>
    

    (五)测试php与MariaDB的连接

    vim /app/httpd24/htdocs/index.php
    <?php
    $mysqli=new mysqli("192.168.136.229","wpadmin","centos");
    if(mysqli_connect_errno()){
    echo "连接数据库失败!";
    $mysqli=null;
    exit;
    }
    echo "连接数据库成功!";
    $mysqli->close();
    phpinfo();
    ?>
    

    图片 32

    四.二进制软件安装(.rpm/.tar.gz/.tgz/.bz2)

    结语:后续更了不起

    二进制安装mariadb

    (六)安装配备WordPress

    • 解压缩软件包至网页存放目录
    tar -xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs/
    cd /app/httpd24/htdocs/
    ln -s wordpress/ blog
    cd blog/
    
    • 编排安装配备文件
    cp wp-config-sample.php wp-config.php
    vim wp-config.php
    // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
    /** WordPress数据库的名称 */
    define('DB_NAME', 'wpdb');
    
    /** MySQL数据库用户名 */
    define('DB_USER', 'wpadmin');
    
    /** MySQL数据库密码 */
    define('DB_PASSWORD', 'centos');
    
    /** MySQL主机 */
    define('DB_HOST', '192.168.136.229');
    
    • 浏览器张开http://192.168.136.129/blog/,依照指示填入新闻初始设置

    • ab测试品质
      ab -c 10 -n 100 http://192.168.136.129/blog/

    图片 33

    Linux下二进制格式的软件是指事先已经在各个平台编译安装好的相关软件,然后压缩打包,安装时只需解压或,恐怕试行可安装文件就能够;如tomcat/Oracle/Weblogic

    解压二进制安装包到/usr/local/目录,把解压后的mariadb目录改名字为mysql或然创造三个名称叫mysql的软连接

    (七)编写翻译安装xcache

    • 解压缩源码包
    tar xvf xcache-3.2.0.tar.bz2 -C /usr/local/src
    cd /usr/local/src/xcache-3.2.0/
    
    • 编写翻译安装
    phpize     //生成configure文件
    ./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-zts-20131226/xcache.so
    
    service php-fpm restart
    
    • ab测试品质
      ab -c 10 -n 100 http://192.168.136.129/blog/

    图片 34

    经过看出:在php_fpm方式下,使用xcache加速功能升高特别明显

    二进制软件包常见的打包格式包含.rpm/.tar.gz/.tgz/.bz2;直接解压到安装文件夹就能够成功安装;删除时平素删除相应的文本夹,如若解压后文件分散在四个目录,须求各种删除;

    [root@6mini local]#tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/
    [root@6mini ~]#cd /usr/local/
    [root@6mini local]#ls
    bin  etc  games  include  lib  lib64  libexec  mariadb-5.5.57-linux-x86_64  sbin  share  src
    [root@6mini local]#ln -s mariadb-5.5.57-linux-x86_64/ mysql
    [root@6mini local]#ls
    bin  games    lib    libexec                      mysql  share
    etc  include  lib64  mariadb-5.5.57-linux-x86_64  sbin   src
    

    对此提供了安装程序的软件包,直接进入目录,运营类似于setup/install/install.sh之类的公文,然后跟随提醒实行相应设置,之后安装就机关达成;

    编制碰着变量的配备文件,在文书中增加mysql意况变量

    比如1:安装java jdk(主要看意况变量配置)

    [root@6mini local]#vim /etc/profile.d/lamp.sh 
    PASH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PASH
    [root@6mini local]#. /etc/profile.d/lamp.sh 
    [root@6mini local]#echo $PASH
    /app/httpd24/bin/:/usr/local/mysql/bin:/app/httpd24/bin/:
    
    • 解压JDK: tar -zxvf jdk-7u72-linux-i586.gz
    • 运动jdk至安装文件夹:
      • mkdir /usr/local/src/java
      • mv jdk1.7.0_72/ /usr/local/src/java/jdk1.7 #将jdk1.7.0_72下在颇具剧情称至新文件夹jdk1.7以下,并且删除原版的书文件夹(jdk1.7.0_72)
    • 配备连串情形变量
      • vim /etc/profile #累加以下两句
      • export JAVA_HOME=/usr/local/src/java/jdk1.7
      • export PATH=$JAVA_HOME/bin:$PATH
    • 使配置生效并测试
      • source /etc/profile
      • java -version

    创造mysql用户,钦命家目录为 /app/mysqldb,用户类型为系统用户

    比如2:安装tomcat(首要看防火墙配置)

    [root@6mini local]#useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
    [root@6mini local]#getent passwd mysql
    mysql:x:498:498::/app/mysqldb:/sbin/nologin
    
    [root@6mini app]#ll -d mysqldb/
    drwx------. 2 mysql mysql 4096 Oct 16 17:10 mysqldb/
    
    • 解压: tar -zxvf apache-tomcat-7.0.52.tar.gz
    • 移动: mv apache-tomcat-7.0.52 /usr/local/src/java/tomcat7
    • 启动:/usr/local/src/java/tomcat7/bin/startup.sh
    • 配备防火墙:
      • vim /etc/sysconfig/iptables
      • -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT #开放8080端口
      • service iptables restart #重启防火墙

    运行scripts/mysql_install_db脚本,生成mysql文件,钦点目录为/app/mysqldb/,钦定用户为mysql

    [root@6mini mysql]#scripts/mysql_install_db --datadir=/app/mysqldb/ --user=mysql
    [root@6mini mysqldb]#ll /app/mysqldb/
    total 32
    -rw-rw----. 1 mysql mysql 16384 Oct 16 17:21 aria_log.00000001
    -rw-rw----. 1 mysql mysql    52 Oct 16 17:21 aria_log_control
    drwx------. 2 mysql root   4096 Oct 16 17:21 mysql
    drwx------. 2 mysql mysql  4096 Oct 16 17:21 performance_schema
    drwx------. 2 mysql root   4096 Oct 16 17:21 test
    

    创设mysql配置文件

    [root@6mini mysql]#mkdir /etc/mysql
    [root@6mini mysql]#cp support-files/my-large.cnf /etc/mysql/my.cnf
    [root@6mini mysql]#vim /etc/mysql/my.cnf
    [mysqld]
    datadir = /app/mysqldb
    innodb_file_per_table = ON
    skip_name_resolve = ON
    

    复制mysql运维的服务进度文件到/etc/init.d/,并该名称mysql增加到服务列表

    [root@6mini mysql]#cp support-files/mysql.server /etc/init.d/mysqld
    [root@6mini mysql]#chkconfig --add mysqld
    

    创办日志文件,并赋予mysql的写权限

    [root@6mini mysql]#touch /var/log/mysqld.log
    [root@6mini mysql]#chown mysql /var/log/mysqld.log
    [root@6mini mysql]#ll /var/log/mysqld.log 
    -rw-r--r--. 1 mysql root 0 Oct 16 17:39 /var/log/mysqld.log
    

    启动mysql

    [root@6mini mysql]#service mysqld start
    Starting MySQL.171016 17:41:04 mysqld_safe Logging to '/var/log/mysqld.log'.
    171016 17:41:04 mysqld_safe Starting mysqld daemon with databases from /app/mysqldb
    .. SUCCESS! 
    

    使用mysql_secure_installation早先化数据库

    [root@6mini bin]#mysql_secure_installation
    /usr/local/mysql/bin/mysql_secure_installation: line 393: find_mysql_client: command not found
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user.  If you've just installed MariaDB, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MariaDB
    root user without the proper authorisation.
    
    Set root password? [Y/n] y
    New password: 
    Re-enter new password: 
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] y
     ... Success!
    
    By default, MariaDB comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
    

    行使root登陆数据库,为workpress创设数据库,并授权给用户wpu

    [root@6mini bin]#mysql -uroot -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 12
    Server version: 5.5.57-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [(none)]> CREATE DATABASE wpdb;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpu@'%' IDENTIFIED BY 'centos';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> QUIT
    Bye
    

    应用wpu用户登入数据库,查看并确定数据库wpdb的成形

    [root@6mini bin]#mysql -uwpu -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 13
    Server version: 5.5.57-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [(none)]> SHOW DATABASES;
     -------------------- 
    | Database           |
     -------------------- 
    | information_schema |
    | wpdb               |
     -------------------- 
    2 rows in set (0.00 sec)
    
    MariaDB [(none)]> 
    

    源码编写翻译php

    编译安装php在此以前,首先安装php的信赖包libxml2-devel bzip2-devel libmcrypt-devel,再拓展编写翻译安装

    [root@6mini ~]#yum install libxml2-devel bzip2-devel libmcrypt-devel
    [root@6mini ~]#tar xvf php-5.6.31.tar.bz2 
    [root@6mini ~]#cd php-5.6.31
    [root@6mini 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
    
    [root@6mini php-5.6.31]# make -j 2 && make install
    

    复制多少个php的计划文件,直接改名,不用安装

    [root@6mini php-5.6.31]#cp php.ini-production /etc/php.ini
    

    编排httpd的布局文件,使httpd协理php

    [root@6mini php-5.6.31]#vim /app/httpd24/conf/httpd.conf
    
    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    </IfModule>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    </Directory>
    #
    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    

    测试php程序
    率先运行httpd24,在主目录里编辑php测试页进行测试

    [root@6mini php-5.6.31]#service httpd24 restart
    Stopping httpd:                                            [  OK  ]
    Starting httpd: AH00557: httpd: apr_sockaddr_info_get() failed for 6mini
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
                                                               [  OK  ]
    [root@6mini php-5.6.31]#vim /app/httpd24/htdocs/index.php
    <?php
    phpinfo();
    ?>
    

    动用浏览器查看php网页

    图片 35

    配置wordpress

    解压wordpress到httpd主目录,并更名字为blog

    [root@6mini ~]#unzip wordpress-4.8.1-zh_CN.zip -d /app/httpd24/htdocs/
    [root@6mini ~]#cd /app/httpd24/htdocs
    [root@6mini htdocs]#mv wordpress/ blog
    

    动用wordpress的布署模板生成配置文件,并修改数据库的消息,确认保障数据库平常使用

    [root@6mini htdocs]#cd blog/
    [root@6mini blog]#mv wp-config-sample.php wp-config.php 
    [root@6mini blog]#vim wp-config.php 
    
    <?php
    /**
     * WordPress基础配置文件。
     *
     * 这个文件被安装程序用于自动生成wp-config.php配置文件,
     * 您可以不使用网站,您需要手动复制这个文件,
     * 并重命名为“wp-config.php”,然后填入相关信息。
     *
     * 本文件包含以下配置选项:
     *
     * * MySQL设置
     * * 密钥
     * * 数据库表名前缀
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/zh-cn:编辑_wp-config.php
     *
     * @package WordPress
     */
    
    // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
    /** WordPress数据库的名称 */
    define('DB_NAME', 'wpdb');
    
    /** MySQL数据库用户名 */
    define('DB_USER', 'wpu');
    
    /** MySQL数据库密码 */
    define('DB_PASSWORD', 'centos');
    
    /** MySQL主机 */
    define('DB_HOST', 'localhost');
    

    浏览器登入并配备wordpress站点

    http://192.168.163.105/blog

    图片 36

    图片 37

    图片 38

    图片 39

    图片 40

    设置到位

    本文由新葡亰496net发布于电脑系统,转载请注明出处:Centos7上编写翻译安装LAMP,Linux下软件安装的三种

    关键词: