zoukankan      html  css  js  c++  java
  • LAMP一键安装

    • 参考:

    https://lnmp.org/install.html
    https://www.cnblogs.com/xiaoxitest/p/6130065.html
    https://lamp.sh/faq.html

    • LAMP简介

    LAMP是指以下几个模块的统称。


    LNMP则是指Linux+Nginx+Mysql+Php

    • 安装命令:

    wget -c http://soft.vpser.net/lnmp/lnmp1.4-full.tar.gz && tar zxf lnmp1.4-full.tar.gz && cd lnmp1.4-full && ./install.sh lamp

    • 安装版本
    模板 版本
    MySQL  5.7.18
    PHP 5.6.31
    Apache 2.4.27



    • 安装流程

    (安装约需1h-2h,看网速):
    [root@localhost lnmp1.4-full]# ./install.sh lamp
    +------------------------------------------------------------------------+
    | LNMP V1.4 for CentOS Linux Server, Written by Licess |
    +------------------------------------------------------------------------+
    | A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux |
    +------------------------------------------------------------------------+
    | For more information please visit https://lnmp.org |
    +------------------------------------------------------------------------+
    You have 5 options for your DataBase install.
    1: Install MySQL 5.1.73
    2: Install MySQL 5.5.56 (Default)
    3: Install MySQL 5.6.36
    4: Install MySQL 5.7.18
    5: Install MariaDB 5.5.56
    6: Install MariaDB 10.0.30
    7: Install MariaDB 10.1.23
    0: DO NOT Install MySQL/MariaDB
    Enter your choice (1, 2, 3, 4, 5, 6, 7 or 0): 4
    You will install MySQL 5.7.18
    ===========================
    Please setup root password of MySQL.(Default password: root)
    Please enter: *******
    MySQL root password:*******
    ===========================
    Do you want to enable or disable the InnoDB Storage Engine?
    Default enable,Enter your choice [Y/n]: y
    You will enable the InnoDB Storage Engine
    ===========================
    You have 6 options for your PHP install.
    1: Install PHP 5.2.17
    2: Install PHP 5.3.29
    3: Install PHP 5.4.45
    4: Install PHP 5.5.38 (Default)
    5: Install PHP 5.6.31
    6: Install PHP 7.0.21
    7: Install PHP 7.1.7
    Enter your choice (1, 2, 3, 4, 5, 6 or 7): 5
    You will install PHP 5.6.31
    ===========================
    You have 3 options for your Memory Allocator install.
    1: Don't install Memory Allocator. (Default)
    2: Install Jemalloc
    3: Install TCMalloc
    Enter your choice (1, 2 or 3):
    No input,You will not install Memory Allocator.
    ===========================
    Please enter Administrator Email Address: ***@139.com
    ===========================
    Server Administrator Email: ***@139.com
    ===========================
    ===========================
    You have 2 options for your Apache install.
    1: Install Apache 2.2.34 (Default)
    2: Install Apache 2.4.27
    Enter your choice (1 or 2): 2
    You will install Apache 2.4.27

    Press any key to install...or Press Ctrl+c to cancel
    ============================Install PHPMyAdmin=================================
    ============================phpMyAdmin install completed=======================
    iptables: Saving firewall rules to /etc/sysconfig/iptables: [ 确定 ]
    Add Startup and Starting LAMP...
    Add httpd service at system startup...
    start apache... (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
    (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
    Clean src directory...
    +------------------------------------------------------------------------+
    | LNMP V1.4 for CentOS Linux Server, Written by Licess |
    +------------------------------------------------------------------------+
    | For more information please visit https://lnmp.org |
    +------------------------------------------------------------------------+
    | lnmp status manage: lnmp {start|stop|reload|restart|kill|status} |
    +------------------------------------------------------------------------+
    | phpMyAdmin: http://IP/phpmyadmin/ |
    | phpinfo: http://IP/phpinfo.php |
    | Prober: http://IP/p.php |
    +------------------------------------------------------------------------+
    | Add VirtualHost: lnmp vhost add |
    +------------------------------------------------------------------------+
    | Default directory: /home/wwwroot/default |
    +------------------------------------------------------------------------+
    | MySQL/MariaDB root password: *********                          |
    +------------------------------------------------------------------------+
    +-------------------------------------------+
    | Manager for LNMP, Written by Licess |
    +-------------------------------------------+
    | https://lnmp.org |
    +-------------------------------------------+
    Apache is running.
    SUCCESS! MySQL running (28998)
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State
    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
    tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN
    tcp6 0 0 :::3306 :::* LISTEN
    tcp6 0 0 :::111 :::* LISTEN
    tcp6 0 0 :::80 :::* LISTEN
    tcp6 0 0 :::61616 :::* LISTEN
    tcp6 0 0 :::41852 :::* LISTEN
    tcp6 0 0 :::43424 :::* LISTEN
    tcp6 0 0 :::8161 :::* LISTEN
    tcp6 0 0 :::10050 :::* LISTEN
    tcp6 0 0 :::2181 :::* LISTEN
    tcp6 0 0 :::5672 :::* LISTEN
    Install lnmp takes 110 minutes.
    Install lnmp V1.4 completed! enjoy it.

    • 默认安装信息

    MySQL 安装目录
    /usr/local/mysql

    MySQL 配置文件: /etc/my.cnf
    MySQL 数据库目录
    /usr/local/mysql/data
    MySQL 的 root 密码。在安装时会要求输入,如不输入则为默认密码 root)MySQL 的 root 密码。在安装时会要求输入,如不输入则为默认密码 root)

    PHP 安装目录
    /usr/local/php


    PHP 配置文件: /usr/local/php/etc/php.ini
    PHP 所有扩展配置文件目录: /usr/local/php/php.d/
    Apache 安装目录
    /usr/local/apache
    Apache 日志目录: /usr/local/apache/logs
    Apache SSL 配置文件: /usr/local/apache/conf/extra/httpd-ssl.conf
    新建站点配置文件: /usr/local/apache/conf/vhost/新建站点的配置文件名.conf

    phpMyAdmin 安装目录
    /data/www/default/phpmyadmin
    phpmyadmin 后台地址: http://域名或IP/phpmyadmin/
    (若目录已改名,此处应为改名后的地址,比如 http://域名或ip/admin_8989/)

    phpmyadmin 默认用户名:root 默认密码:root
    (安装完成后出于安全,建议将此目录改名,比如改为 /data/www/default/admin_8989)

    • 安装后检查

    LAMP状态管理命令:

    LAMP 1.2+状态管理: lnmp {start|stop|reload|restart|kill|status}
    LAMP 1.2+各个程序状态管理: lnmp {httpd|mysql|mariadb|pureftpd} {start|stop|reload|restart|kill|status}

    检查Apached状态
     lnmp httpd status
     lnmp httpd start

    MySQL/MariaDB/Percona Server 命令:
    /etc/init.d/mysqld (start|stop|restart|status)

    Apache 命令:
    /etc/init.d/httpd (start|stop|restart|status)

    Memcached 命令(可选安装)
    /etc/init.d/memcached (start|stop|restart|status)

    Redis 命令(可选安装)
    /etc/init.d/redis-server (start|stop|restart|status)

    • 卸载LAMP

    找到unstall.sh脚本,执行,选择对应的安装模式即可

    Current Stack: unknow
    Enter 1 to uninstall LNMP
    Enter 2 to uninstall LNMPA
    Enter 3 to uninstall LAMP
    (Please input 1, 2 or 3): 3
    You will uninstall LAMP
    Please backup your configure files and mysql data!!!!!!
    The following directory or files will be remove!
    /usr/local/apache

    /etc/init.d/httpd
    /etc/init.d/None
    /usr/local/php
    /usr/local/zend
    /etc/my.cnf
    /bin/lnmp

    Press any key to start...or Press Ctrl+c to cancel

    Stoping LAMP...
    ./uninstall.sh:行135: lnmp: 未找到命令
    ./uninstall.sh:行136: lnmp: 未找到命令
    Deleting iptables rules...
    Removing httpd service at system startup...
    服务 httpd 信息读取出错:没有那个文件或目录
    服务 httpd 信息读取出错:没有那个文件或目录
    Deleting LAMP files...
    LAMP Uninstall completed.

    • 问题定位:

    问题1: 如果安装后检查MYSQl,出现以下报错MySQL is running but PID file could not be found,需要先kill掉重启一下就好了:
    [root@localhost etc]# /etc/init.d/mysql status
    ERROR! MySQL is running but PID file could not be found
    [root@localhost etc]# /etc/init.d/mysql start
    Starting MySQL.. SUCCESS!
    [root@localhost etc]# /etc/init.d/mysql status
    SUCCESS! MySQL running (37504)
    [root@localhost etc]#


    问题2: 安装LAMP过程报错,提示httpd*文件找不到


    vi /root/lnmp-install.log

    checking whether to enable mod_ssl... checking dependencies
    checking for OpenSSL... checking for user-provided OpenSSL base directory... none
    checking for OpenSSL version >= 0.9.8a... FAILED
    configure: WARNING: OpenSSL version is too old
    no
    checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
    make: *** 没有指明目标并且找不到 makefile。 停止。
    mv: 无法获取"/usr/local/apache/conf/httpd.conf" 的文件状态(stat): 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/httpd.conf": 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/extra/httpd-vhosts.conf": 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/extra/httpd-ssl.conf": 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/enable-apache-ssl-vhost-example.conf": 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/extra/httpd-default.conf": 没有那个文件或目录
    cp: 无法创建普通文件"/usr/local/apache/conf/extra/mod_remoteip.conf": 没有那个文件或目录
    mkdir: 无法创建目录"/usr/local/apache/conf/vhost": 没有那个文件或目录
    sed:无法读取 /usr/local/apache/conf/extra/httpd-vhosts.conf:没有那个文件或目录
    ^[[0;34m[+] Installing php-5.6.31^[[0m
    Uncompress php-5.6.31.tar.bz2...


    Write ZendGuardLoader to php.ini...
    Create PHP Info Tool...
    Copy PHP Prober...
    Copy Opcache Control Panel...
    ============================Install PHPMyAdmin=================================
    ============================phpMyAdmin install completed=======================
    iptables: Saving firewall rules to /etc/sysconfig/iptables: [ 确定 ]^M
    Add Startup and Starting LAMP...
    Add httpd service at system startup...
    start apache... /etc/init.d/httpd:行87: /usr/local/apache/bin/httpd: 没有那个文件或目录
    failed
    Add mysql service at system startup...
    Starting MySQL.. SUCCESS!
    ^[[0;31mError: Apache install failed.^[[0m
    ^[[0;32mMySQL: OK^[[0m
    ^[[0;31mError: PHP install failed.^[[0m
    ^[[0;31mSorry, Failed to install LNMP!^[[0m
    ^[[0;31mPlease visit https://bbs.vpser.net/forum-25-1.html feedback errors and logs.^[[0m
    ^[[0;31mYou can download /root/lnmp-install.log from your server,and upload lnmp-install.log to LNMP Forum.^[[0m

    The output of /usr/local/apache/bin/apxs follows:
    ./configure: line 6199: /usr/local/apache/bin/apxs: No such file or directory
    configure: error: Aborting
    make: *** 没有指明目标并且找不到 makefile。 停止。
    make: *** 没有规则可以创建目标“install”。 停止。
    Copy new php configure file...
    Modify php.ini......
    include/php.sh:行23: pear: 未找到命令
    include/php.sh:行24: pecl: 未找到命令
    include/php.sh:行29: php: 未找到命令
    curl: (23) Failed writing body (0 != 16133)
    Install ZendGuardLoader for PHP 7.1...
    unavailable now.

    原因是opens-ssl的版本过低,或者没有安装导致。

    解决办法:yum install openssl-devel

    如果安装openssl-devel报错,yum install 时候提示错误:

    #yum install openssh
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * epel: ftp.cuhk.edu.hk
    正在解决依赖关系
    There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
    --> 正在检查事务
    ---> 软件包 openssh.x86_64.0.6.4p1-8.el7 将被 升级
    --> 正在处理依赖关系 openssh = 6.4p1-8.el7,它被软件包 openssh-clients-6.4p1-8.el7.x86_64 需要
    --> 正在处理依赖关系 openssh = 6.4p1-8.el7,它被软件包 openssh-server-6.4p1-8.el7.x86_64 需要
    ---> 软件包 openssh.x86_64.0.6.6.1p1-12.el7_1 将被 升级
    --> 正在处理依赖关系 openssh = 6.6.1p1-12.el7_1,它被软件包 openssh-clients-6.6.1p1-12.el7_1.x86_64 需要
    --> 正在处理依赖关系 openssh = 6.6.1p1-12.el7_1,它被软件包 openssh-server-6.6.1p1-12.el7_1.x86_64 需要
    ---> 软件包 openssh.x86_64.0.6.6.1p1-22.el7 将被 更新
    --> 正在检查事务
    ---> 软件包 openssh.x86_64.0.6.4p1-8.el7 将被 升级
    ---> 软件包 openssh-clients.x86_64.0.6.4p1-8.el7 将被 升级
    ---> 软件包 openssh-clients.x86_64.0.6.6.1p1-12.el7_1 将被 升级
    ---> 软件包 openssh-clients.x86_64.0.6.6.1p1-22.el7 将被 更新
    ---> 软件包 openssh-server.x86_64.0.6.4p1-8.el7 将被 升级
    ---> 软件包 openssh-server.x86_64.0.6.6.1p1-12.el7_1 将被 升级
    ---> 软件包 openssh-server.x86_64.0.6.6.1p1-22.el7 将被 更新
    --> 解决依赖关系完成
    错误:软件包:openssh-server-6.4p1-8.el7.x86_64 (@anaconda)
    需要:openssh = 6.4p1-8.el7
    正在删除: openssh-6.4p1-8.el7.x86_64 (@anaconda)
    openssh = 6.4p1-8.el7
    更新,由: openssh-6.6.1p1-22.el7.x86_64 (base)
    openssh = 6.6.1p1-22.el7
    正在删除: openssh-6.6.1p1-12.el7_1.x86_64 (installed)
    openssh = 6.6.1p1-12.el7_1
    更新,由: openssh-6.6.1p1-22.el7.x86_64 (base)
    openssh = 6.6.1p1-22.el7
    错误:软件包:openssh-clients-6.4p1-8.el7.x86_64 (@anaconda)
    需要:openssh = 6.4p1-8.el7
    正在删除: openssh-6.4p1-8.el7.x86_64 (@anaconda)
    openssh = 6.4p1-8.el7
    更新,由: openssh-6.6.1p1-22.el7.x86_64 (base)
    openssh = 6.6.1p1-22.el7
    正在删除: openssh-6.6.1p1-12.el7_1.x86_64 (installed)
    openssh = 6.6.1p1-12.el7_1
    更新,由: openssh-6.6.1p1-22.el7.x86_64 (base)
    openssh = 6.6.1p1-22.el7
    您可以尝试添加 --skip-broken 选项来解决该问题
    ** 发现 3 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
    openssh-6.6.1p1-12.el7_1.x86_64 是 openssh-6.4p1-8.el7.x86_64 的副本
    openssh-clients-6.6.1p1-12.el7_1.x86_64 是 openssh-clients-6.4p1-8.el7.x86_64 的副本
    openssh-server-6.6.1p1-12.el7_1.x86_64 是 openssh-server-6.4p1-8.el7.x86_64 的副本

    原因:依赖Apache的安装包
    解决办法:package-cleanup --cleandupes
    package-cleanup : 用于清理本地安装的RPM软件包

    然后再 yum install openssh

    • 附:

    1. 安装过程,为避免ssh中断导致安装过程退出,可以使用screen命令

    linux screen 命令详解

    功能说明:
    使用telnet或SSH远程登录linux时,如果连接非正常中断(远程机器关闭),重新连接时,系统将开一个新的session,无法恢复原来的session.screen命令可以解决这个问题。Screen工具是一个终端多路转接器,在本质上,这意味着你能够使用一个单一的终端窗口运行多终端的应用。
    用法:

    1,开启一个screen并进入:
    screen -S test1 #这里用-S表示给screen起名字,以后切换的时候比较方便。这时就进去了screen test1了。里面可以跑一些程序。
    2,退出该screen:
    Ctrl-a d #这里的ctrl-a表示同时按ctrl键和a键,然后再单独按d键。这时退到跟终端。
    3,在根下查看开启的所有screen:
    screen -ls # 比如会有25764.test1 (Detached)等。
    4,在根下进入某个screen:
    screen -r test1 #这时又进入到指定的screen session中,或者screen -r 25764。
    5,关闭该session:
    exit #在该screen中退出,退到根下。

    2. 安装过程,如果网络没有问题,但是安装不上,可能是SELinux作怪,需要先临时关闭。

    查看SELinux状态:
    1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
    SELinux status: enabled
    2、getenforce ##也可以用这个命令检查
    关闭SELinux:
    1、临时关闭(不用重启机器):
    setenforce 0 ##设置SELinux 成为permissive模式
    ##setenforce 1 设置SELinux 成为enforcing模式
    2、修改配置文件需要重启机器:
    修改/etc/selinux/config 文件
    将SELINUX=enforcing改为SELINUX=disabled
    重启机器即可

  • 相关阅读:
    Flex 布局
    前端跨域之jsonp
    vs code 自定义代码片段
    vue中使用axios进行http通信
    Table边框合并
    getElementsBy 系列方法相比querySelector系列的区别
    vue中watch简单使用
    png图标任意赋色
    pc端与移动端适配解决方案之rem
    Express post请求无法解析参数的原因
  • 原文地址:https://www.cnblogs.com/xiaoer/p/8283402.html
Copyright © 2011-2022 走看看