lamp的独立部署
安装httpd
//这里是有yum源的配置就不需要做配置了
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Stream-AppStream.repo CentOS-Stream-HighAvailability.repo
CentOS-Stream-BaseOS.repo CentOS-Stream-Media.repo
CentOS-Stream-Debuginfo.repo CentOS-Stream-PowerTools.repo
CentOS-Stream-Extras.repo CentOS-Stream-RealTime.repo
安装开发工具包
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum groups mark install 'Development Tools'
安装依赖包
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
//创建apache用户
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
//安装依赖包
这里首先查看一下有没有apache残留
[root@localhost ~]# rpm -qa |grep httpd
[root@localhost ~]# which apachectl
/usr/bin/which: no apachectl in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
把安装httpd的三个包下载并拖进findshell
[root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1.tar.bz2 initial-setup-ks.cfg
apr-1.7.0.tar.bz2 httpd-2.4.43.tar.bz2
[root@localhost ~]# tar xf apr-1.7.0.tar.bz2
[root@localhost ~]# tar xf apr-util-1.6.1.tar.bz2
[root@localhost ~]# tar xf httpd-2.4.43.tar.bz2
修改配置文件
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.43.tar.bz2
apr-1.7.0 apr-util-1.6.1 httpd-2.4.43 initial-setup-ks.cfg
[root@localhost ~]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# ls
apr-config.in build.conf dso libapr.rc NOTICE support
apr.dep buildconf emacs-mode LICENSE NWGNUmakefile tables
apr.dsp build-outputs.mk encoding locks passwd test
apr.dsw CHANGES file_io Makefile.in poll threadproc
apr.mak CMakeLists.txt helpers Makefile.win random time
apr.pc.in config.layout include memory README tools
apr.spec configure //修改这个文件 libapr.dep misc README.cmake user
atomic configure.in libapr.dsp mmap shmem
build docs libapr.mak network_io strings
[root@localhost apr-1.7.0]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
把中间这行删掉
cat <<_LT_EOF >> "$cfgfile"
编译安装
[root@localhost 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
checking for chosen layout... apr
checking for gcc... gcc
安装
[root@localhost apr-1.7.0]# make
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
make[1]: 离开目录“/root/apr-1.7.0”
[1]+ 已完成 make
[root@localhost apr-1.7.0]# make install
/usr/bin/install -c -m 755 /root/apr-1.7.0/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
/usr/bin/install -c -m 644 /root/apr-1.7.0/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
编译另外一个包
[root@localhost 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
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
安装
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
安装httpd
[root@localhost httpd-2.4.43]# ./configure --prefix=/usr/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
Server Version: 2.4.43
Install prefix: /usr/local/apache
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
看到这个说明没有问题
直接就可以安装了
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
[root@localhost ~]# ls /usr/local/apache
bin build cgi-bin error htdocs icons include logs man manual modules
做一个环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' >/etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
头文件映射
[root@localhost ~]# ln -s /usr/local/apache/include /usr/include/httpd
[root@localhost ~]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
启动apache
[root@localhost ~]# apachectl start
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
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
永久关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# 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 these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
访问测试httpd
看到这个页面就表明apache安装成功了
安装mysql
安装mysql之前需要先安装依赖包
[root@localhost ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
创建用户
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql
[root@localhost ~]# id mysql
uid=973(mysql) gid=972(mysql) 组=972(mysql)
解压
[root@localhost ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.33-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ls
apache apr-util etc include lib64 mysql share
apr bin games lib libexec sbin src
[root@localhost local]# chown -R mysql.mysql mysql/
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 13 root root 152 5月 12 06:26 apache
drwxr-xr-x. 6 root root 58 5月 12 06:16 apr
drwxr-xr-x. 5 root root 43 5月 12 06:21 apr-util
drwxr-xr-x. 2 root root 6 5月 18 2020 bin
drwxr-xr-x. 2 root root 6 5月 18 2020 etc
drwxr-xr-x. 2 root root 6 5月 18 2020 games
drwxr-xr-x. 2 root root 6 5月 18 2020 include
drwxr-xr-x. 2 root root 6 5月 18 2020 lib
drwxr-xr-x. 3 root root 17 5月 11 10:38 lib64
drwxr-xr-x. 2 root root 6 5月 18 2020 libexec
drwxr-xr-x. 9 mysql mysql 129 5月 12 06:55 mysql
drwxr-xr-x. 2 root root 6 5月 18 2020 sbin
drwxr-xr-x. 5 root root 49 5月 11 10:38 share
drwxr-xr-x. 2 root root 6 5月 18 2020 src
写一个环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost ~]# source /etc/profile.d/mysql.sh
做软连接
[root@localhost ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql/
编写库文件的配置文件
[root@localhost ~]# vim /etc/ld.so.conf.d/mysql.cnf
/usrlocal/msyql/lib
[root@localhost ~]# ldconfig //重新读取配置文件
[root@localhost ~]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
MANDATORY_MANPATH /usr/local/mysql/man
创建存放mysql的目录
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data
[root@localhost ~]# ll /opt
总用量 0
drwxr-xr-x. 2 mysql mysql 6 5月 12 07:04 data
初始化
[root@localhost ~]# mysqld --initialize --user=mysql --datadir=/opt/data
2021-05-12T11:06:23.753752Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-12T11:06:23.944910Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-12T11:06:23.978220Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-12T11:06:23.986064Z 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: 16e59737-b312-11eb-b38b-000c29fa596e.
2021-05-12T11:06:23.986662Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-12T11:06:24.410733Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-12T11:06:24.529597Z 1 [Note] A temporary password is generated for root@localhost: gpV%s>/H6fj/
生成配置文件
[root@localhost ~]# cat > /etc/my.cnf <<EOF
> [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
> EOF
[root@localhost ~]# 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
编写配置文件
[root@localhost ~]# cp /usr/local//mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/opt/data
启动mysql
[root@localhost ~]# service mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
安装一个软件包用于进入msyql
[root@localhost ~]# dnf whatprovides libncurses.so.5
上次元数据过期检查:3:34:14 前,执行于 2021年05月12日 星期三 03时41分34秒。
ncurses-compat-libs-6.1-7.20180224.el8.i686 : Ncurses compatibility libraries
仓库 :baseos
匹配来源:
提供 : libncurses.so.5
[root@localhost ~]# dnf -y install ncurses-compat-libs
登录进去并更改密码
mysql> set password = password('ZHANGde12+Jun');
设置开机自启
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
安装php
[root@localhost ~]# dnf -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和msyql
[root@localhost ~]# dnf list all |grep php|grep mysql
php-mysqlnd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
过滤一下php,方便更好的看出有哪些软件包
[root@localhost ~]# dnf list all | grep php
mlt-php.x86_64 6.24.0-4.el8 epel
php.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-IDNA_Convert.noarch 0.8.0-14.el8 epel
php-adodb.noarch 5.20.6-9.el8 epel
php-bcmath.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-cli.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-common.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-dba.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-dbg.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-devel.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-embedded.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-enchant.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-fpm.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-gd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-gmp.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-intl.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-json.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-ldap.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-mbstring.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-mysqlnd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-odbc.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-opcache.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-pdo.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-pear.noarch 1:1.10.5-9.module_el8.2.0+313+b04d0a66 appstream
php-pear-Auth-SASL.noarch 1.1.0-6.el8 epel
php-pear-Cache-Lite.noarch 1.8.3-1.el8 epel
php-pear-Date.noarch 1.4.7-22.el8 epel
php-pear-HTTP-Request.noarch 1.4.4-18.el8 epel
php-pear-Mail.noarch 1.4.1-6.el8 epel
php-pear-Net-SMTP.noarch 1.9.0-1.el8 epel
php-pear-Net-Socket.noarch 1.2.2-6.el8 epel
php-pear-Net-URL.noarch 1.0.15-20.el8 epel
php-pear-Text-Diff.noarch 1.2.2-9.el8 epel
php-pecl-apcu.x86_64 5.1.12-2.module_el8.2.0+313+b04d0a66 appstream
php-pecl-apcu-devel.x86_64 5.1.12-2.module_el8.2.0+313+b04d0a66 appstream
php-pecl-zip.x86_64 1.15.3-1.module_el8.2.0+313+b04d0a66 appstream
php-pgsql.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-process.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-recode.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-snmp.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-soap.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-xml.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-xmlrpc.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
php-xmpphp.noarch 0.1-0.23.rc2.r77.el8 epel
python-calcephpy-doc.noarch 3.4.7-2.el8 epel
python3-calcephpy.x86_64 3.4.7-2.el8 epel
sphinx-php.x86_64 2.2.11-15.el8 epel
安装一下所有与php相关的包
[root@localhost ~]# dnf -y install php*
查看一下版本号
[root@localhost ~]# php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
[root@localhost ~]# ls /etc/php.ini
/etc/php.ini
//有这个文件。
有这个状态
[root@localhost ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset:>
Active: inactive (dead)
[root@localhost ~]# ls /etc/php
php.d/ php-fpm.conf php-fpm.d/ php.ini
[root@localhost ~]# ls /etc/php-fpm.d/
www.conf
启动php
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset:>
Active: active (running) since Wed 2021-05-12 09:49:46 EDT; 13s ago
Main PID: 768897 (php-fpm)
Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 6 (limit: 11070)
Memory: 33.8M
CGroup: /system.slice/php-fpm.service
├─768897 php-fpm: master process (/etc/php-fpm.conf)
├─768898 php-fpm: pool www
├─768899 php-fpm: pool www
├─768900 php-fpm: pool www
├─768901 php-fpm: pool www
└─768902 php-fpm: pool www
5月 12 09:49:45 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process M>
5月 12 09:49:46 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Ma>
[root@localhost ~]# systemctl enable php-fpm //开机自启
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
这里发现端口没有起来
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
查看这里有这个文件
[root@localhost ~]# cd /run
[root@localhost run]# cd php-fpm
[root@localhost php-fpm]# ls
php-fpm.pid www.sock
//找到这两行
; Note: This value is mandatory.
;listen = /run/php-fpm/www.sock //复制这一行,并加上注释:;
listen = 0.0.0.0:9000 //修改为此行
再次重启php,会发现9000端口起来了
[root@localhost ~]# systemctl restart php-fpm
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
把这两行的注释取消掉
[root@localhost ~]# vim /etc/httpd24/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
创建一个网站存放的地方,并写入一个php源,调用php函数,查看php页面
配置虚拟主机
[root@localhost ~]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# mkdir zdj
[root@localhost htdocs]# cd zdj
[root@localhost zdj]# vim index.php
<?php
phpinfo();
?>
更改属主组
[root@localhost zdj]# chown -R apache.apache /usr/local/apache/htdocs/
[root@localhost htdocs]# ll
总用量 4
-rw-r--r--. 1 apache apache 45 6月 11 2007 index.html
drwxr-sr-x. 2 apache apache 23 5月 12 10:09 zdj
[root@localhost httpd24]# vim httpd.conf
Include /etc/httpd24/extra/vhosts.conf
在此目录下面编写配置文件
[root@localhost extra]# vim vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zdj"
ServerName localhost:80
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zdj/$1
<Directory "/usr/local/apache/htdocs/zdj">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@localhost ~]# vim /etc/httpd24/httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
加入下面两行
添加一个index.php
[root@localhost ~]# vim /etc/httpd24/httpd.conf
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
重启apache
这里重启不行,需要杀进程
[root@localhost ~]# pkill httpd
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
[root@localhost ~]# apachectl start
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
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
测试
lamp搭建成功
lamp分离部署
环境:
centos8 192.168.98.33 apache
centos8 192.168.98.77 mysql
centos8 192.168.98.99 php
首先关闭三台主机的防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
33安装apache
[root@localhost apr-1.7.0]# yum install -y openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
[root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1.tar.bz2 initial-setup-ks.cfg
apr-1.7.0.tar.bz2 httpd-2.4.43.tar.bz2
解压
[root@localhost ~]# tar xf apr-1.7.0.tar.bz2
[root@localhost ~]# tar xf apr-util-1.6.1.tar.bz2
[root@localhost ~]# tar xf httpd-2.4.43.tar.bz2
[root@localhost apr-1.7.0]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
把这行删掉
cat <<_LT_EOF >> "$cfgfile"
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# cd ../apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make & make install
[root@localhost apr-util-1.6.1]# cd ../httpd-2.4.43/
[root@localhost httpd-2.4.43]# ./configure --prefix=/usr/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
[root@localhost httpd-2.4.43]# make & make install
编写环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin/:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]source /etc/profile.d/httpd.sh
[root@localhost ~]# apachectl start
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
在88上安装mysql
首先把压缩包拖进来
,解压,更改属主组
[root@localhost ~]# ls
公共 图片 音乐 initial-setup-ks.cfg
模板 文档 桌面 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
视频 下载 anaconda-ks.cfg
[root@localhost ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin games lib libexec sbin src
etc include lib64 mysql-5.7.33-linux-glibc2.12-x86_64 share
[root@localhost local]# mv mysql-5.7.33-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# chown -R mysql.mysql mysql/
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 5月 18 2020 bin
drwxr-xr-x. 2 root root 6 5月 18 2020 etc
drwxr-xr-x. 2 root root 6 5月 18 2020 games
drwxr-xr-x. 2 root root 6 5月 18 2020 include
drwxr-xr-x. 2 root root 6 5月 18 2020 lib
drwxr-xr-x. 3 root root 17 5月 3 15:12 lib64
drwxr-xr-x. 2 root root 6 5月 18 2020 libexec
drwxr-xr-x. 9 mysql mysql 129 5月 12 15:23 mysql
drwxr-xr-x. 2 root root 6 5月 18 2020 sbin
drwxr-xr-x. 5 root root 49 5月 3 15:12 share
drwxr-xr-x. 2 root root 6 5月 18 2020 src
编写环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
[root@localhost ~]# source /etc/profile.d/mysql.sh
创建目录并初始化
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2021-05-12T19:28:08.332416Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-12T19:28:08.754087Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-12T19:28:08.796217Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-12T19:28:08.802728Z 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: 2ec40ffc-b358-11eb-a763-000c29486c24.
2021-05-12T19:28:08.803424Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-12T19:28:09.107962Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-12T19:28:09.381815Z 1 [Note] A temporary password is generated for root@localhost: grIse0tS6k!A
[root@localhost ~]# echo 'grIse0tS6k!A' > zdj
生成配置文件
[root@localhost ~]# 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@localhost ~]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost ~]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@localhost ~]# ldconfig
[root@localhost ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/opt/data
重启
[root@localhost ~]# service mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
开机自启
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig --list
设置登录密码
set password = password(ZHANGde12+Jun);
安装php
[root@localhost ~]#yum install -y php*
启动
[root@localhost ~]# vim /etc/php-fpm.d/www.conf
; Note: This value is mandatory.
;listen = /run/php-fpm/www.sock
listen = 0.0.0.0:9000
添加这一行
;listen.allowed_clients = 127.0.0.1
加上注释
[root@localhost ~]# mkdir -p /data/php
[root@localhost ~]# vim /data/php/index.php
<?php
phpinfo
?>