LAMP----------install

Install MySQL

initialization
软件包放在在例方便管理

[[email protected] ~]# cd /usr/local/src
[[email protected] src]# ll
total 321036
-rw-r–r--. 1 root root 328740156 Nov 10 01:37 mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz

解压源码包

[[email protected] src]# tar -zxf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz

移动mysql文件的位置

[[email protected] src]# mv mysql-5.6.43-linux-glibc2.12-x86_64 /usr/local/mysql/

建立mysql用户,因为启动MySQL需要改用户

[[email protected] src]# useradd -s /sbin/nologin mysql

创建datadir,数据库文件会放到这里面,并更改权限,不更改后续操作会出现问题

[[email protected] src]# cd /usr/local/mysql/
[[email protected] mysql]# mkdir -p /data/mysql; chown -R mysql:mysql /data/mysql
[[email protected] mysql]# cd /data/mysql
[[email protected] mysql]# ls -la
total 110600
drwxr-xr-x. 5 mysql mysql 104 Nov 10 02:11 .
drwxr-xr-x. 3 root root 18 Nov 10 01:46 …

报错:缺少包perl-Module-Install而导致报错

[[email protected] mysql]# cd /usr/local/mysql/
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
![Insert picture description here]([ [email protected] php-7.4.19]# cd /usr/local/php7/
[[email protected] php7]# ls
bin include lib php php.ini var
//–user means to define which user the database runs as
// --Datadir means to define the installation directory of the database

[[email protected] mysql]# yum install -y perl-Module-Install

执行完成后会出现两个OK,并且在/data/mysql 目录下会生成几个文件和目录,说明MySQL安装成功啦

[[email protected] src]# cd /usr/local/mysql/
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

Insert picture description here


Insert picture description here
Configure MySQL
复制配置文件

[[email protected] mysql]# cd /usr/local/mysql/
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y (是否覆盖)

打开配置文件,做一下配置

[[email protected] support-files]# vi /etc/my.cnf

[mysqld]

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
server_id = 25
socket = /tmp/mysql.sock
Insert picture description here
复制启动脚本文件并修改其属性

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# chmod 777 /etc/init.d/mysqld

修改启动脚本,并把它加入系统服务项,并设定开机启动MySQL

[[email protected] mysql]# vi /etc/init.d/mysqld

Insert picture description here

[[email protected] mysql]# chkconfig --add mysql
[[email protected] mysql]# chkconfig mysql on
[[email protected] mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/localhost.localdomain.err’.
SUCCESS!

[[email protected] mysql]# ps aux | grep mysql
root 19482 0.0 0.0 11824 1624 pts/1 S 01:51 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql 19659 2.1 24.2 1302756 452908 pts/1 Sl 01:51 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root 19685 0.0 0.0 112812 968 pts/1 S+ 01:52 0:00 grep --color=auto mysql

[[email protected] mysql]# yum install -y net-tools

[[email protected] mysql]# netstat -ntpl | grep 3306
tcp6 0 0 :::3306 ::😗 LISTEN 19659/mysqld

详解:
Insert picture description here
Install Apache
① 安装apr

[[email protected] ~]# cd /usr/local/src

[[email protected] src]# tar -zxf apr-1.6.5.tar.gz
[[email protected] src]# tar -zxf apr-util-1.6.1.tar.gz
[[email protected] src]# tar -zxf httpd-2.4.46.tar.gz

[[email protected] src]# cd apr-1.6.5/
[[email protected] apr-1.6.5]# 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

Note: (The environment is relatively clean and lacks libtoolT)
[[email protected] apr-1.6.5]# ./configure --prefix=/usr/local/apr
. . .
rm: cannot remove'libtoolT': No such file or directory
config.status: executing default commands

解决:
[[email protected] apr-1.6.5]# yum install -y libtool*

Compile again:
[[email protected] apr-1.6.5]# ./configure --prefix=/usr/local/apr

Insert picture description here


(Ignorable)

②安装apr-util

[[email protected] apr-1.6.5]# cd …
[[email protected] src]# cd apr-util-1.6.1
[[email protected] apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[[email protected] apr-util-1.6.1]# make && make install

Insert picture description here

[[email protected] apr-util-1.6.1]# yum install -y expat-devel

再次运行
[[email protected] apr-util-1.6.1]# make && make install(无报错)
[[email protected] apr-util-1.6.1]# echo $?
0
[[email protected] apr-util-1.6.1]# cd …
[[email protected] src]#
[[email protected] src]#
[[email protected] src]# ls /usr/local/
apr bin games lib libexec sbin src
apr-util etc include lib64 mysql share

③安装httpd

[[email protected] src]# cd httpd-2.4.46
//The backslash here is an escape character, plus it we can write one line of command into multiple lines

[[email protected] httpd-2.4.46]# ./configure \
> --prefix=/usr/local/apache2.4 \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util \
> --enable-so \
> --enable-mods-shared=most
Insert picture description here


Error:

Insert picture description here


To avoid errors when make, install the library files in advance. ·
Solution:
[[email protected] httpd-2.4.46]# yum install -y pcre-devel

Run again: (0 means no problem)
[[email protected] httpd-2.4.46]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with -apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

[[email protected] httpd-2.4.46]# echo $?
0

[[email protected] httpd-2.4.46]# make && make install

Insert picture description here

解决(成功)
[[email protected] httpd-2.4.46]# cd srclib/
[[email protected] srclib]# ls
apr apr-util Makefile Makefile.in
[[email protected] srclib]#
[[email protected] srclib]#
[[email protected] srclib]# cd …
[[email protected] httpd-2.4.46]#
[[email protected] httpd-2.4.46]# ls
ABOUT_APACHE config.log InstallBin.dsp os
acinclude.m4 config.nice LAYOUT README
Apache-apr2.dsw config.status libhttpd.dep README.cmake
Apache.dsw configure libhttpd.dsp README.platforms
apache_probes.d configure.in libhttpd.mak ROADMAP
ap.d docs LICENSE server
build emacs-style Makefile srclib
BuildAll.dsp httpd.dep Makefile.in support
BuildBin.dsp httpd.dsp Makefile.win test
buildconf httpd.mak modules VERSIONING
CHANGES httpd.spec modules.c
CMakeLists.txt include NOTICE
config.layout INSTALL NWGNUmakefile
[[email protected] httpd-2.4.46]# make clean

[[email protected] httpd-2.4.46]# ./configure --prefix=/usr/local/apache2.4 --enable-so --with-pcre --with-included-apr --enable-modules=most --enable-mpms-share=all --with-mpm=prefork

[[email protected] httpd-2.4.46]# echo $?
0
[[email protected] httpd-2.4.46]# make && make install
[[email protected] httpd-2.4.46]# echo $?
0

[[email protected] src]# cd httpd-2.4.46
[[email protected] httpd-2.4.46]# cd /usr/local/
[[email protected] local]# du -sh apache2.4/
42M apache2.4/
[[email protected] local]# cd apache2.4/

View the loaded module: with shared means the module is a dynamic shared module (a separate file); static is a static module (tied directly with the main program)
[[email protected] apache2.4]# /usr/local/apache2. 4/bin/httpd -M
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
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_prefork_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (
auth_basic)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)

Install PHP

[[email protected] src]# tar -zxf php-7.4.19.tar.gz
[[email protected] src]# cd php-7.4.19
[[email protected] php-7.4.19]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

But it will prompt the following:
No package'libxml-2.0' found
Solution:
[[email protected] src]# yum install libxml2-devel bzip2 bzip2-devel libpng libpng-devel openssl openssl-devel freetype freetype-devel opel-release -y
maybe Will report an error and delete --with-jpeg-dir (picture)

[[email protected] src]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

Error:

[[email protected] php-7.4.19]# yum install -y sqlite-devel
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

No package 'sqlite3' found

configure: error: Package requirements (oniguruma) were not met:
No package 'oniguruma' found

https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz

[[email protected] ~]# tar -zxf oniguruma-6.9.4.tar.gz
[[email protected] oniguruma-6.9.4]# cd oniguruma-6.9.4/

[[email protected] oniguruma-6.9.4]# ./autogen.sh

[[email protected] oniguruma-6.9.4]# ./configure --prefix=/usr --libdir=/lib64
//64-bit system must be marked with --libdir=/lib64, otherwise it will not work

[[email protected] oniguruma-6.9.4]# make && make install

[[email protected]alhost oniguruma-6.9.4]# echo $?
0

[[email protected] src]# cd php-7.4.19
[[email protected] php-7.4.19]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

Insert picture description here


[[email protected] php-7.4.19]# make && make install

Insert picture description here

[[email protected] php-7.4.19]# echo $?
0

[[email protected] php-7.4.19]# /usr/local/apache2.4/bin/httpd -M
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
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_prefork_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
php7_module (shared)

[[email protected] php-7.4.19]# cd /usr/local/apache2.4/modules/

Insert picture description here


View the installation information of php

Insert picture description here


Finally back up the configuration file
[[email protected] php-7.4.19]# cp php.ini-production / usr/local/php7/php.ini

[[email protected] php-7.4.19]# cd /usr/local/php7/
[[email protected] php7]# ls
bin include lib php php.inivar is
installed.