源代码编译安装lamp
源代码编译安装lamp
关闭防火墙与selinux
[root@syf ~]# systemctl stop firewalld
[root@syf ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@syf ~]# vim /etc/selinux/config # This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted~
~
重启:
[root@syf ~]# reboot
配置yum网络源(阿里源镜像站中CentOS 7镜像):
[root@syf ~]# cd /etc/yum.repos.d/
[root@syf yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@syf yum.repos.d]# rm -rf *
[root@syf yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-19 10:55:11-- https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 116.207.134.100, 116.207.134.101, 116.207.134.94
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|116.207.134.100|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’100%[==========================>] 2,523 --.-K/s in 0s 2025-08-19 10:55:11 (19.8 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523][root@syf yum.repos.d]# yum -y install epel-release
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/4): extras/7/x86_64/primary_db | 253 kB 00:00
(2/4): base/7/x86_64/group_gz | 153 kB 00:00
(3/4): updates/7/x86_64/primary_db | 27 MB 00:01
base/7/x86_64/primary_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(4/4): base/7/x86_64/primary_db | 6.1 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency ResolutionDependencies Resolved====================================================================Package Arch Version Repository Size
====================================================================
Installing:epel-release noarch 7-11 extras 15 kTransaction Summary
====================================================================
Install 1 PackageTotal download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed:epel-release.noarch 0:7-11 Complete!
准备编译环境:
部署lamp-apache(安装需要的工具包):
[root@syf ~]# yum -y install bzip2 vim make wget openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ libxml2-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 4.4 kB 00:00 * base: mirrors.aliyun.com* epel: ftp-stud.hs-esslingen.de* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
epel | 4.3 kB 00:00
(1/3): epel/x86_64/group | 399 kB 00:03
(2/3): epel/x86_64/updateinfo | 1.0 MB 00:26
(3/3): epel/x86_64/primary_db | 8.7 MB 06:08
Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
.....
[root@syf ~]# ls
anaconda-ks.cfg Downloads Pictures Videos
Desktop initial-setup-ks.cfg Public
Documents Music Templates
[root@syf ~]# rz -E
rz waiting to receive.
[root@syf ~]# rz -E
rz waiting to receive.
[root@syf ~]# rz -E
rz waiting to receive.
[root@syf ~]# rz -E
rz waiting to receive.
[root@syf ~]# rz -E
rz waiting to receive.
[root@syf ~]# ls
anaconda-ks.cfg Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54.tar.gz Videos
initial-setup-ks.cfg
[root@syf ~]# tar -xzvf apr-1.7.0.tar.gz
apr-1.7.0/
apr-1.7.0/emacs-mode
apr-1.7.0/passwd/
apr-1.7.0/passwd/apr_getpass.c
apr-1.7.0/Makefile.win
apr-1.7.0/CMakeLists.txt
apr-1.7.0/poll/
apr-1.7.0/poll/os2/
apr-1.7.0/poll/os2/pollset.c
apr-1.7.0/poll/os2/poll.c
apr-1.7.0/poll/unix/
.....
[root@syf ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg
apr-1.7.0 Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54.tar.gz Videos
[root@syf ~]# cd apr-1.7.0/
[root@syf apr-1.7.0]# ls
apr-config.in CMakeLists.txt libapr.mak poll
apr.dep config.layout libapr.rc random
apr.dsp configure LICENSE README
apr.dsw configure.in locks README.cmake
apr.mak docs Makefile.in shmem
apr.pc.in dso Makefile.win strings
apr.spec emacs-mode memory support
atomic encoding misc tables
build file_io mmap test
buildconf helpers network_io threadproc
build.conf include NOTICE time
build-outputs.mk libapr.dep NWGNUmakefile tools
CHANGES libapr.dsp passwd user
[root@syf apr-1.7.0]# sed -i '/$RM "$cfgfile"/d' configure
[root@syf apr-1.7.0]# vim configure
... ficfgfile=${ofile}Ttrap "$RM \"$cfgfile\"; exit 1" 1 2 15//已删除cat <<_LT_EOF >> "$cfgfile"
...
配置 ./configure:
[root@syf apr-1.7.0]# ls
apr-config.in CMakeLists.txt libapr.mak poll
apr.dep config.layout libapr.rc random
apr.dsp configure LICENSE README
apr.dsw configure.in locks README.cmake
apr.mak docs Makefile.in shmem
apr.pc.in dso Makefile.win strings
apr.spec emacs-mode memory support
atomic encoding misc tables
build file_io mmap test
buildconf helpers network_io threadproc
build.conf include NOTICE time
build-outputs.mk libapr.dep NWGNUmakefile tools
CHANGES libapr.dsp passwd user
[root@syf apr-1.7.0]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
......
编译make:
[root@syf apr-1.7.0]# make
make[1]: Entering directory `/root/apr-1.7.0'
/bin/sh /root/apr-1.7.0/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/root/apr-1.7.0/include/arch/unix -I/root/apr-1.7.0/include -I/root/apr-1.7.0/include/private -I/root/apr-1.7.0/include/private -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
.....
编译安装 make install:
[root@syf apr-1.7.0]# make install
make[1]: Entering directory `/root/apr-1.7.0'
make[1]: Nothing to be done for `local-all'.
make[1]: Leaving directory `/root/apr-1.7.0'
/root/apr-1.7.0/build/mkdir.sh /usr/local/apr/lib /usr/local/apr/bin /usr/local/apr/build-1 \/usr/local/apr/lib/pkgconfig /usr/local/apr/include/apr-1
/usr/bin/install -c -m 644 /root/apr-1.7.0/include/apr.h /usr/local/apr/include/apr-1
......
[root@syf ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg
apr-1.7.0 Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54.tar.gz Videos
[root@syf ~]# tar -zxvf apr-util-1.6.1.tar.gz
apr-util-1.6.1/
apr-util-1.6.1/strmatch/
apr-util-1.6.1/strmatch/apr_strmatch.c
apr-util-1.6.1/uri/
apr-util-1.6.1/uri/apr_uri.c
apr-util-1.6.1/apr-util.spec
apr-util-1.6.1/README.FREETDS
apr-util-1.6.1/ldap/
apr-util-1.6.1/ldap/NWGNUmakefile
apr-util-1.6.1/ldap/apr_ldap_init.c
apr-util-1.6.1/ldap/apr_ldap_url.c
apr-util-1.6.1/ldap/apr_ldap.dsp
......
[root@syf ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg
apr-1.7.0 Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1 php-7.1.10.tar.bz2
apr-util-1.6.1.tar.gz Pictures
Desktop Public
Documents Templates
Downloads Videos
httpd-2.4.54.tar.gz
[root@syf ~]# cd apr-util-1.6.1
[root@syf apr-util-1.6.1]# ls
aprutil.dep configure.in Makefile.win
aprutil.dsp crypto memcache
aprutil.dsw dbd misc
aprutil.mak dbm NOTICE
apr-util.pc.in docs NWGNUmakefile
apr-util.spec encoding README
apu-config.in export_vars.sh.in README.cmake
buckets hooks README.FREETDS
build include redis
buildconf ldap renames_pending
build.conf libaprutil.dep strmatch
build-outputs.mk libaprutil.dsp test
CHANGES libaprutil.mak uri
CMakeLists.txt libaprutil.rc xlate
config.layout LICENSE xml
configure Makefile.in
[root@syf apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.6.1
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.
......
配置后,编译make:
[root@syf apr-util-1.6.1]# make
make[1]: Entering directory `/root/apr-util-1.6.1'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.1/include -I/root/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o buckets/apr_brigade.lo -c buckets/apr_brigade.c && touch buckets/apr_brigade.lo
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.1/include -I/root/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o buckets/apr_buckets.lo -c buckets/apr_buckets.c && touch buckets/apr_buckets.lo
......
编译安装 make install:
[root@syf apr-util-1.6.1]# make install
make[1]: Entering directory `/root/apr-util-1.6.1'
make[1]: Nothing to be done for `local-all'.
make[1]: Leaving directory `/root/apr-util-1.6.1'
/usr/local/apr/build-1/mkdir.sh /usr/local/apr-util/include/apr-1 /usr/local/apr-util/lib/pkgconfig \/usr/local/apr-util/lib /usr/local/apr-util/bin
for f in /root/apr-util-1.6.1/include/*.h /root/apr-util-1.6.1/include/*.h; do \/usr/bin/install -c -m 644 ${f} /usr/local/apr-util/include/apr-1; \
done
......
两个依赖包安装完成
解压并安装httpd:
[root@syf ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg
apr-1.7.0 Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1 php-7.1.10.tar.bz2
apr-util-1.6.1.tar.gz Pictures
Desktop Public
Documents Templates
Downloads Videos
httpd-2.4.54.tar.gz
[root@syf ~]# tar -xzvf httpd-2.4.54.tar.gz
httpd-2.4.54/
httpd-2.4.54/acinclude.m4
httpd-2.4.54/README.cmake
httpd-2.4.54/INSTALL
httpd-2.4.54/CMakeLists.txt
httpd-2.4.54/LICENSE
httpd-2.4.54/test/
httpd-2.4.54/BuildBin.dsp
httpd-2.4.54/configure
httpd-2.4.54/ROADMAP
httpd-2.4.54/CHANGES
httpd-2.4.54/LAYOUT
httpd-2.4.54/include/
......
[root@syf ~]# ls
anaconda-ks.cfg httpd-2.4.54.tar.gz
apr-1.7.0 initial-setup-ks.cfg
apr-1.7.0.tar.gz Music
apr-util-1.6.1 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54 Videos
[root@syf ~]# cd httpd-2.4.54/
[root@syf httpd-2.4.54]# ls
ABOUT_APACHE CMakeLists.txt InstallBin.dsp README
acinclude.m4 config.layout LAYOUT README.CHANGES
Apache-apr2.dsw configure libhttpd.dep README.cmake
Apache.dsw configure.in libhttpd.dsp README.platforms
apache_probes.d docs libhttpd.mak ROADMAP
ap.d emacs-style LICENSE server
build httpd.dep Makefile.in srclib
BuildAll.dsp httpd.dsp Makefile.win support
BuildBin.dsp httpd.mak modules test
buildconf httpd.spec NOTICE VERSIONING
CHANGES include NWGNUmakefile
changes-entries INSTALL os
[root@syf httpd-2.4.54]# ./configure --prefix=/use/local/apache \
> --sysconfdir=/etc/httpd24 \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
......
配置后,编译make:
[root@syf httpd-2.4.54]# make
Making all in srclib
make[1]: Entering directory `/root/httpd-2.4.54/srclib'
make[1]: Leaving directory `/root/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory `/root/httpd-2.4.54/os'
Making all in unix
make[2]: Entering directory `/root/httpd-2.4.54/os/unix'
make[3]: Entering directory `/root/httpd-2.4.54/os/unix'
......
编译安装 make install:
[root@syf httpd-2.4.54]# make install
......
[root@syf httpd-2.4.54]# cd /usr/local/apache/
[root@syf apache]# ls
bin cgi-bin htdocs include man modules
build error icons logs manual
[root@syf apache]# cd bin/
[root@syf bin]# ls
ab dbmmanage htcacheclean httpd
apachectl envvars htdbm httxt2dbm
apxs envvars-std htdigest logresolve
checkgid fcgistarter htpasswd rotatelogs
[root@syf bin]# cd
[root@syf ~]# /usr/local/apache/bin/apachectl start
测试网页:
网页位置:
[root@syf ~]# cd /usr/local/apache/
[root@syf apache]# ls
bin cgi-bin htdocs include man modules
build error icons logs manual
[root@syf apache]# cd htdocs/
[root@syf htdocs]# ls
index.html
[root@syf htdocs]# vim index.html
<html><body><h1>It works!</h1></body></html>
~
~
[root@syf htdocs]# cd /etc/httpd24/
[root@syf httpd24]# ls
extra httpd.conf magic mime.types original
配置mysql:
创建服务用户MySQL:
[root@syf ~]# id mysql
id: mysql: no such user
[root@syf ~]# useradd -r -M -s /sbin/nologin mysql
[root@syf ~]# id mysql
uid=988(mysql) gid=982(mysql) groups=982(mysql)
安装依赖包:
[root@syf ~]# yum -y install libncurses* //默认已安装
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: pubmirror1.math.uh.edu* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Package ncurses-libs-5.9-14.20130511.el7_4.x86_64 already installed and latest version
Nothing to do
解压mysql:
[root@syf ~]# ls
anaconda-ks.cfg httpd-2.4.54.tar.gz
apr-1.7.0 initial-setup-ks.cfg
apr-1.7.0.tar.gz Music
apr-util-1.6.1 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54 Videos
[root@syf ~]# tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mysql-5.7.37-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.37-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.37-linux-glibc2.12-x86_64/bin/myisamlog
mysql-5.7.37-linux-glibc2.12-x86_64/bin/myisampack
mysql-5.7.37-linux-glibc2.12-x86_64/bin/mysql
......
[root@syf ~]# cd /usr/local/
[root@syf local]# ls
apache etc lib64 share
apr games libexec src
apr-util include mysql-5.7.37-linux-glibc2.12-x86_64
bin lib sbin
[root@syf local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
‘mysql’ -> ‘mysql-5.7.37-linux-glibc2.12-x86_64/’
[root@syf local]# ll
total 0
drwxr-xr-x 13 root root 152 Aug 19 15:17 apache
drwxr-xr-x 6 root root 58 Aug 19 11:39 apr
drwxr-xr-x 5 root root 43 Aug 19 11:51 apr-util
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
lrwxrwxrwx 1 root root 36 Aug 19 15:40 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 Aug 19 15:37 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Jul 23 11:29 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
[root@syf local]# ls
apache etc lib64 sbin
apr games libexec share
apr-util include mysql src
bin lib mysql-5.7.37-linux-glibc2.12-x86_64
[root@syf local]# chown -R mysql.mysql mysql
[root@syf local]# ll
total 0
drwxr-xr-x 13 root root 152 Aug 19 15:17 apache
drwxr-xr-x 6 root root 58 Aug 19 11:39 apr
drwxr-xr-x 5 root root 43 Aug 19 11:51 apr-util
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
lrwxrwxrwx 1 mysql mysql 36 Aug 19 15:40 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 Aug 19 15:37 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Jul 23 11:29 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
[root@syf local]# mkdir /opt/data
[root@syf local]# chown -R mysql.mysql /opt/data
[root@syf local]# yum -y install libaio //默认已安装
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: ftp-stud.hs-esslingen.de* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
Nothing to do
初始化数据库:
[root@syf local]# ls
apache etc lib64 sbin
apr games libexec share
apr-util include mysql src
bin lib mysql-5.7.37-linux-glibc2.12-x86_64
[root@syf local]# cd mysql
[root@syf mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@syf mysql]# cd bin/
[root@syf bin]# ls
innochecksum mysqldumpslow
lz4_decompress mysql_embedded
myisamchk mysqlimport
myisam_ftdump mysql_install_db
myisamlog mysql_plugin
myisampack mysqlpump
my_print_defaults mysql_secure_installation
mysql mysqlshow
mysqladmin mysqlslap
mysqlbinlog mysql_ssl_rsa_setup
mysqlcheck mysqltest_embedded
mysql_client_test_embedded mysql_tzinfo_to_sql
mysql_config mysql_upgrade
mysql_config_editor mysqlxtest
mysqld perror
mysqld-debug replace
mysqld_multi resolveip
mysqld_safe resolve_stack_dump
mysqldump zlib_decompress
[root@syf bin]# cd
[root@syf ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data
2025-08-19T07:52:57.115695Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2025-08-19T07:52:57.537909Z 0 [Warning] InnoDB: New log files created, LSN=45790
2025-08-19T07:52:57.613300Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2025-08-19T07:52:57.714059Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 856f04ea-7cd1-11f0-a35c-000c29e4651e.
2025-08-19T07:52:57.716085Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2025-08-19T07:52:58.818293Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2025-08-19T07:52:58.818331Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2025-08-19T07:52:58.822048Z 0 [Warning] CA certificate ca.pem is self signed.
2025-08-19T07:52:59.072575Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@syf ~]# cd /usr/local/mysql
[root@syf mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@syf mysql]# cd ..
[root@syf local]# ls
apache etc lib64 sbin
apr games libexec share
apr-util include mysql src
bin lib mysql-5.7.37-linux-glibc2.12-x86_64
[root@syf local]# cd
[root@syf ~]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
‘/usr/local/include/mysql’ -> ‘/usr/local/mysql/include/’
[root@syf ~]# vim /etc/ld.so.conf/mysql.conf
[root@syf ~]# cd /usr/local/mysql
[root@syf mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@syf mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@syf mysql]# ldconfig
修改mysql配置文件:
[root@syf ~]# vim /etc/my.cnf //内容清空,写入下方配置
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
~
~
[root@syf ~]# cd /usr/local/mysql
[root@syf mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@syf mysql]# cd support-files/
[root@syf support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@syf support-files]# vim mysql.server
...
basedir=/usr/local/mysql
datadir=/opt/data
...
[root@syf support-files]# cd
[root@syf ~]# cd /usr/lib/systemd/system
[root@syf system]# ls
abrt-ccpp.service
abrtd.service
abrt-oops.service
abrt-pstoreoops.service
abrt-vmcore.service
abrt-xorg.service
accounts-daemon.service
alsa-restore.service
alsa-state.service
...
[root@syf system]# vim mysqld.service
[Unit]
Description=mysql server daemon
After=network.target[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP \$MAINPID[Install]
WantedBy=multi-user.target~
~
[root@syf system]# systemctl daemon-reload
[root@syf system]# systemctl enable --now mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@syf system]# systemctl status mysqld
● mysqld.service - mysql server daemonLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2025-08-19 16:32:54 CST; 28s agoProcess: 112508 ExecStart=/usr/local/mysql/support-files/mysql.server start (code=exited, status=0/SUCCESS)Main PID: 112521 (mysqld_safe)Tasks: 28CGroup: /system.slice/mysqld.service├─112521 /bin/sh /usr/local/mysql/bin/mysqld_safe --da...└─112701 /usr/local/mysql/bin/mysqld --basedir=/usr/lo...Aug 19 16:32:53 syf.example.com systemd[1]: Starting mysql server...
Aug 19 16:32:54 syf.example.com mysql.server[112508]: Starting My...
Aug 19 16:32:54 syf.example.com systemd[1]: Started mysql server ...
Hint: Some lines were ellipsized, use -l to show in full.
使用数据库:
[root@syf ~]# mysql -uroot -p
bash: mysql: command not found...
需要配置环境变量:
[root@syf ~]# vim /etc/profile
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH //最末尾写入
~
~
[root@syf ~]# source /etc/profile
[root@syf ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37 MySQL Community Server (GPL)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password=password('redhat');
Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> exit
Bye
[root@syf ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37 MySQL Community Server (GPL)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)mysql> exit
Bye
部署lamp-php:
安装依赖包,安装GD库和GD库关联程序,用来处理和生成图片:
[root@syf ~]# yum -y install libjpeg \
> libjpeg-devel \
> libpng libpng-devel \
> freetype freetype-devel \
> libxml2 \
> libxml2-devel \
> zlib zlib-devel \
> curl curl-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* epel: mirror.math.princeton.edu* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Package libxml2-2.9.1-6.el7_9.6.x86_64 already installed and latest version
Package libxml2-devel-2.9.1-6.el7_9.6.x86_64 already installed and latest version
Package zlib-1.2.7-21.el7_9.x86_64 already installed and latest version
Package zlib-devel-1.2.7-21.el7_9.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package curl.x86_64 0:7.29.0-51.el7 will be updated
---> Package curl.x86_64 0:7.29.0-59.el7_9.2 will be an update
--> Processing Dependency: libcurl = 7.29.0-59.el7_9.2 for package: curl-7.29.0-59.el7_9.2.x86_64
---> Package freetype.x86_64 0:2.8-12.el7 will be updated
---> Package freetype.x86_64 0:2.8-14.el7_9.1 will be an update
---> Package freetype-devel.x86_64 0:2.8-14.el7_9.1 will be installed
---> Package libcurl-devel.x86_64 0:7.29.0-59.el7_9.2 will be installed
base/7/x86_64/filelists_db | 7.2 MB 00:01
updates/7/x86_64/filelists_db | 15 MB 00:01
---> Package libjpeg-turbo.x86_64 0:1.2.90-6.el7 will be updated
---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be an update
---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-8.el7 will be installed
---> Package libpng.x86_64 2:1.5.13-7.el7_2 will be updated
---> Package libpng.x86_64 2:1.5.13-8.el7 will be an update
---> Package libpng-devel.x86_64 2:1.5.13-8.el7 will be installed
--> Running transaction check
---> Package libcurl.x86_64 0:7.29.0-51.el7 will be updated
---> Package libcurl.x86_64 0:7.29.0-59.el7_9.2 will be an update
--> Processing Dependency: libssh2(x86-64) >= 1.8.0 for package: libcurl-7.29.0-59.el7_9.2.x86_64
--> Running transaction check
---> Package libssh2.x86_64 0:1.4.3-12.el7 will be updated
---> Package libssh2.x86_64 0:1.8.0-4.el7_9.1 will be an update
--> Finished Dependency ResolutionDependencies Resolved====================================================================Package Arch Version RepositorySize
====================================================================
Installing:freetype-devel x86_64 2.8-14.el7_9.1 updates 447 klibcurl-devel x86_64 7.29.0-59.el7_9.2 updates 303 klibjpeg-turbo-devel x86_64 1.2.90-8.el7 base 99 klibpng-devel x86_64 2:1.5.13-8.el7 base 122 k
Updating:curl x86_64 7.29.0-59.el7_9.2 updates 271 kfreetype x86_64 2.8-14.el7_9.1 updates 380 klibjpeg-turbo x86_64 1.2.90-8.el7 base 135 klibpng x86_64 2:1.5.13-8.el7 base 213 k
Updating for dependencies:libcurl x86_64 7.29.0-59.el7_9.2 updates 223 klibssh2 x86_64 1.8.0-4.el7_9.1 updates 88 kTransaction Summary
====================================================================
Install 4 Packages
Upgrade 4 Packages (+2 Dependent packages)Total download size: 2.2 M
Downloading packages:
No Presto metadata available for base
No Presto metadata available for updates
(1/10): curl-7.29.0-59.el7_9.2.x86_64.rpm | 271 kB 00:00
(2/10): freetype-2.8-14.el7_9.1.x86_64.rpm | 380 kB 00:00
(3/10): freetype-devel-2.8-14.el7_9.1.x86_64.r | 447 kB 00:00
(4/10): libcurl-7.29.0-59.el7_9.2.x86_64.rpm | 223 kB 00:00
(5/10): libcurl-devel-7.29.0-59.el7_9.2.x86_64 | 303 kB 00:00
(6/10): libjpeg-turbo-1.2.90-8.el7.x86_64.rpm | 135 kB 00:00
(7/10): libpng-1.5.13-8.el7.x86_64.rpm | 213 kB 00:00
(8/10): libjpeg-turbo-devel-1.2.90-8.el7.x86_6 | 99 kB 00:00
(9/10): libpng-devel-1.5.13-8.el7.x86_64.rpm | 122 kB 00:00
(10/10): libssh2-1.8.0-4.el7_9.1.x86_64.rpm | 88 kB 00:00
--------------------------------------------------------------------
Total 3.1 MB/s | 2.2 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionUpdating : 2:libpng-1.5.13-8.el7.x86_64 1/16 Installing : 2:libpng-devel-1.5.13-8.el7.x86_64 2/16 Updating : freetype-2.8-14.el7_9.1.x86_64 3/16 Updating : libssh2-1.8.0-4.el7_9.1.x86_64 4/16 Updating : libcurl-7.29.0-59.el7_9.2.x86_64 5/16 Updating : libjpeg-turbo-1.2.90-8.el7.x86_64 6/16 Installing : libjpeg-turbo-devel-1.2.90-8.el7.x86_64 7/16 Installing : libcurl-devel-7.29.0-59.el7_9.2.x86_64 8/16 Updating : curl-7.29.0-59.el7_9.2.x86_64 9/16 Installing : freetype-devel-2.8-14.el7_9.1.x86_64 10/16 Cleanup : freetype-2.8-12.el7.x86_64 11/16 Cleanup : curl-7.29.0-51.el7.x86_64 12/16 Cleanup : libcurl-7.29.0-51.el7.x86_64 13/16 Cleanup : libssh2-1.4.3-12.el7.x86_64 14/16 Cleanup : 2:libpng-1.5.13-7.el7_2.x86_64 15/16 Cleanup : libjpeg-turbo-1.2.90-6.el7.x86_64 16/16 Verifying : libjpeg-turbo-1.2.90-8.el7.x86_64 1/16 Verifying : 2:libpng-devel-1.5.13-8.el7.x86_64 2/16 Verifying : libssh2-1.8.0-4.el7_9.1.x86_64 3/16 Verifying : libcurl-devel-7.29.0-59.el7_9.2.x86_64 4/16 Verifying : curl-7.29.0-59.el7_9.2.x86_64 5/16 Verifying : libjpeg-turbo-devel-1.2.90-8.el7.x86_64 6/16 Verifying : 2:libpng-1.5.13-8.el7.x86_64 7/16 Verifying : freetype-devel-2.8-14.el7_9.1.x86_64 8/16 Verifying : freetype-2.8-14.el7_9.1.x86_64 9/16 Verifying : libcurl-7.29.0-59.el7_9.2.x86_64 10/16 Verifying : curl-7.29.0-51.el7.x86_64 11/16 Verifying : libssh2-1.4.3-12.el7.x86_64 12/16 Verifying : 2:libpng-1.5.13-7.el7_2.x86_64 13/16 Verifying : libcurl-7.29.0-51.el7.x86_64 14/16 Verifying : freetype-2.8-12.el7.x86_64 15/16 Verifying : libjpeg-turbo-1.2.90-6.el7.x86_64 16/16 Installed:freetype-devel.x86_64 0:2.8-14.el7_9.1 libcurl-devel.x86_64 0:7.29.0-59.el7_9.2 libjpeg-turbo-devel.x86_64 0:1.2.90-8.el7 libpng-devel.x86_64 2:1.5.13-8.el7 Updated:curl.x86_64 0:7.29.0-59.el7_9.2 freetype.x86_64 0:2.8-14.el7_9.1 libjpeg-turbo.x86_64 0:1.2.90-8.el7 libpng.x86_64 2:1.5.13-8.el7 Dependency Updated:libcurl.x86_64 0:7.29.0-59.el7_9.2 libssh2.x86_64 0:1.8.0-4.el7_9.1 Complete!
解压-----进行配置-----编译-----编译安装:
[root@syf ~]# ls
anaconda-ks.cfg httpd-2.4.54.tar.gz
apr-1.7.0 initial-setup-ks.cfg
apr-1.7.0.tar.gz Music
apr-util-1.6.1 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54 Videos
[root@syf ~]# tar -xjvf php-7.1.10.tar.bz2
......
[root@syf ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg
apr-1.7.0 Music
apr-1.7.0.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1 php-7.1.10
apr-util-1.6.1.tar.gz php-7.1.10.tar.bz2
Desktop Pictures
Documents Public
Downloads Templates
httpd-2.4.54 Videos
httpd-2.4.54.tar.gz
[root@syf ~]# cd php-7.1.10/
[root@syf php-7.1.10]# ls
acinclude.m4 php.ini-development
aclocal.m4 php.ini-production
appveyor README.EXT_SKEL
build README.GIT-RULES
buildconf README.input_filter
buildconf.bat README.MAILINGLIST_RULES
CODING_STANDARDS README.md
config.guess README.namespaces
config.sub README.NEW-OUTPUT-API
configure README.PARAMETER_PARSING_API
configure.in README.REDIST.BINS
CONTRIBUTING.md README.RELEASE_PROCESS
CREDITS README.SELF-CONTAINED-EXTENSIONS
ext README.STREAMS
EXTENSIONS README.SUBMITTING_PATCH
footer README.TESTING
generated_lists README.TESTING2
genfiles README.UNIX-BUILD-SYSTEM
header README.WIN32-BUILD-SYSTEM
INSTALL run-tests.php
install-sh sapi
LICENSE scripts
ltmain.sh server-tests-config.php
main server-tests.php
makedist snapshot
Makefile.frag stamp-h.in
Makefile.gcov stub.c
Makefile.global tests
makerpm travis
missing TSRM
mkinstalldirs UPGRADING
netware UPGRADING.INTERNALS
NEWS vcsclean
pear win32
php7.spec.in Zend
php.gif
[root@syf php-7.1.10]# ./configure --prefix=/usr/local/php \
> --with-apxs2=/usr/local/apache/bin/apxs \
> --with-mysql-sock=/tmp/mysql.sock \
> --with-mysqli \
> --with-zlib \
> --with-curl \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --with-freetype-dir \
> --with-openssl \
> --enable-mbstring \
> --enable-xml \
> --enable-session \
> --enable-ftp \
> --enable-pdo \
> --enable-tokenizer \
> --enable-zip
......
[root@syf php-7.1.10]# make
...
[root@syf php-7.1.10]# make install
...
配置php:
[root@syf ~]# cd php-7.1.10/
[root@syf php-7.1.10]# ls
acinclude.m4 netware
aclocal.m4 NEWS
appveyor pear
build php7.spec
buildconf php7.spec.in
buildconf.bat php.gif
CODING_STANDARDS php.ini-development
config.guess php.ini-production
config.log README.EXT_SKEL
config.nice README.GIT-RULES
config.status README.input_filter
config.sub README.MAILINGLIST_RULES
configure README.md
configure.in README.namespaces
CONTRIBUTING.md README.NEW-OUTPUT-API
CREDITS README.PARAMETER_PARSING_API
ext README.REDIST.BINS
EXTENSIONS README.RELEASE_PROCESS
footer README.SELF-CONTAINED-EXTENSIONS
generated_lists README.STREAMS
genfiles README.SUBMITTING_PATCH
header README.TESTING
include README.TESTING2
INSTALL README.UNIX-BUILD-SYSTEM
install-sh README.WIN32-BUILD-SYSTEM
libphp7.la run-tests.php
libs sapi
libtool scripts
LICENSE server-tests-config.php
ltmain.sh server-tests.php
main snapshot
makedist stamp-h.in
Makefile stub.c
Makefile.frag tests
Makefile.fragments travis
Makefile.gcov TSRM
Makefile.global UPGRADING
Makefile.objects UPGRADING.INTERNALS
makerpm vcsclean
missing win32
mkinstalldirs Zend
modules
[root@syf php-7.1.10]# cp php.ini-development /usr/local/php/lib/php.ini
[root@syf php-7.1.10]# vim /usr/local/php/lib/php.ini
...
/date.time //搜索date.time
...
cli_server.color = On[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai //注释符去掉; http://php.net/date.default-latitude
...
需要让httpd支持php网页:
修改httpd配置文件:
[root@syf ~]# cd /etc/httpd24/
[root@syf httpd24]# ls
extra httpd.conf httpd.conf.bak magic mime.types original
[root@syf httpd24]# vim httpd.conf
.....
/index.html //搜索
........
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>DirectoryIndex index.html index.php //index.php写入
</IfModule>#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
......
AddType application/x-httpd-php .php //末尾写入
AddType application/x-httpd-php-source .phps //
~
~
修改测试网页:
[root@syf httpd24]# cd /usr/local/apache/
[root@syf apache]# ls
bin cgi-bin htdocs include man modules
build error icons logs manual
[root@syf apache]# cd htdocs/
[root@syf htdocs]# ls
index.html
[root@syf htdocs]# rm -rf index.html
[root@syf htdocs]# vim index.php
<?phpphpinfo();
?>
~
~
重新启动apache服务(无配置环境变量):
[root@syf ~]# /usr/local/apache/bin/apachectl stop
[root@syf ~]# /usr/local/apache/bin/apachectl start