• 编译配置LAMP


    编译安装Apache

    1、安装一些apache的依赖包

    yum install -y gcc gcc-c++ autoconf libtool

    2、安装apr

    (1) cd /usr/local/src/
    (2) wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
    (3) tar zxvf apr-1.5.0.tar.gz
    (4) cd apr-1.5.0
    (5) ./configure --prefix=/usr/local/apr
    (6) make && make install

    3、安装apr-util

    (1) cd /usr/local/src/
    (2) wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz
    (3) tar zxvf apr-util-1.5.3.tar.gz
    (4) cd apr-util-1.5.3
    (5) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    (6) make && make install

    4、安装pcre

    (1) cd /usr/local/src/
    (2) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gz
    (3) tar zxvf pcre-8.38.tar.gz
    (4) cd pcre-8.38
    (5) ./configure --prefix=/usr/local/pcre
    (6) make && make install

    5、安装apache

    (1) make && make install
    (2) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gz
    (3) tar zxvf httpd-2.4.23.tar.gz
    (4) cd httpd-2.4.23
    (5) ./configure 
    --prefix=/usr/local/apache --sysconfdir=/etc/httpd 
    --enable-so --enable-cgi --enable-rewrite 
    --with-zlib --with-pcre=/usr/local/pcre 
    --with-apr=/usr/local/apr 
    --with-apr-util=/usr/local/apr-util 
    --enable-mods-shared=most --enable-mpms-shared=all 
    --with-mpm=event
    (6) make && make install

    6、修改httpd.conf配置文件

    (1) cd /etc/httpd/
    (2) vim httpd.conf
        a  找到Directory参数,注释掉Require all denied添加Require all granted。
        b  找到ServerName参数,添加ServerName localhost:80 然后,按Esc键后输入:wq保存退出。
        c  在配置文件中添加  PidFile "/var/run/httpd.pid"

    7、启动Apache服务

    (1) cd /usr/local/apache/bin/
    (2) ./apachectl start
    (3) netstat -tnlp

    8、设置开机自启

    在/etc/rc.d/rc.local文件中添加apache启动命令
    (1) vim /etc/rc.d/rc.local 将/usr/local/apache/bin/apachectl start 写入文件
    (2) 设置环境变量
        a  vim /root/.bash_profile  将 PATH=$PATH:$HOME/bin:/usr/local/apache/bin 写入
        b  source /root/.bash_profile

    编译安装MySQL

    1、检查系统中是否有MySQL,若有先删除在安装

    (1) rpm -qa | grep mysql
    (2) rpm -qa | grep mariadb
    (3) rpm -e xxx  #卸载
    (4) rpm -e --nodeps xxx  #强制卸载

    2、安装MySQL

    (1) yum install -y libaio-*  #安装mysql所需要的依赖包
    (2) mkdir -p /usr/local/mysql
    (3) cd /usr/local/src
    (4) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
    (5) tar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
    (6) mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/

    3、建立mysql组和用户,并将mysql用户添加到mysql组中

    (1) groupadd mysql
    (2) useradd -g mysql -s /sbin/nologin mysql

    4、初始化

    /usr/local/mysql/bin/mysqld --initialize-insecure --datadir=/usr/local/mysql/data/ --user=mysql

    5、更改mysql安装目录的属组

    (1) chown -R mysql:mysql /usr/local/mysql
    (2) chown -R mysql:mysql /usr/local/mysql/data/
    (3) chown -R mysql:mysql /usr/local/mysql

    6、设置开机自启

    (1) cd /usr/local/mysql/support-files/
    (2) cp mysql.server /etc/init.d/mysqld
    (3) chmod +x /etc/init.d/mysqld
    (4) vim /etc/rc.d/rc.local 将/etc/init.d/mysqld start添加到rc.local文件

    7、设置环境变量

    (1) vim /root/.bash_profile   将PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib写入文件
    (2) source /root/.bash_profile

    8、启动mysql

    /etc/init.d/mysql start

    9、修改mysql的root用户密码

    mysqladmin -u root password '12345678'

    10、添加my.cnf文件

    cp /usr/local/mysql/support-files/my-default.cnf      /etc/my.cnf

    编译安装PHP

    编辑配置文件,是Apache支持PHP

    1、在httpd.conf中写入相应的配置

    (1) vim /etc/httpd/httpd.conf 在配置文件中添加下面配置
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
    (2) 将httpd.conf中的 DirectoryIndex index.html 改为 DirectoryIndex index.php index.html

    2、重启apache

    /usr/local/apache/bin/apachectl restart
  • 相关阅读:
    windos下安装多个mysql服务
    mysql 提示too many connections”的解决办法
    python打包成exe
    对于点击后需要等待一段时间才会有的元素的操作
    python自动化报错
    自动化测试中对不能输入的框体的处理
    对于下拉框的处理方法
    selenium自动化遇见Cannot find class in classpath问题
    企业如何留住人才
    如何成为一名优秀的前端工程师
  • 原文地址:https://www.cnblogs.com/Mr-Wenyan/p/9337335.html
Copyright © 2020-2023  润新知