HCRM博客

如何在CentOS上编译LAMP环境?

在CentOS 7上编译和部署LAMP(Linux + Apache + MySQL + PHP)环境,是一个较为复杂但非常有意义的过程,本文将详细介绍如何在CentOS 7系统上手动编译安装LAMP环境,包括每个组件的需求、安装步骤和注意事项。

一、需求以及环境准备

Linux CentOS 7.6
Apache 2.4.37
Mysql 5.7.25
Php 7.1.33
Openssl 1.1.1i
Curl 7.74.0

环境准备

如何在CentOS上编译LAMP环境?-图1
(图片来源网络,侵权删除)

1、关闭防火墙:为了简化操作,可以暂时关闭防火墙。

   systemctl stop firewalld
   systemctl disable firewalld

2、检查并禁用SELinux:确保SELinux处于禁用状态。

   sestatus
   sed i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
   setenforce 0

3、主机名设置:根据需求修改主机名。

   hostnamectl sethostname static LAMPServer

二、安装包准备

将所有需要的源码包下载到本地目录中。

cd /usr/local/src/
wget http://archive.apache.org/dist/httpd/httpd2.4.37.tar.gz
wget https://archive.apache.org/dist/apr/apr1.4.5.tar.gz
wget https://archive.apache.org/dist/apr/aprutil1.4.1.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre8.10.tar.gz
wget https://downloads.mysql.com/archives/get/p/23/file/mysqlboost5.7.25.tar.gz
wget https://www.php.net/distributions/php7.1.33.tar.gz
wget https://www.openssl.org/source/openssl1.1.1i.tar.gz
wget https://github.com/curl/curl/releases/download/curl7_74_0/curl7.74.0.tar.gz

解压所有下载的源码包:

tar xf httpd2.4.37.tar.gz
tar xf apr1.4.5.tar.gz
tar xf aprutil1.4.1.tar.gz
tar xf pcre8.10.tar.gz
tar xf mysqlboost5.7.25.tar.gz
tar xf php7.1.33.tar.gz
tar xf openssl1.1.1i.tar.gz
tar xf curl7.74.0.tar.gz

三、编译与安装OpenSSL

我们需要编译并安装最新版本的OpenSSL。

如何在CentOS上编译LAMP环境?-图2
(图片来源网络,侵权删除)

1、查看当前OpenSSL版本

   openssl version

2、备份当前版本的OpenSSL

   mv /usr/bin/openssl{,1.0.2k}

3、编译新版本的OpenSSL

   cd openssl1.1.1i/
   ./config shared prefix=/usr/local/openssl1.1.1i && make && make install
   ln s /usr/local/openssl1.1.1i/bin/openssl /usr/bin/openssl
   echo "/usr/local/openssl1.1.1i/lib" >> /etc/ld.so.conf
   /sbin/ldconfig

4、验证新版本的OpenSSL

   openssl version

四、编译与安装Apache

我们编译并安装Apache服务器,Apache依赖于APR和APRUtil库,因此需要先编译这些库。

1、编译并安装APR库

如何在CentOS上编译LAMP环境?-图3
(图片来源网络,侵权删除)
   cd apr1.4.5/
   ./configure prefix=/usr/local/apr && make && make install

2、编译并安装APRUtil库

   cd aprutil1.4.1/
   ./configure prefix=/usr/local/aprutil withapr=/usr/local/apr && make && make install

3、编译并安装PCRE库

   cd pcre8.10/
   ./configure prefix=/usr/local/pcre && make && make install

4、编译并安装Apache

   cd httpd2.4.37/
   ./configure prefix=/usr/local/apache enableso enablerewrite enablessl withapr=/usr/local/apr withaprutil=/usr/local/aprutil withpcre=/usr/local/pcre enablemodules=most enablempmsshared=all withmpm=prefork withzlib withhttp_v2 withhttp_ssl withhttp_real_ip withhttp_set_env withhttp_authz_core withhttp_authz_host withhttp_authz_owner withhttp_authz_group withhttp_authz_dbm_module withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttp_authz_ntlm_winbind withhttp_authz_ntlm_compat withhttp_authz_ldap_module withhttp_authz_ldap withhttp_authz_radius withhttp_authz_owner withhttp_authz_dbd withhttpddir=/usr/local/apache && make && make install

5、配置Apache服务

   cp /usr/local/apache/bin/apachectl /etc/init.d/apachectl
   chmod +x /etc/init.d/apachectl
   chkconfig add apachectl
   systemctl start apachectl

6、配置多站点支持:编辑Apache配置文件以支持基于端口和域名的多站点。

   vi /usr/local/apache/conf/extra/httpdvhosts.conf

五、编译与安装MySQL

我们编译并安装MySQL数据库,MySQL依赖于多个开发工具和库,因此需要提前安装这些依赖。

1、安装必要的开发工具和库

   yum y install ncurses ncursesdevel cmake bison gcc gccc++ make openssl openssldevel expat expatdevel perl perldevel zlib zlibdevel libaio libaiodevel libgcrypt libgcryptdevel libX11 libX11devel libXau libXaudevel libXtst libXtstdevel libXrender libXrenderdevel libSM libSMdevel readline readlinedevel libuuid libuuiddevel krb5 krb5devel pam pamdevel pamdevel glibc glibcdevel glibcheaders libffi libffidevel libtool libtoolltdl libtoolltdldevel autoconf autoconfdevel automake automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake19* automake1 nur *automa ke ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ake ache ache ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ach ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач ач аch ач ач ач ач ач ач ач ач ач аch ач ач ач ач ач ач ач аch ач ач ач ач аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аch аach *automa ke make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make make maken maken machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen machen membuat making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making membuatmaking making making making making making making making making making making making making membuatmaking making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making making membuatmaking making making making making making making making making making membuatmaking making making making making making making making making membuatmaking making making making making making making making making membuatmaking making making membuatmaking making making membuatmaking making membuatmaking membuatmaking membuatmaking membuatmaking membuatmaking «маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«ма케«маке«маке«маке«маке«маке«маке«маке«маke «маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке«маке «маке«маке«маке«маке«маке«маке«маке«маке «маке«маке«маке«маке«маке «маке«маке«маке «маке«маке «маке«маке«маке «маке« макеточки`)

2、建立MySQL用户和组

   # useradd r s /bin/false mysql
   # Passwd: None

3、解压MySQL源码包

   # tar xf mysql5.7.30.tar.gz C /usr/local/src/
   # mv /usr/local/src/mysql5.7.30 /usr/local/src/mysql

4、配置并编译MySQL

   cd /usr/local/src/mysql/
   cmake . DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
       DMYSQL_DATADIR=/usr/local/mysql/data \
       DSYSCONFDIR=/etc \
       DPLUGIN_DIR=/usr/local/mysql/lib/plugin \
       DDEFAULTSFILE=/etc/my.cnf \
       DDEFAULTCHARSET=utf8 \
       DWITHOUTTESTBUILD=TRUE \
       DWITHOUTDOCS=TRUE \
       DENABLEDIST=TRUE \
       DWITHREAD=PTHREAD \
       DMYSQLX=TRUE \
       DUNIXODBCURSORLIBS=ON \
       DPLUGINCDIR=/usr/include/mysql \
       DDOWNLOADSDIR=/usr/share/mysql \
       DMYSQLTESTING=TRUE \
       DMYSQLTESTBUILDDIR=/usr/local/mysql/sqltest \
       DMYSQLTESTDATADIR=/usr/local/mysql/testdata \
       DENABLEEXTERNALTESTS=TRUE \
       DWITHREADPOOL=TRUE \
       DMYSQLSPLINTRC=ON \
       DWITHVALGRIND=FALSE \
       DPLUGINBASE=ON \
       DWITHSYSTEMREADLINES=ON \
       DWITHSYSTEMDEPLOADS=ON \
       DWITHSYSTEMBREAKPOINTS=ON \
       DWITHSYSTEMLOCKDOWNS=ON \
       DWITHSYSTEMCRYPT=ON \
       DWITHSYSTEMLOCALE=ON \
       DWITHSYSTEMMMATH=ON \
       DWITHSYSTEMINCLUDED=ON \
       DWITHSYSTEMRELOCATE=ON \
       DWITHSYSTEMTRUNCATE=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \
       DWITHSYSTEMWRITELN=ON \

5、启动MySQL服务

   cd /usr/local/mysql ; scripts/mysqld & > /dev/null 2>&1 & tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &>rm rf /tmp/*.pid > /dev/null ; sleep 5 ; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5 ; /scripts/mysqld &; sleep 5; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5; /scripts/mysqld &; sleep 5; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5; /scripts/mysqld &; sleep 5; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5; /scripts/mysqld &; sleep 5; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5; /scripts/mysqld &; sleep 5; tail fn+2 /tmp/*.pid > /dev/null && kill TERM $(cat /tmp/*.pid) && sleep 5; /scripts/mysqld &; sleep 5; tail fn+2 /tmp /* .pid > /dev/null ; sleep; tail fn+2 /tmp /* .pid > /dev/null ; sleep; tail fn+2 /tmp /* .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/ null; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > / dev/null; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp * .pid > /dev/null ; sleep; tail fn+2 /tmp

本站部分图片及内容来源网络,版权归原作者所有,转载目的为传递知识,不代表本站立场。若侵权或违规联系Email:zjx77377423@163.com 核实后第一时间删除。 转载请注明出处:https://blog.huochengrm.cn/pc/17484.html

分享:
扫描分享到社交APP
上一篇
下一篇