编译部署LAMP
配置apache
[root@zyq ~]#: wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz
--2023-12-11 14:35:57-- https://downloads.apache.org/apr/apr-1.7.4.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1122147 (1.1M) [application/x-gzip]
Saving to: ‘apr-1.7.4.tar.gz’
apr-1.7.4.tar.g 100%[=======>] 1.07M 317KB/s in 3.5s
2023-12-11 14:36:01 (317 KB/s) - ‘apr-1.7.4.tar.gz’ saved [1122147/1122147]
[root@zyq ~]#: wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
--2023-12-11 14:36:58-- https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 556623 (544K) [application/x-gzip]
Saving to: ‘apr-util-1.6.3.tar.gz’
apr-util-1.6.3. 100%[=======>] 543.58K 397KB/s in 1.4s
2023-12-11 14:37:00 (397 KB/s) - ‘apr-util-1.6.3.tar.gz’ saved [556623/556623]
[root@zyq ~]#: wget https://downloads.apache.org/httpd/httpd-2.4.58.tar.gz
--2023-12-11 14:37:31-- https://downloads.apache.org/httpd/httpd-2.4.58.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9825177 (9.4M) [application/x-gzip]
Saving to: ‘httpd-2.4.58.tar.gz’
httpd-2.4.58.ta 100%[=======>] 9.37M 837KB/s in 11s
2023-12-11 14:37:44 (853 KB/s) - ‘httpd-2.4.58.tar.gz’ saved [9825177/9825177]
创建用户
[root@zyq ~]#: useradd -r -M -s /sbin/nologin apache
安装依赖包
[root@zyq ~]#: yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim
Last metadata expiration check: 0:06:27 ago on Mon 11 Dec 2023 02:34:25 PM CST.
Dependencies resolved.
================================================================
Package Arch Version Repo Size
================================================================
Installing:
expat-devel x86_64 2.5.0-1.el9 appstream 53 k
gcc x86_64 11.4.1-2.1.el9 appstream 32 M
......
perl-vars-1.05-480.el9.noarch
vim-common-2:8.2.2637-20.el9_1.x86_64
vim-enhanced-2:8.2.2637-20.el9_1.x86_64
vim-filesystem-2:8.2.2637-20.el9_1.noarch
Complete!
解压软件包
[root@zyq ~]#: ls
anaconda-ks.cfg apr-util-1.6.3.tar.gz
apr-1.7.4.tar.gz httpd-2.4.58.tar.gz
[root@zyq ~]#: tar xf apr-1.7.4.tar.gz
[root@zyq ~]#: tar xf apr-util-1.6.3.tar.gz
[root@zyq ~]#: tar xf httpd-2.4.58.tar.gz
[root@zyq ~]#: ls
anaconda-ks.cfg apr-util-1.6.3 httpd-2.4.58.tar.gz
apr-1.7.4 apr-util-1.6.3.tar.gz
apr-1.7.4.tar.gz httpd-2.4.58
修改configure文件
[root@zyq apr-1.7.4]#: vim configure
/cfgfile
cfgfile="${ofile}T"
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //将此行加上注释,或者删除此行
进行编译
[root@zyq apr-1.7.4]#: ./configure --prefix=/usr/local/apr
[root@zyq apr-1.7.4]#: make && make install
[root@zyq apr-util-1.6.3]#:./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
.......
[root@zyq apr-util-1.6.3]#: make && make install
[root@zyq apr-util-1.6.3]#: cd ../httpd-2.4.58/
[root@zyq httpd-2.4.58]#: ./configure --prefix=/usr/local/apache \
--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
......
[root@zyq httpd-2.4.58]#: make && make install
安装后配置
[root@zyq ~]#: ls /usr/local/
apache apr-util etc include lib64 sbin src
apr bin games lib libexec share
[root@zyq ~]#: ls /usr/local/apache/
bin cgi-bin htdocs include man modules
build error icons logs manual
[root@zyq ~]#: echo 'export PATH=/usr/local/apache/bin:$PATH'> /etc/profile.d/httpd.sh
[root@zyq ~]#: ln -s /usr/local/apache/include/ /usr/include/apache
[root@zyq ~]#: vim /etc/man_db.conf
MANDATORY_MANPATH /usr/local/apache/man
启动服务
[root@zyq ~]#: source /etc/profile.d/httpd.sh
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@zyq ~]#: apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe92:c051%ens160. Set the 'ServerName' directive globally to suppress this message
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
关闭防火墙
[root@zyq ~]#: systemctl disable --now firewalld.service
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@zyq ~]#: setenforce 0
[root@zyq ~]#: vim /etc/selinux/config
设置开机自启
[root@zyq apache]#: vim /usr/local/apache/conf/httpd.conf
ServerName www.example.com:80 取消此行注释
[root@zyq apache]#: apachectl stop
[root@zyq apache]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
修改配置文件
[root@zyq ~]#: cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/httpd.service
[root@zyq ~]#: vim /usr/lib/systemd/system/httpd.service
[root@zyq ~]#: cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=OpenSSH server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@zyq ~]#: systemctl daemon-reload
[root@zyq ~]#: systemctl status httpd
○ httpd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; dis>
Active: inactive (dead)
[root@zyq ~]#: systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@zyq ~]#: systemctl status httpd
● httpd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; ena>
Active: active (running) since Mon 2023-12-11 15:45:24 CST>
Process: 88201 ExecStart=/usr/local/apache/bin/apachectl st>
Main PID: 88204 (httpd)
Tasks: 1 (limit: 48715)
Memory: 1.0M
CPU: 12ms
CGroup: /system.slice/httpd.service
└─88204 /usr/local/apache/bin/httpd -k start
Dec 11 15:45:09 zyq systemd[1]: Starting OpenSSH server daemon.>
Dec 11 15:45:24 zyq apachectl[88203]: AH00558: httpd: Could not>
Dec 11 15:45:24 zyq systemd[1]: Started OpenSSH server daemon.
配置MySQL
安装依赖包
[root@zyq ~]#: yum -y install epel-release
[root@zyq ~]#: yum -y install https://mirror.stream.centos.org/9-stream/CRB/x86_64/os/Packages/mariadb-devel-10.5.16-2.el9.x86_64.rpm
......
Upgraded:
zlib-1.2.11-40.el9.x86_64
Installed:
mariadb-connector-c-3.2.6-1.el9_0.x86_64
mariadb-connector-c-config-3.2.6-1.el9_0.noarch
mariadb-connector-c-devel-3.2.6-1.el9_0.x86_64
mariadb-devel-3:10.5.16-2.el9.x86_64
zlib-devel-1.2.11-40.el9.x86_64
Complete!
[root@zyq ~]#: rpm -qa | grep mariadb
mariadb-connector-c-config-3.2.6-1.el9_0.noarch
mariadb-connector-c-3.2.6-1.el9_0.x86_64
mariadb-connector-c-devel-3.2.6-1.el9_0.x86_64
mariadb-devel-10.5.16-2.el9.x86_64
[root@zyq ~]#:
[root@zyq ~]#: yum -y install ncurses-devel openssl-devel openssl cmake
......
Installed:
cmake-3.20.2-8.el9.x86_64
cmake-data-3.20.2-8.el9.noarch
cmake-filesystem-3.20.2-8.el9.x86_64
cmake-rpm-macros-3.20.2-8.el9.noarch
libuv-1:1.42.0-1.el9.x86_64
ncurses-c++-libs-6.2-10.20210508.el9.x86_64
ncurses-devel-6.2-10.20210508.el9.x86_64
Complete!
创建用户
[root@zyq ~]#: useradd -r -M -s /sbin/nologin mysql
上传MySQL软件包
[root@zyq ~]#: ls
apr-util-1.6.3.tar.gz anaconda-ks.cfg httpd-2.4.58
apr-1.7.4 httpd-2.4.58.tar.gz
apr-1.7.4.tar.gz mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz
apr-util-1.6.3
[root@zyq ~]#: tar xf mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz -C /usr/local/
[root@zyq ~]#: cd /usr/local/
[root@zyq local]#: mv mysql-8.0.35-linux-glibc2.28-x86_64/ mysql
[root@zyq local]#: chown -R mysql.mysql mysql
[root@zyq local]#: ll
total 0
drwxr-xr-x. 14 root root 164 Dec 11 15:34 apache
drwxr-xr-x. 6 root root 58 Dec 11 14:53 apr
drwxr-xr-x. 5 root root 43 Dec 11 14:59 apr-util
drwxr-xr-x. 2 root root 6 May 16 2022 bin
drwxr-xr-x. 2 root root 6 May 16 2022 etc
drwxr-xr-x. 2 root root 6 May 16 2022 games
drwxr-xr-x. 2 root root 6 May 16 2022 include
drwxr-xr-x. 2 root root 6 May 16 2022 lib
drwxr-xr-x. 3 root root 17 Dec 5 10:21 lib64
drwxr-xr-x. 2 root root 6 May 16 2022 libexec
drwxr-xr-x. 9 mysql mysql 129 Dec 11 16:03 mysql
drwxr-xr-x. 2 root root 6 May 16 2022 sbin
drwxr-xr-x. 5 root root 49 Dec 5 10:21 share
drwxr-xr-x. 2 root root 6 May 16 2022 src
设置环境变量
[root@zyq ~]#: echo 'export PATH=/usr/local/mysql/bin:$PATH'> /etc/profile.d/mysql.sh
[root@zyq ~]#: source /etc/profile.d/mysql.sh
创建数据存放路径
[root@zyq ~]#: mkdir /opt/data
[root@zyq ~]#: chown -R mysql.mysql /opt/data/
初始化数据库
[root@zyq bin]#: /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2023-12-11T08:13:04.906951Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.35) initializing of server in progress as process 94610
2023-12-11T08:13:04.921197Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-11T08:13:05.433632Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-11T08:13:06.985899Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: I(aToa#hd9g(
[root@zyq ~]#: echo 'I(aToa#hd9g(' > pass
[root@zyq ~]#: vim /etc/my.cnf
[root@zyq ~]#: cat /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
[client-server]
[root@zyq ~]#: ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@zyq ~]#: vim /etc/ld.so.conf.d/mysql.conf
[root@zyq ~]#: cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@zyq ~]#: ldconfig -v
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Path `/usr/lib64' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/local/mysql/lib: (from /etc/ld.so.conf.d/mysql.conf:1)
libmysqlclient.so.21 -> libmysqlclient.so.21.2.35
/lib: (from <builtin>:0)
/lib64: (from <builtin>:0)
libctf-nobfd.so.0 -> libctf-nobfd.so.0.0.0
libbfd-2.35.2-42.el9.so -> libbfd-2.35.2-42.el9.s
......
[root@zyq ~]#: vim /etc/man_db.conf
#添加此行
MANDATORY_MANPATH /usr/local/mysql/man
[root@zyq ~]#: ls /usr/local/mysql/support-files/
mysqld_multi.server mysql-log-rotate mysql.server
指定路径
[root@zyq ~]#: vim /usr/local/mysql/support-files/mysql.server
basedir=/usr/local/mysql
datadir=/opt/data
[root@zyq ~]#: /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/opt/data/zyq.err'.
. SUCCESS!
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 151 *:3306 *:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22
设置开机自启
[root@lyx ~]# cp /usr/lib/systemd/system/sshd.service
/usr/lib/systemd/system/mysqld.service
[root@lyx ~]# vim /usr/lib/systemd/system/mysqld.service
[root@lyx ~]# cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=mysqld 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@lyx ~]# systemctl daemon-reload
[root@lyx ~]# systemctl status mysqld
○ mysqld.service - mysqld server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset:
disabled)
Active: inactive (dead)
[root@zyq ~]#: systemctl enable --now mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@zyq ~]#: systemctl status mysqld.service
● mysqld.service
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; en>
Active: active (running) since Mon 2023-12-11 16:46:02 CST>
Process: 95768 ExecStart=/usr/local/mysql/support-files/mys>
Main PID: 95785 (mysqld_safe)
Tasks: 39 (limit: 48715)
Memory: 368.6M
CPU: 490ms
CGroup: /system.slice/mysqld.service
├─95785 /bin/sh /usr/local/mysql/bin/mysqld_safe ->
└─95975 /usr/local/mysql/bin/mysqld --basedir=/usr>
Dec 11 16:46:01 zyq systemd[1]: Starting mysqld.service...
Dec 11 16:46:02 zyq mysql.server[95768]: Starting MySQL. SUCCES>
Dec 11 16:46:02 zyq systemd[1]: Started mysqld.service.
lines 1-15/15 (END)
修改密码
[root@zyq ~]#: cat pass
I(aToa#hd9g(
[root@zyq ~]#: mysql -uroot -p'I(aToa#hd9g('
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35
Copyright (c) 2000, 2023, 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> alter user 'root'@'localhost' identified with mysql_native_password by 'Pssword@_'
-> ;
Query OK, 0 rows affected (0.00 sec)
安装php
https://www.php.net/distributions/php-8.3.3.tar.gz
[root@zyq ~]#: wget https://www.php.net/distributions/php-8.3.0.tar.xz
--2023-12-11 17:41:20-- https://www.php.net/distributions/php-8.3.0.tar.xz
Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad
Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12431612 (12M) [application/octet-stream]
Saving to: ‘php-8.3.0.tar.xz’
php-8.3.0.tar.x 100%[=======>] 11.86M 549KB/s in 19s
2023-12-11 17:41:41 (624 KB/s) - ‘php-8.3.0.tar.xz’ saved [12431612/12431612]
[root@zyq ~]#: tar xf php-8.3.0.tar.xz
[root@zyq ~]#: ls
anaconda-ks.cfg
apr-1.7.4
apr-1.7.4.tar.gz
apr-util-1.6.3
apr-util-1.6.3.tar.gz
httpd-2.4.58
httpd-2.4.58.tar.gz
mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz
pass
php-8.3.0
php-8.3.0.tar.xz
[root@zyq ~]#: cd php-8.3.0/
[root@zyq php-8.3.0]#: ls
appveyor ext sapi
benchmark EXTENSIONS scripts
build LICENSE SECURITY.md
buildconf main tests
buildconf.bat NEWS travis
CODEOWNERS pear TSRM
CODING_STANDARDS.md php.ini-development UPGRADING
configure php.ini-production UPGRADING.INTERNALS
configure.ac README.md win32
CONTRIBUTING.md README.REDIST.BINS Zend
docs run-tests.php
安装以来环境
[root@zyq ~]#: yum -y install epel-release
[root@zyq ~]#: yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php-mysqlnd
[root@zyq ~]#: yum -y install libsqlite3x-devel libzip-devel
Last metadata expiration check: 0:10:18 ago on Mon 11 Dec 2023 08:06:23 PM CST.
Dependencies resolved.
================================================================
Package Arch Version Repository Size
================================================================
Installing:
libsqlite3x-devel x86_64 20071018-31.el9 epel 134 k
......
pgraded:
sqlite-libs-3.34.1-6.el9_1.x86_64
Installed:
libsqlite3x-20071018-31.el9.x86_64
libsqlite3x-devel-20071018-31.el9.x86_64
sqlite-3.34.1-6.el9_1.x86_64
sqlite-devel-3.34.1-6.el9_1.x86_64
Complete!
[root@zyq ~]#: wget https://dl.rockylinux.org/pub/rocky/9/devel/x86_64/os/Packages/o/oniguruma-devel-6.9.6-1.el9.5.x86_64.rpm
[root@zyq ~]#: cd /etc/yum.repos.d/
[root@zyq yum.repos.d]#: vim rocky-devel.repo
[devel]
name=Rocky Linux $releasever - Devel WARNING! FOR BUILDROOT ONLY DO NOT LEAVE ENABLED
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=devel-$releasever$rltype
#baseurl=http://dl.rockylinux.org/$contentdir/$releasever/devel/$basearch/os/
gpgcheck=1
enabled=1 打开,将0该为1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
......
[root@zyq yum.repos.d]#: yum list all | grep oniguruma-devel
oniguruma-devel.x86_64 6.9.6-1.el9.5 devel
[root@zyq yum.repos.d]#: yum -y install oniguruma-devel
编译
[root@zyq ~]#: cd php-8.3.0/
[root@zyq php-8.3.0]#: ./configure --prefix=/usr/local/php8 \
--with-config-file-path=/etc \
--enable-fpm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
[root@zyq php-8.3.0]#: make -j2
......
[root@zyq php-8.3.0]#: make install
......
安装完成后设置环境变量
[root@zyq php-8.3.0]#: ls /usr/local/php8/
bin etc include lib php sbin var
[root@zyq local]#: echo 'export PATH=/usr/local/php8/bin:/usr/local/php8/sbin:$PATH'> /etc/profile.d/php.sh
[root@zyq php-8.3.0]#: source /etc/profile.d/php.sh
[root@zyq php-8.3.0]#: ln -s /usr/local/php8/include/ /usr/include/php
[root@zyq php-8.3.0]#: vim /etc/ld.so.conf.d/php.conf
[root@zyq php-8.3.0]#: cat /etc/ld.so.conf.d/php.conf
/usr/local/php8/lib
[root@zyq php-8.3.0]#: ldconfig -v
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Path `/usr/lib64' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/local/mysql/lib: (from /etc/ld.so.conf.d/mysql.conf:1)
libmysqlclient.so.21 -> libmysqlclient.so.21.2.35
/usr/local/php8/lib: (from /etc/ld.so.conf.d/php.conf:1)
......
[root@zyq local]#: which php
/usr/local/php8/bin/php
[root@zyq local]#: php -v
PHP 8.3.0 (cli) (built: Dec 11 2023 20:53:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
修该配置文件
[root@zyq php-8.3.0]#: pwd
/root/php-8.3.0
[root@zyq php-8.3.0]#: ls
appveyor EXTENSIONS README.md
benchmark include README.REDIST.BINS
build libs run-tests.php
buildconf libtool sapi
buildconf.bat LICENSE scripts
CODEOWNERS main SECURITY.md
CODING_STANDARDS.md Makefile tests
config.log Makefile.fragments travis
config.nice Makefile.objects TSRM
config.status modules UPGRADING
configure NEWS UPGRADING.INTERNALS
configure.ac pear win32
CONTRIBUTING.md php.ini-development Zend
docs php.ini-production
ext php.sh
[root@zyq php-8.3.0]#: cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
配置php-fpm
[root@zyq php-8.3.0]#: mkdir /etc/init.d
[root@zyq php-8.3.0]#: cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@zyq php-8.3.0]#: ll /etc/init.d/
total 4
-rw-r--r--. 1 root root 2402 Dec 11 21:19 php-fpm
[root@zyq ~]#: chmod +x /etc/init.d/php-fpm
[root@zyq etc]#: cd /usr/local/php8/
[root@zyq php8]#: ls
bin etc include lib php sbin var
[root@zyq php8]#: cd etc/
[root@zyq etc]#: ls
pear.conf php-fpm.conf.default php-fpm.d
[root@zyq etc]#: cp php-fpm.conf.default php-fpm.conf
[root@zyq etc]#: ls
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
[root@zyq etc]#: cd php-fpm.d/
[root@zyq php-fpm.d]#: ls
www.conf.default
[root@zyq php-fpm.d]#: cp www.conf.default www.conf
[root@zyq php-fpm.d]#: ls
www.conf www.conf.default
[root@zyq php-fpm.d]#: cd
[root@zyq ~]#: service php-fpm start
Starting php-fpm done
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 151 *:3306 *:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@zyq ~]#: service php-fpm stop
Gracefully shutting down php-fpm . done
设置开机自启
[root@zyq ~]#: cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/php-fpm.service
[root@zyq ~]#: vim /usr/lib/systemd/system/php-fpm.service
[root@zyq ~]#: cat /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=OpenSSH server daemon
After=network.target
[Service]
Type=forking
ExecStart=service php-fpm start
ExecStop=service php-fpm stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@zyq ~]#: systemctl daemon-reload
[root@zyq ~]#: systemctl status php-fpm.service
○ php-fpm.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; e>
Active: inactive (dead)
Dec 11 21:40:51 zyq systemd[1]: php-fpm.service: Service has mo>
Dec 11 21:41:59 zyq systemd[1]: php-fpm.service: Service has mo>
[root@zyq ~]#: systemctl enable --now php-fpm
[root@zyq ~]#: systemctl status php-fpm
● php-fpm.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; e>
Active: active (running) since Mon 2023-12-11 21:43:40 CST>
Process: 251800 ExecStart=service php-fpm start (code=exite>
Main PID: 251806 (php-fpm)
Tasks: 3 (limit: 48715)
Memory: 7.2M
CPU: 30ms
CGroup: /system.slice/php-fpm.service
├─251806 "php-fpm: master process (/usr/local/php8>
├─251807 "php-fpm: pool www"
└─251808 "php-fpm: pool www"
Dec 11 21:43:40 zyq systemd[1]: Starting OpenSSH server daemon.>
Dec 11 21:43:40 zyq service[251804]: Starting php-fpm done
Dec 11 21:43:40 zyq systemd[1]: Started OpenSSH server daemon.
...skipping...
● php-fpm.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; e>
Active: active (running) since Mon 2023-12-11 21:43:40 CST>
Process: 251800 ExecStart=service php-fpm start (code=exite>
Main PID: 251806 (php-fpm)
Tasks: 3 (limit: 48715)
Memory: 7.2M
CPU: 30ms
CGroup: /system.slice/php-fpm.service
├─251806 "php-fpm: master process (/usr/local/php8>
├─251807 "php-fpm: pool www"
└─251808 "php-fpm: pool www"
Dec 11 21:43:40 zyq systemd[1]: Starting OpenSSH server daemon.>
Dec 11 21:43:40 zyq service[251804]: Starting php-fpm done
Dec 11 21:43:40 zyq systemd[1]: Started OpenSSH server daemon.
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 151 *:3306 *:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
配置apache
[root@zyq ~]#: sed -i '/proxy_module/s/#//g' /usr/local/apache/conf/httpd.conf
[root@zyq ~]#: sed -i '/proxy_fcgi_module/s/#//g' /usr/local/apache/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
取消上面两行注释启用httpd的相关模块
[root@zyq ~]#: cd /usr/local/apache
[root@zyq apache]#: ls
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@zyq apache]#: cd htdocs/
[root@zyq htdocs]#: ls
index.html
创建测试web页面
[root@zyq htdocs]#: mkdir test
[root@zyq htdocs]#: cd test/
[root@zyq test]#: vim index.php
[root@zyq test]#: cat index.php
<?php
phpinfo();
?>
[root@zyq test]#: vim /usr/local/apache/conf/httpd.conf
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Include conf/extra/vhosts.conf #加入此行
[root@zyq test]#: vim /usr/local/apache/conf/extra/vhosts.conf
[root@zyq extra]#: cat /usr/local/apache/conf/extra/vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/test"
ServerName www.zyq.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/test/$1
<Directory "/usr/local/apache/htdocs/test">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@zyq ~]#: vim /usr/local/apache/conf/httpd.conf
//搜索AddType,添加以下内容
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php #添加此行
AddType application/x-httpd-php-source .phps #添加此行
<IfModule dir_module>
DirectoryIndex index.html index.php 加上index.php
</IfModule>
重启服务
[root@zyq ~]#: systemctl restart httpd.service
[root@zyq ~]#: systemctl restart php-fpm.service
[root@zyq ~]#: ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 151 *:3306 *:*
LISTEN 0 511 *:80 *:*
关闭防火墙访问php测试页面