设为首页 收藏本站
查看: 804|回复: 0

[经验分享] centos7源码安装lamp(新)

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2019-2-15 17:55:59 | 显示全部楼层 |阅读模式
  一、安装apache:


  • 安装软件:
    a. httpd官方网站/下载地址:
    http://httpd.apache.org/download.cgi

    https://github.com/dollarphper/soft/raw/master/apache/httpd-2.4.34.tar.gz
      b. arp、arp-util官方网站:

    http://apr.apache.org/download.cgi

    https://github.com/dollarphper/soft/raw/master/apache/apr-1.6.3.tar.gz
    https://github.com/dollarphper/soft/raw/master/apache/apr-util-1.6.1.tar.gz
      c. pcre官方网站:

    https://www.pcre.org/

    https://github.com/dollarphper/soft/raw/master/apache/pcre-8.42.tar.gz
  • 安装:
    a. 安装依赖:
    yum  -y  install  expat-devel
    yum  -y  install  libxml2-devel
      b. 解压:

    tar  -xzf  httpd-2.4.34.tar.gz
    tar  -xzf  apr-1.6.3.tar.gz
    tar  -xzf  apr-util-1.6.1.tar.gz
    tar  -xzf  pcre-8.42.tar.gz
      c. 移动apr、apr-util到httpd目录下并重命名:

    mv  apr-1.6.3  httpd-2.4.34/srclib/apr
    mv  apr-util-1.6.1  httpd-2.4.34/srclib/apr-util
      d. 安装pcre:
    d-1. 创建文件夹:

    mkdir  /etc/pcre
      d-2. 进入pcre目录:

    cd  pcre-8.42
      d-3. 编译安装:

    ./configure  --prefix=/etc/pcre
    make  &&  make  install  &&  make  clean
      e. 安装apache:
    e-1. 创建文件夹:

    mkdir  /etc/httpd
      e-2. 进入apache目录:

    cd  httpd-2.4.34
      e-3. 编译安装:

    ./configure  --prefix=/etc/httpd  -with-pcre=/etc/pcre/bin/pcre-config  -with-included-apr
    make  &&  make  install  &&  make  clean
      e-4. 创建apache用户:

    useradd  -s  /sbin/nologin  -M  apache
      e-5. 安装gzip模块:

    /etc/httpd/bin/apxs  -i  -c  -a  /home/lee/lamp/apache/httpd-2.4.34/modules/filters/mod_deflate.c
      e-6. 安装rewrite模块:

    /etc/httpd/bin/apxs  -i  -c  -a  /home/lee/lamp/apache/httpd-2.4.34/modules/mappers/mod_rewrite.c
  • 配置:
    a. 修改配置文件:
    vim /etc/httpd/conf/httpd.conf
    ServerRoot "/etc/httpd"
    ServerName lee
    User apache
    Group apache
    Listen 80
    LoadModule authn_file_module modules/mod_authn_file.so
    LoadModule authn_core_module modules/mod_authn_core.so
    LoadModule authz_host_module modules/mod_authz_host.so
    LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
    LoadModule authz_user_module modules/mod_authz_user.so
    LoadModule authz_core_module modules/mod_authz_core.so
    LoadModule access_compat_module modules/mod_access_compat.so
    LoadModule auth_basic_module modules/mod_auth_basic.so
    LoadModule reqtimeout_module modules/mod_reqtimeout.so
    LoadModule filter_module modules/mod_filter.so
    LoadModule mime_module modules/mod_mime.so
    LoadModule log_config_module modules/mod_log_config.so
    LoadModule env_module modules/mod_env.so
    LoadModule headers_module modules/mod_headers.so
    LoadModule setenvif_module modules/mod_setenvif.so
    LoadModule version_module modules/mod_version.so
    LoadModule unixd_module modules/mod_unixd.so
    LoadModule status_module modules/mod_status.so
    LoadModule autoindex_module modules/mod_autoindex.so
    LoadModule dir_module modules/mod_dir.so
    LoadModule alias_module modules/mod_alias.so
    LoadModule php7_module        modules/libphp7.so
    LoadModule deflate_module     modules/mod_deflate.so
    LoadModule rewrite_module     modules/mod_rewrite.so

    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
    AddOutputFilterByType DEFLATE application/x-javascript

    LimitRequestBody 10485760

    User apache
    Group apache

    ServerAdmin you@example.com

    AllowOverride none
    Require all denied

    DocumentRoot "/var/www/html"

    Header set Access-Control-Allow-Origin *
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
    AcceptPathInfo on


    DirectoryIndex index.php index.html


    Require all denied

    ErrorLog "logs/error_log"
    LogLevel warn

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    CustomLog "logs/access_log" common


    ScriptAlias /cgi-bin/ "/etc/httpd/cgi-bin/"




    AllowOverride None
    Options None
    Require all granted


    RequestHeader unset Proxy early


    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .phtml .php3 .inc


    Include conf/extra/proxy-html.conf


    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin

      b. 新建文件夹:

    mkdir  -p  /var/www/html
  • 测试:
    a. 启动命令:
    /etc/httpd/bin/apachectl  -k  start
      b. 停止命令:

    /etc/httpd/bin/apachectl  -k  stop
      c. 重启命令:

    /etc/httpd/bin/apachectl  -k  restart
      d. 添加环境变量:

    echo  'export  PATH=$PATH:/etc/httpd/bin/'  >>  /etc/profile
    .  /etc/profile
      e. 添加启动脚本:
    vim  /etc/init.d/httpd

    #!/bin/bash
    function start()
    {
    /etc/httpd/bin/apachectl  -k  start
    }
    function stop()
    {
    /etc/httpd/bin/apachectl  -k  stop
    }
    case "$1" in
    start)
    start
    ;;  
    stop)
    stop
    ;;  
    restart)
    stop
    start
    ;;
    *)
    echo "Usage : start | stop | restart"
    ;;
    esac
      f. 加载httpd:

    chmod  +x  /etc/init.d/httpd
    systemctl  daemon-reload
      g. 创建测试文件:

    echo  "hello world"  >  /var/www/html/index.html
      h. 浏览器访问:

    二、安装mysql:

  • 下载:
    https://dev.mysql.com/downloads/mysql/

    https://github.com/dollarphper/soft/blob/master/mysql/mysql-boost-8.0.12.tar.gz
  • 安装:
    a. 安装依赖:
    yum -y install cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel
      b. 创建用户:

    useradd mysql -s /sbin/nologin -M
      c. 创建文件夹:

    mkdir -p /usr/local/mysql/data
      d. 解压:

    tar  -xzf  mysql-boost-8.0.12.tar.gz
      e. 编译安装:

    cd  mysql-8.0.12
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    -DMYSQL_DATADIR=/usr/local/mysql/data \
    -DSYSCONFDIR=/etc \
    -DMYSQL_TCP_PORT=3306 \
    -DWITH_BOOST=./boost
    make  &&  make  install
  • 配置:
    a. 修改mysql所属者为mysql:
    chown  -R  mysql.mysql  /usr/local/mysql
      b. 修改配置文件:
    vim  /etc/my.cnf

    [mysqld]
    server-id=1
    port=3306
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    ngram_token_size=2
      c. 初始化:

    /usr/local/mysql/bin/mysqld  --initialize-insecure  --user=mysql --datadir=/usr/local/mysql/data
    /usr/local/mysql/bin/mysql_ssl_rsa_setup
      d. 启动服务:

    /usr/local/mysql/bin/mysqld_safe  --user=mysql  &
      e. 添加到环境变量:

    echo  'export  PATH=$PATH:/usr/local/mysql/bin/'  >>  /etc/profile
    .  /etc/profile
      f. 添加启动脚本:
    vim  /etc/init.d/mysqld

    #!/bin/bash
    function start()
    {
    /usr/local/mysql/bin/mysqld_safe  --user=mysql  &
    }
    function stop()
    {
    /usr/bin/pkill  mysqld
    }
    case "$1" in
    start)
    start
    ;;  
    stop)
    stop
    ;;  
    restart)
    stop
    start
    ;;
    *)
    echo "Usage : start | stop | restart"
    ;;
    esac
      g. 加载mysqld:

    chmod  +x  /etc/init.d/mysqld
    systemctl  daemon-reload
      k. 添加用户:

    CREATE  USER `root`@`%`  IDENTIFIED  BY  '123456';
      l. 授权:

    GRANT  ALL  ON *.*  TO  `root`@`%`  WITH  GRANT  OPTION;
      m. 删除系统预留用户:

    delete  from  mysql.user  where  host'%';
      n. 刷新权限:

    flush  privileges;
      o. 允许远程登录:
    o-1. 设置变量:

    SET  GLOBAL innodb_fast_shutdown  =  1;
      o-2. 退出:

    quit
      o-3. 升级:

    mysql_upgrade  -u  root  -p123456
  • 测试:
    /usr/local/mysql/bin/mysql

    三、安装php:
  • 下载:
    http://us1.php.net/downloads.php

    https://github.com/dollarphper/soft/blob/master/php/php-7.2.10.tar.gz
  • 安装:
    a. 安装依赖:
    yum  -y  install  libxml2  libxml2-devel
    yum  -y  install  curl-devel  libjpeg-devel  libpng-devel  freetype-devel
    yum  -y  install  libicu-devel
    yum  -y  install  libxslt-devel
    yum  -y  install  openssl  openssl-devel
      b. 解压:

    tar  -xzf  php-7.2.10.tar.gz
      c. 编译:

    cd  php-7.2.10
    ./configure  \
    --prefix=/usr/local/php   \
    --with-apxs2=/etc/httpd/bin/apxs  \
    --with-config-file-path=/usr/local/php/etc  \
    --enable-mysqlnd  \
    --with-mysqli=mysqlnd  \
    --with-pdo-mysql=mysqlnd  \
    --with-iconv-dir  \
    --with-freetype-dir=/usr/local/freetype  \
    --with-jpeg-dir  \
    --with-png-dir  \
    --with-zlib  \
    --with-libxml-dir=/usr  \
    --enable-xml  \
    --disable-rpath  \
    --enable-bcmath  \
    --enable-shmop  \
    --enable-sysvsem  \
    --enable-inline-optimization  \
    --with-curl  \
    --enable-mbregex  \
    --enable-mbstring  \
    --enable-intl  \
    --enable-pcntl  \
    --enable-ftp  \
    --with-gd  \
    --with-openssl  \
    --with-mhash  \
    --enable-pcntl  \
    --enable-sockets  \
    --with-xmlrpc  \
    --enable-zip  \
    --enable-soap  \
    --with-gettext  \
    --disable-fileinfo  \
    --enable-opcache  \
    --enable-maintainer-zts  \
    --with-xsl
      d. 安装:

    make  &&  make  install
      e. 下载pthreads:

    git  clone  https://github.com/krakjoe/pthreads.git
      f. 安装pthreads:

    cd  pthreads
    phpize
    ./configure  --with-php-config=/usr/local/php/bin/php-config
    make  &&  make install
      g. 开启pthreads扩展:
    vim  /usr/local/php/etc/php.ini

    [pthreads]
    extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pthreads.so
      h. 安装phpunit:
    h-1. 下载:

    wget  -O  phpunit  https://phar.phpunit.de/phpunit-7.phar
      h-2. 授权:

    chmod  +x  phpunit
      h-3. 添加到环境变量:

    mv  phpunit  /usr/local/php/bin
      i. 安装xdebug:
    i-1. 下载:

    git  clone  git://github.com/xdebug/xdebug.git
      i-2. 进入目录:

    cd  xdebug
      i-3. 生成编译文件:

    /usr/local/php/bin/phpize
      i-4. 编译:

    ./configure  --enable-xdebug  --with-php-config=/usr/local/php/bin/php-config
      i-5. 安装:

    make  &&  make  install
      i-6. 配置:

    [xdebug]
    zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=172.20.10.2
    xdebug.remote_port=9000
    xdebug.idekey="PHPSTORM"
  • 配置:
    a. 拷贝配置文件:
    cp  php.ini-production  /usr/local/php/etc/php.ini
      b. 配置文件参考:

    [PHP]
    engine = On
    short_open_tag = Off
    precision = 14
    output_buffering = 4096
    zlib.output_compression = Off
    implicit_flush = Off
    unserialize_callback_func =
    serialize_precision = -1
    disable_functions =
    disable_classes =
    zend.enable_gc = On
    expose_php = On
    max_execution_time = 30
    max_input_time = 60
    memory_limit = 512M
    error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
    display_errors = on
    display_startup_errors = Off
    log_errors = On
    log_errors_max_len = 1024
    ignore_repeated_errors = Off
    ignore_repeated_source = Off
    report_memleaks = On
    html_errors = On
    variables_order = "GPCS"
    request_order = "GP"
    register_argc_argv = Off
    auto_globals_jit = On
    post_max_size = 8M
    auto_prepend_file =
    auto_append_file =
    default_mimetype = "text/html"
    default_charset = "UTF-8"
    doc_root =
    user_dir =
    enable_dl = Off
    file_uploads = On
    upload_max_filesize = 20M
    max_file_uploads = 20
    allow_url_fopen = On
    allow_url_include = Off
    default_socket_timeout = 99999999
    date.timezone = PRC
    [CLI Server]
    cli_server.color = On
    [Date]
    [filter]
    [iconv]
    [intl]
    [sqlite3]
    [Pcre]
    [Pdo]
    [Pdo_mysql]
    pdo_mysql.cache_size = 2000
    pdo_mysql.default_socket=
    [Phar]
    [mail function]
    SMTP = localhost
    smtp_port = 25
    mail.add_x_header = Off
    [ODBC]
    odbc.allow_persistent = On
    odbc.check_persistent = On
    odbc.max_persistent = -1
    odbc.max_links = -1
    odbc.defaultlrl = 4096
    odbc.defaultbinmode = 1
    [Interbase]
    ibase.allow_persistent = 1
    ibase.max_persistent = -1
    ibase.max_links = -1
    ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
    ibase.dateformat = "%Y-%m-%d"
    ibase.timeformat = "%H:%M:%S"
    [MySQLi]
    mysqli.max_persistent = -1
    mysqli.allow_persistent = On
    mysqli.max_links = -1
    mysqli.cache_size = 2000
    mysqli.default_port = 3306
    mysqli.default_socket =
    mysqli.default_host =
    mysqli.default_user =
    mysqli.default_pw =
    mysqli.reconnect = Off
    [mysqlnd]
    mysqlnd.collect_statistics = On
    mysqlnd.collect_memory_statistics = Off
    [OCI8]
    [PostgreSQL]
    pgsql.allow_persistent = On
    pgsql.auto_reset_persistent = Off
    pgsql.max_persistent = -1
    pgsql.max_links = -1
    pgsql.ignore_notice = 0
    pgsql.log_notice = 0
    [bcmath]
    bcmath.scale = 0
    [browscap]
    [Session]
    session.save_handler = files
    session.use_strict_mode = 0
    session.use_cookies = 1
    session.use_only_cookies = 1
    session.name = PHPSESSID
    session.auto_start = 0
    session.cookie_lifetime = 0
    session.cookie_path = /
    session.cookie_domain =
    session.cookie_httponly =
    session.serialize_handler = php
    session.gc_probability = 1
    session.gc_divisor = 1000
    session.gc_maxlifetime = 1440
    session.referer_check =
    session.cache_limiter = nocache
    session.cache_expire = 180
    session.use_trans_sid = 0
    session.sid_length = 26
    session.trans_sid_tags = "a=href,area=href,frame=src,form="
    session.sid_bits_per_character = 5
    [Assertion]
    zend.assertions = -1
    [COM]
    [mbstring]
    [gd]
    [exif]
    [Tidy]
    tidy.clean_output = Off
    [soap]
    soap.wsdl_cache_enabled=1
    soap.wsdl_cache_dir="/tmp"
    soap.wsdl_cache_ttl=86400
    soap.wsdl_cache_limit = 5
    [sysvshm]
    [ldap]
    ldap.max_links = -1
    [dba]
    [opcache]
    [curl]
    [openssl]
    [pthreads]
    extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pthreads.so
    [xdebug]
    zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=172.20.10.2
    xdebug.remote_port=9000
    xdebug.idekey="PHPSTORM"
      c. 添加环境变量:

    echo  'export  PATH=$PATH:/usr/local/php/bin/'  >>  /etc/profile
    .  /etc/profile




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-672756-1-1.html 上篇帖子: centos6.6 vim自动补全python代码 下篇帖子: centos7安装 git
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表