1、需求以及环境准备
1.1、版本需求
| SERVICE | VERSION |
| Linux |
CentOS 7.6 |
| Apache |
2.4.37 |
| Mysql |
5.7.25 |
| Php |
7.1.33 |
| Openssl |
1.1.1i |
| Curl |
7.74.0 |
- LAMP=Linux+Apache+Mysql+Php
- LNMP=Linux+Nginx+Mysql+Php
- LNMT=Linux+Nginx+Mysql+Tomcat
1.2、环境准备
"内网服务器,没有要求的话,直接把firewalld关了"
[root@localhost ~]
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]
SELinux status: disabled
[root@localhost ~]
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
"主机名看需求修改,不是强制项"
[root@localhost ~]
1.3、安装包准备
[root@LAMP-Server ~]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
[root@LAMP-Server src]
"都是国外服务器,下载都比较慢,已经打包上传到百度云,担心有问题的,可以自己wget下载,或者使用迅雷下载"
链接:https://pan.baidu.com/s/1i_LZzXnRQsFEbgx8jrA9KA
提取码:d4pj
2、编译升级Openssl
"下载编译所需环境"
[root@LAMP-Server src]
2.1、查看当前Openssl版本
[root@LAMP-Server src]
OpenSSL 1.0.2k-fips 26 Jan 2017
2.2、备份当前版本Openssl文件
[root@LAMP-Server src]
2.3、编译新版本Openssl
[root@LAMP-Server src]
[root@LAMP-Server openssl-1.1.1i]
2.3、生成新版本Openssl
[root@LAMP-Server openssl-1.1.1i]
[root@LAMP-Server openssl-1.1.1i]
[root@LAMP-Server openssl-1.1.1i]
[root@LAMP-Server openssl-1.1.1i]
OpenSSL 1.1.1i 8 Dec 2020
3、编译部署Apache
"Apache编译安装依赖apr、apr-util、pcre"
"使用 ./configure --help 命令可以查看相关的模块,有需要的模块,可以在编译的时候加入"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server apr-1.4.5]
make && \
make install
--------------------------------------------------------------------------------------------------------------
[root@LAMP-Server ~]
[root@LAMP-Server apr-util-1.4.1]
--with-apr=/usr/local/httpd-2.4.37/apr-1.4.5 && \
make && \
make install
--------------------------------------------------------------------------------------------------------------
[root@LAMP-Server ~]
[root@LAMP-Server pcre-8.10]
make && \
make install
--------------------------------------------------------------------------------------------------------------
[root@LAMP-Server ~]
[root@LAMP-Server httpd-2.4.37]
--with-apr=/usr/local/httpd-2.4.37/apr-1.4.5 \
--with-apr-util=/usr/local/httpd-2.4.37/apr-util-1.4.1 \
--with-pcre=/usr/local/httpd-2.4.37/pcre-8.10 && \
make && \
make install
3.1、启动Apache
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server httpd-2.4.37]
<html><body><h1>It works!</h1></body></html>
"可以访问到apache服务默认的内容了"
4、编译部署Mysql
"安装编译所需的环境依赖"
[root@LAMP-Server ~]
"创建mysql普通用户,禁止登陆bash"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server mysql-5.7.25]
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/src/mysql-5.7.25/boost/boost_1_59_0 \
-DWITH_SYSTEMD=1 && \
make && \
make install
- 如果在cmake的过程中有报错,当报错解决后,需要把源码目录中的CMakeCache.txt文件删除,然后再重新cmake,否则依旧报错
4.1、修改mysql配置文件
"因为使用的是mysql普通用户,所以需要修改mysql目录的用户权限"
[root@LAMP-Server mysql-5.7.25]
"修改mysql配置文件"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
port=3306
character_set_server=utf8
lower_case_table_names=1
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
!includedir /etc/my.cnf.d
4.2、mysql数据库初始化
"添加mysql命令到PATH环境变量"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
"数据库初始化"
[root@LAMP-Server ~]
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
"数据库初始化后,密码为空"
2021-01-22T17:15:19.994597Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
4.3、启动mysql数据库
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
4.4、修改数据库密码
[root@LAMP-Server ~]
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@LAMP-Server ~]
Enter password:
5、编译部署php
"安装编译所需的依赖"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server php-7.1.33]
[root@LAMP-Server php-7.1.33]
[root@LAMP-Server php-7.1.33]
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--bindir=/usr/local/php/bin \
--sbindir=/usr/local/php/sbin \
--includedir=/usr/local/php/include \
--libdir=/usr/local/php/lib/php \
--mandir=/usr/local/php/php/man \
--with-config-file-path=/usr/local/php/etc \
--with-mysql-sock=/tmp/mysql.sock \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-fpm \
--with-fpm-user=http \
--with-fpm-group=http \
--without-gdbm \
--enable-fast-install \
--disable-fileinfo \
--with-php-config=/usr/local/bin/php-config \
--with-pdo-mysql=mysqlnd && \
make && \
make install
[root@LAMP-Server php-7.1.33]
[root@LAMP-Server php-7.1.33]
[root@LAMP-Server php-7.1.33]
PHP 7.1.33 (cli) (built: Jan 23 2021 01:59:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
5.1、配置php.ini以及php-fpm
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
6、编译部署Curl
"Curl当前版本"
[root@LAMP-Server ~]
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
"备份当前版本的Curl"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
./configure \
--prefix=/usr/local/curl-7.74.0 \
--without-nss \
--with-ssl=/usr/local/openssl-1.1.1i && \
make && \
make install
- –without-nss是因为centos自带的curl支持的https是nss版本的,不是openssl的,我们这里要用openssl版本的
- –with-ssl后面跟的openssl安装目录
- 直接./configure,默认是不支持https协议的
"更新curl"
[root@LAMP-Server ~]
[root@LAMP-Server ~]
[root@LAMP-Server ~]
curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1i zlib/1.2.7
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets