• Linux(CentOS7)搭建LAMP服务环境


    1、MySQL高版本5.7及以上安装在CentOS7x64位系统,安装过程在以往笔记里找,这里不再赘述;

    2、安装Apache-Httpd,下载地址:http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.23.tar.gz

    在编译安装Apache(httpd-2.4.3)时分别出现了apr not found、APR-util not found、pcre-config for libpcre not found的问题,下面就httpd-2.4.3的这些问题解决来实际操作一把。

    http://apr.apache.org/download.cgi 下载apr-1.4.5.tar.gz、apr-util-1.3.12.tar.gz

    https://sourceforge.net/projects/pcre/files 下载pcre-8.31.zip 或者 pcre2-10.22.tar.gz

    1.解决apr not found问题

    [root@localhost bin]# tar -zxf apr-1.5.2.tar.gz
    
    [root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
    
    [root@localhost apr-1.5.2]# make && make install
    
    [root@localhost apr-1.5.2]# make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    2.解决APR-util not found问题

    [root@localhost bin]# tar -zxf apr-util-1.5.4.tar.gz
    
    [root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/
    
    [root@localhost apr-util-1.5.4]# make && make install
    
    [root@localhost apr-util-1.5.4]# make install
    
    在安装apr-util时,缺少/opt/apr-util-1.5.4/xml/expat/libexpat.la文件 
    
    在当前目录 执行命令:yum search libexpat 即可解决;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    3、解决pcre-config for libpcre not found问题

    [root@localhost ~]# unzip pcre-8.10.zip 
    
    [root@localhost ~]# cd pcre-8.10 
    
    [root@localhost pcre-8.10]# ./configure --prefix=/usr/local/pcre 
    
    [root@localhost pcre-8.10]# make && make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    先将支持Apache-httpd的几个程序安装完,之后在安装Apache【反正安装没坏处】

    解压Apache:tar -zxvf Apache-httpd-2.4.24.tar.gz

    md5sum httpd-2.4.23.tar.gz
    
    tar zvxf httpd-2.4.23.tar.gz 
    
    ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-modules=all --enable-rewrite  --enable-ssl --with-ssl --enable-cgid --enable-cgi
    
    apr是为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    2.4.23Apche之后的编译版本命令有所不同:

    (除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)make && make install

    因为httpd默认端口:80,已经给tomcat使用了,所以要去安装目录/usr/local/apache/conf/httpd.conf
    
    vim它,修改它的listener:80,变成8082
    
    启动:/usr/local/apache/bin/apachectl start 报错:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. 
    
    Set the 'ServerName' directive globally to suppress this message
    
    vim httpd.conf 配置文件,增加一行:ServerName  localhost[先配置虚拟机ip]:8081
    
    防火墙开启端口8081,windows可远程访问apachehttpd服务
    
    iptables -I INPUT -p tcp --dport 80 -j ACCEPT
    
    CentOS7防火墙设置:firewall-cmd --zone=public --add-port=8082/tcp --permanent
    
      防火墙重启: firewall-cmd --reload
    
    •停止Apache:/usr/local/apache/bin/apachectl stop
    
    •重启Apache:/usr/local/apache/bin/apachectl restart
    
    cp /usr/local/apache/bin/apachectl /etc/init.d/httpd #复制服务到服务列表
    
    如果复制没有权限,使用软链接:ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd
    
    service httpd start / stop restart 启动httpd
    
    chmod 755 /etc/init.d/httpd  
    
    chkconfig --add httpd 报错:service httpd does not support chkconfig
    
    解决办法:打开vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面) 
    
    #description: Activates/Deactivates Apache Web Server
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35

    3、安装PHP(下载php-5.5-.38.tar.gz)

    • 因为httpd默认端口:80,已经给tomcat使用了,所以要去安装目录/usr/local/apache/conf/httpd.conf
      
      vim它,修改它的listener:80,变成8082
      
      启动:/usr/local/apache/bin/apachectl start 报错:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. 
      
      Set the 'ServerName' directive globally to suppress this message
      
      vim httpd.conf 配置文件,增加一行:ServerName  localhost[先配置虚拟机ip]:8081
      
      防火墙开启端口8081,windows可远程访问apachehttpd服务
      
      iptables -I INPUT -p tcp --dport 80 -j ACCEPT
      
      CentOS7防火墙设置:firewall-cmd --zone=public --add-port=8082/tcp --permanent
      
        防火墙重启: firewall-cmd --reload
      
      •停止Apache:/usr/local/apache/bin/apachectl stop
      
      •重启Apache:/usr/local/apache/bin/apachectl restart
      
      cp /usr/local/apache/bin/apachectl /etc/init.d/httpd #复制服务到服务列表
      
      如果复制没有权限,使用软链接:ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd
      
      service httpd start / stop restart 启动httpd
      
      chmod 755 /etc/init.d/httpd  
      
      chkconfig --add httpd 报错:service httpd does not support chkconfig
      
      解决办法:打开vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面) 
      
      #description: Activates/Deactivates Apache Web Server
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35

      make: *** [sapi/cli/PHP] 错误 1

    #make clean  
    
    #make
    
    <?php>
    
    phpinfo();
    
    <?>
    
    浏览器打开测试test.php,环境不能解析php代码,访问出现源代码;
    
    修改vim /usr/local/apache/conf/httpd/conf
    
    找到AddType内容
    
    #添加[MIME映射](https://www.baidu.com/s?wd=MIME%E6%98%A0%E5%B0%84&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdmHc4rH6LuWfdPAFbnhnv0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3En1RLnHf1PHcY),让apache把PHP文件当成代码文件来执行
    
    AddType application/x-httpd-php .php .phtml
    
    重启apache--httpd服务就好了
    
    \[so:warn\] \[pid 3020:tid 139963331409728\] AH01574: module php5\_module is already loaded, skipping
    
    apache重装php环境,重复加载php5\_module模块,编辑apache/conf/httpd.conf 删除即可;
    
    (20014)Internal error (specific information not available): AH00058: Error retrieving pid file logs/httpd.pid
    
    要删除apache/logs/httpd.pid这个进程文件;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
  • 相关阅读:
    性能优化究竟应该怎么做
    ES6展开运算符—— 通俗易懂
    uniapp基础学习笔记01
    观察者模式的运用——消息队列
    ZYNQ之HLS学习----开篇实验
    rhcsa(rh134)
    ESP32蓝牙实例-ESP32之间通过蓝牙串口主从机通信
    Ubuntu下安装node.js遇到的问题记录
    Docker极简入门:使用Docker-Compose 运行网站浏览量统计Demo
    Power BI 傻瓜入门 6. 从动态数据源获取数据
  • 原文地址:https://blog.csdn.net/u011466469/article/details/119888644