lamp架构部署 httpd编译、mysql二进制、php编译 网页访问效果
LAMP构建
文章目录
- LAMP构建
- @[toc]
- 1. 安装httpd
- 2. 安装mysql
- 3. 安装php
- 4. 配置apache
- 5. 验证
环境说明:
系统平台 | IP | 需要安装的服务 |
---|---|---|
centos8 redhat8 | 192.168.183.131 | httpd-2.4 mysql-5.7 php php-mysql |
lamp平台软件安装次序:
httpd --> mysql --> php
注意:php要求httpd使用prefork MPM
1. 安装httpd
//yum源配置
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed
100 2495 100 2495 0 0 7920 0 --:--:-- --:--:-- --:--:-- 7920
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
Failed to set locale, defaulting to C.UTF-8
······
Installed:epel-release-8-16.el8.noarch Complete!
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# ls
CentOS-Base.repo epel-testing-modular.repo epel.repo
epel-modular.repo epel-testing.repo
[root@localhost yum.repos.d]# cd
[root@localhost ~]# dnf clean all
Failed to set locale, defaulting to C.UTF-8
29 files removed
[root@localhost ~]# dnf makecache
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.aliyun.com 4.3 MB/s | 4.6 MB 00:01
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 66 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co 9.0 MB/s | 8.4 MB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 6.5 MB/s | 13 MB 00:01
Extra Packages for Enterprise Linux Modular 8 - 1.4 MB/s | 1.0 MB 00:00
Metadata cache created.
[root@localhost ~]#//安装依赖包
[root@localhost ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make wget --allowerasing
Failed to set locale, defaulting to C.UTF-8
······
Skipped:gcc-8.5.0-4.el8_5.x86_64 glibc-2.28-164.el8.x86_64 glibc-devel-2.28-164.el8.i686 glibc-devel-2.28-164.el8.x86_64 Complete!//创建apache服务的用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache//下载和安装apr、httpd以及apr-util
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
--2022-08-02 20:17:42-- https://downloads.apache.org/apr/apr-1.7.0.tar.gz
······[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
[root@localhost ~]# tar xf apr-1.7.0.tar.gz
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54.tar.gz
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# ls
CHANGES apr.dsp configure libapr.mak strings
CMakeLists.txt apr.dsw configure.in libapr.rc support
LICENSE apr.mak docs locks tables
Makefile.in apr.pc.in dso memory test
Makefile.win apr.spec emacs-mode misc threadproc
NOTICE atomic encoding mmap time
NWGNUmakefile build file_io network_io tools
README build-outputs.mk helpers passwd user
README.cmake build.conf include poll
apr-config.in buildconf libapr.dep random
apr.dep config.layout libapr.dsp shmem
[root@localhost apr-1.7.0]# vim configure
# $RM "$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]# make install
······
[root@localhost apr-1.7.0]# cd ../apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ls
CHANGES aprutil.dep configure.in libaprutil.mak
CMakeLists.txt aprutil.dsp crypto libaprutil.rc
LICENSE aprutil.dsw dbd memcache
Makefile.in aprutil.mak dbm misc
Makefile.win apu-config.in docs redis
NOTICE buckets encoding renames_pending
NWGNUmakefile build export_vars.sh.in strmatch
README build-outputs.mk hooks test
README.FREETDS build.conf include uri
README.cmake buildconf ldap xlate
apr-util.pc.in config.layout libaprutil.dep xml
apr-util.spec configure libaprutil.dsp[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
······
[root@localhost apr-util-1.6.1]# make install
······
[root@localhost apr-util-1.6.1]# cd
[root@localhost ~]# ls /usr/local/
apr apr-util bin etc games include lib lib64 libexec sbin share src//编译httpd
[root@localhost ~]# tar xf httpd-2.4.54.tar.gz
[root@localhost ~]# cd httpd-2.4.54
[root@localhost httpd-2.4.54]# ls
ABOUT_APACHE LICENSE VERSIONING docs modules
Apache-apr2.dsw Makefile.in acinclude.m4 emacs-style os
Apache.dsw Makefile.win ap.d httpd.dep server
BuildAll.dsp NOTICE apache_probes.d httpd.dsp srclib
BuildBin.dsp NWGNUmakefile build httpd.mak support
CHANGES README buildconf httpd.spec test
CMakeLists.txt README.CHANGES changes-entries include
INSTALL README.cmake config.layout libhttpd.dep
InstallBin.dsp README.platforms configure libhttpd.dsp
LAYOUT ROADMAP configure.in libhttpd.mak
[root@localhost httpd-2.4.54]# ./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
······
configure: summary of build options:Server Version: 2.4.54Install prefix: /usr/local/apacheC compiler: gccCFLAGS: -g -O2 -pthread CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE LDFLAGS: LIBS: C preprocessor: gcc -E[root@localhost httpd-2.4.54]# make
······
[root@localhost httpd-2.4.54]# make install
······//安装后配置
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
[root@localhost ~]# ls /usr/local/
apache apr-util etc include lib64 sbin src
apr bin games lib libexec share
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd
[root@localhost ~]# ls /usr/local/apache/
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/apache
[root@localhost ~]# vim /etc/man_db.conf
23 MANDATORY_MANPATH /usr/local/apache/man//写service文件方式启动apache
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vim httpd.service[Unit]
Description=web server daemon
Documentation=man:httpd(5)
After=network.target sshd-keygen.target[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/local/apache/bin/apachectl stop[Install]
WantedBy=multi-user.target
[root@localhost system]# cd
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl status httpd
� httpd.service - web server daemonLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor pres>Active: inactive (dead)Docs: man:httpd(5)
[root@localhost ~]# systemctl start 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 128 [::]:22 [::]:*
LISTEN 0 128 *:80 *:*
[root@localhost ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service 鈫� /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl status httpd
● httpd.service - web server daemonLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>Active: active (running) since Tue 2022-08-02 20:54:16 CST; 2min 1s agoDocs: man:httpd(5)Main PID: 173478 (httpd)Tasks: 82 (limit: 5748)Memory: 14.7MCGroup: /system.slice/httpd.service├─173478 /usr/local/apache/bin/httpd -k start├─173479 /usr/local/apache/bin/httpd -k start├─173480 /usr/local/apache/bin/httpd -k start└─173481 /usr/local/apache/bin/httpd -k startAug 02 20:54:16 localhost.localdomain systemd[1]: Starting web server daemon...
Aug 02 20:54:16 localhost.localdomain apachectl[173477]: AH00558: httpd: Could >
Aug 02 20:54:16 localhost.localdomain systemd[1]: Started web server daemon.
2. 安装mysql
//安装依赖包
[root@localhost ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
Failed to set locale, defaulting to C.UTF-8
······ncurses-devel-6.1-9.20180224.el8.x86_64 Complete!//创建用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql//下载二进制格式的mysql软件包
[root@localhost ~]# cd /usr/src
[root@localhost src]# ls
debug kernels mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz//解压至/usr/local/
[root@localhost src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
apache bin include libexec share
apr etc lib mysql-5.7.38-linux-glibc2.12-x86_64 src
apr-util games lib64 sbin
[root@localhost local]# mv mysql-5.7.38-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
total 0
drwxr-xr-x. 14 root root 164 Aug 2 20:43 apache
drwxr-xr-x. 6 root root 58 Aug 2 20:31 apr
drwxr-xr-x. 5 root root 43 Aug 2 20:35 apr-util
drwxr-xr-x. 2 root root 6 Jun 22 2021 bin
drwxr-xr-x. 2 root root 6 Jun 22 2021 etc
drwxr-xr-x. 2 root root 6 Jun 22 2021 games
drwxr-xr-x. 2 root root 6 Jun 22 2021 include
drwxr-xr-x. 2 root root 6 Jun 22 2021 lib
drwxr-xr-x. 3 root root 17 Jul 18 09:57 lib64
drwxr-xr-x. 2 root root 6 Jun 22 2021 libexec
drwxr-xr-x. 9 mysql mysql 129 Aug 2 21:12 mysql
drwxr-xr-x. 2 root root 6 Jun 22 2021 sbin
drwxr-xr-x. 5 root root 49 Jul 18 09:57 share
drwxr-xr-x. 2 root root 6 Jun 22 2021 src//添加环境变量
[root@localhost local]# ls mysql/
LICENSE README bin docs include lib man share support-files
[root@localhost local]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@localhost local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# vim /etc/man_db.confMANDATORY_MANPATH /usr/local/mysql/man[root@localhost local]# cd
[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 ~]# which mysql
/usr/local/mysql/bin/mysql//建立数据存放目录
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data//初始化数据库
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data
2022-08-02T13:22:55.305739Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T13:22:55.488895Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T13:22:55.516278Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T13:22:55.572894Z 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: 381ccbb3-1266-11ed-902d-000c29eef386.
2022-08-02T13:22:55.573570Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T13:22:55.777643Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T13:22:55.777654Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T13:22:55.778064Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T13:22:55.852699Z 1 [Note] A temporary password is generated for root@localhost: =<lUYR0pFjOj
[root@localhost ~]# echo '=<lUYR0pFjOj' > pass//卸载mariadb包,避免冲突
[root@localhost ~]# rpm -qa | grep mariadb
mariadb-connector-c-3.1.11-2.el8_3.x86_64
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
mariadb-devel-10.3.28-1.module_el8.3.0+757+d382997d.x86_64
mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64
[root@localhost ~]# dnf -y remove mariadb*
······//生成配置文件
[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 ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
LICENSE README bin docs include lib man share support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
magic mysql-log-rotate mysql.server mysqld_multi.server
[root@localhost support-files]# file mysql.server
mysql.server: POSIX shell script, ASCII text executable
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# vim /etc/init.d/mysqld46 basedir=/usr/local/mysql47 datadir=/opt/data
[root@localhost support-files]# chmod +x /etc/init.d/mysqld//启动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 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
[root@localhost ~]#
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off//登录mysql并修改密码
[root@localhost ~]# dnf install -y ncurses-compat-libs
Failed to set locale, defaulting to C.UTF-8
······
[root@localhost ~]# cat pass
=<lUYR0pFjOj
[root@localhost ~]# mysql -uroot -p'=<lUYR0pFjOj'
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 3
Server version: 5.7.38Copyright (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('123com');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> quit
Bye
[root@localhost ~]#//验证新密码登录
[root@localhost ~]# mysql -uroot -p123com
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 4
Server version: 5.7.38 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> quit;
Bye
3. 安装php
//下载php
[root@localhost ~]# wget https://www.php.net/distributions/php-7.4.30.tar.xz
--2022-08-02 21:55:54-- https://www.php.net/distributions/php-7.4.30.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: 10419136 (9.9M) [application/octet-stream]
Saving to: 'php-7.4.30.tar.xz'php-7.4.30.tar.xz 100%[===================>] 9.94M 1.67MB/s in 6.9s 2022-08-02 21:56:02 (1.44 MB/s) - 'php-7.4.30.tar.xz' saved [10419136/10419136][root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1 httpd-2.4.54.tar.gz
apr-1.7.0 apr-util-1.6.1.tar.gz pass
apr-1.7.0.tar.gz httpd-2.4.54 php-7.4.30.tar.xz
[root@localhost ~]# sha256sum php-7.4.30.tar.xz
ea72a34f32c67e79ac2da7dfe96177f3c451c3eefae5810ba13312ed398ba70d php-7.4.30.tar.xz//安装依赖包
[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-mysqlnd --allowerasing --skip-broken --nobest
······//编译安装php并安装所需依赖包
[root@localhost ~]# tar xf php-7.4.30.tar.xz
[root@localhost ~]# cd php-7.4.30
[root@localhost ~]# dnf -y install libsqlite3x-devel libxml2-devel libzip-devel
[root@localhost ~]# dnf -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
[root@localhost php-7.4.30]# ./configure --prefix=/usr/local/php7 \
> --with-config-file-path=/etc \
> --enable-fpm \
> --enable-inline-optimization \
> --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-json \
> --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
······
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+Thank you for using PHP.[root@localhost php-7.4.30]# make
······
Build complete.
Don't forget to run 'make test'.[root@localhost php-7.4.30]# make install
······//安装后配置
[root@localhost ~]# cd php-7.4.30
[root@localhost php-7.4.30]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhost php-7.4.30]# source /etc/profile.d/php7.sh
[root@localhost php-7.4.30]# which php
/usr/local/php7/bin/php
[root@localhost php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug 2 2022 22:44:01) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[root@localhost php-7.4.30]# //配置php-fpm
[root@localhost php-7.4.30]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@localhost php-7.4.30]# cd sapi/
[root@localhost sapi]# ls
apache2handler cgi cli embed fpm litespeed phpdbg
[root@localhost sapi]# cd fpm/
[root@localhost fpm]# ls
CREDITS init.d.php-fpm php-fpm.conf status.html.in
LICENSE init.d.php-fpm.in php-fpm.conf.in tests
Makefile.frag php-fpm php-fpm.service www.conf
config.m4 php-fpm.8 php-fpm.service.in www.conf.in
fpm php-fpm.8.in status.html
[root@localhost fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script, ASCII text executable
[root@localhost fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@localhost fpm]# chmod +x /etc/init.d/php-fpm
[root@localhost ~]# cd /usr/local/php7/
[root@localhost php7]# ls
bin etc include lib php sbin var
[root@localhost php7]# cd etc/
[root@localhost etc]# ls
pear.conf php-fpm.conf.default php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# ls
www.conf www.conf.default
[root@localhost php-fpm.d]# //启动php-fpm并设为开机自启
[root@localhost php-fpm.d]# service php-fpm start
Starting php-fpm done
[root@localhost php-fpm.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost php-fpm.d]# cd
[root@localhost ~]# chkconfig --add php-fpm
[root@localhost ~]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off//重启验证
[root@localhost ~]# reboot
[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 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
4. 配置apache
//启用httpd的相关模块
[root@localhost ~]# cd /usr/local/apache/conf/
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf120 LoadModule proxy_module modules/mod_proxy.so
124 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so //将此两行内容取消注释//创建虚拟主机目录并生成php测试页面
[root@localhost conf]# mkdir -p /usr/local/apache/htdocs/george
[root@localhost conf]# vim /usr/local/apache/htdocs/george/index.php<?phpphpinfo();
?>//在配置文件中加入内容
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
httpd-autoindex.conf httpd-languages.conf httpd-ssl.conf
httpd-dav.conf httpd-manual.conf httpd-userdir.conf
httpd-default.conf httpd-mpm.conf httpd-vhosts.conf
httpd-info.conf httpd-multilang-errordoc.conf proxy-html.conf
[root@localhost extra]# vim httpd-vhosts.conf23 <VirtualHost *:80>24 DocumentRoot "/usr/local/apache/htdocs/george"25 ServerName george.example.com26 ErrorLog "logs/george.example.com-error_log"27 CustomLog "logs/george.example.com-access_log" common28 ProxyRequests Off29 ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/george/$130 <Directory "/usr/local/apache/htdocs/george">31 Options none32 AllowOverride none33 Require all granted34 </Directory>35 </VirtualHost>[root@localhost extra]# cd ..
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf398 AddType application/x-compress .Z
399 AddType application/x-gzip .gz .tgz
400 AddType application/x-httpd-php .php //添加此两行配置
401 AddType application/x-httpd-php-source .phps489 Include conf/extra/httpd-vhosts.conf //取消此行注释261 DirectoryIndex index.php index.html //添加index.php//重启apache服务
[root@localhost conf]# systemctl restart httpd
[root@localhost conf]# systemctl status httpd
● httpd.service - web server daemonLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>Active: active (running) since Thu 2022-08-04 09:10:30 CST; 5s agoDocs: man:httpd(5)Process: 80199 ExecStop=/usr/local/apache/bin/apachectl stop (code=exited, st>Process: 80203 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, >Main PID: 80206 (httpd)Tasks: 82 (limit: 5748)Memory: 12.9MCGroup: /system.slice/httpd.service├─80206 /usr/local/apache/bin/httpd -k start├─80207 /usr/local/apache/bin/httpd -k start├─80208 /usr/local/apache/bin/httpd -k start└─80209 /usr/local/apache/bin/httpd -k startAug 04 09:10:30 localhost.localdomain systemd[1]: httpd.service: Succeeded.
Aug 04 09:10:30 localhost.localdomain systemd[1]: Stopped web server daemon.
Aug 04 09:10:30 localhost.localdomain systemd[1]: Starting web server daemon...
Aug 04 09:10:30 localhost.localdomain apachectl[80205]: AH00558: httpd: Could n>
Aug 04 09:10:30 localhost.localdomain systemd[1]: Started web server daemon.
[root@localhost conf]#
5. 验证
lamp架构部署 httpd编译、mysql二进制、php编译 网页访问效果相关推荐
- (十)RHEL系统之基于LAMP架构部署商城系统
基于LAMP架构部署商城系统 接上篇:(九)RHEL系统之linux自有服务 任务背景 小王经过一段时间学习,慢慢的了解到公司的一些业务架构,发现好几个项目不是LAMP架构就是Nginx+Tomcat ...
- 2019Linux系统教程189讲-08_基于LAMP架构部署商城系统
任务需求 1.任务具体要求 使用yum(dnf)工具一键部署LAMP环境 发布电商项目上线 ① 能够实现web界面注册会员账号 ② 能够实现web界面进行后台商品及会员的管理 2.项目选型 ㈠ PHP ...
- php动态网页简书,LAMP架构部署和动态网站环境的配置
本文属于原创,比较适合企业应用,具体详细的介绍可以参考<Linux就该这么学>里边教程的第20章,里面详细的介绍了LNMP架构,而我这里是介绍LAMP架构,LAMP.LNMP在企业都应用比 ...
- lamp架构-访问控制-禁止php解析、屏蔽curl命令访问
lamp架构-访问控制-禁止php解析 有的网站论坛开启了上传图片功能,导致******捆绑图片上传到服务器,通过访问php来提升服务器后台权限, 这里我们就需要将上传图片的目录禁止访问php文件,来 ...
- Linux LNMP源码架构部署 | Nginx服务 | Mysql服务 | php服务 | 论坛源码编译安装 | 超详细
| Nginx服务 | Mysql服务 | php服务 | 论坛源码编译安装 | ➤安装 Nginx 服务 ➤1.关闭防火墙和安全机制 ➤2.卸载自带的httpd服务 ➤3.安装依赖包 ➤4.创建运行 ...
- LNMP架构环境搭建之mysql源码编译安装
Mysql MySQL是一个开源的数据库,在互联网行业应用的很广泛,下面来记录一下从源码编译安装的步骤,当然,MySQL也有其他安装方式,比如,使用yum下载安装rpm包,或者二进制方式安装,如果机器 ...
- linux lamp架构部署,Centos7部署LAMP平台之架构之路
部署lamp平台搭建 一.源码安装lamp 1.安装apache [root@localhost ~]# yum -y install gcc* apr-devel apr-util-devel pc ...
- Linux系统使用LAMP架构部署Discuz论坛系统,简洁明了
话不多说,直接开搞. 下载并安装apache服务 启动Apache并设置为开机自启,配置防火墙,永久开启服务 测试apache页面是否正常 先查看是否已安装mysql-server包,若没有再下载my ...
- LAMP架构介绍、MySQL和MariaDB介绍、MySQL安装
2019独角兽企业重金招聘Python工程师标准>>> LAMP架构介绍 Linux+Apache+MySQL+PHP 就是在linux系统上安装httpd. mysql .PHP, ...
- 如何部署LAMP架构
LAMP平台的构成组件 一. linux操作系统LAMP架构的基础,Apache网站服务器:LAMP架构的前端,MySQL:LAPM架构后端,PHP/Per/Python网页编程语言:负责解析动态网页 ...
最新文章
- php留言板入门教程,一个php留言板实例详解(附源码下载)
- 小程序统一服务消息_[miniblog]小程序订阅消息踩坑记
- 开发奇淫巧技Tips(Android篇)
- ccf-csp #201909-2 小明种苹果(续)
- 数据结构和算法(02)---字符串(c++)
- 邯郸计算机三加二专大专学校,双辽中专学校有保障,32学校排名
- 博客七----tensorflow-gpu安装满满填坑
- 【新春特辑】发压岁钱、看贺岁片、AI写春联……华为云社区给大家拜年了
- jQuery html5Validate基于HTML5表单验证插件
- c#图片色阶调整、亮度调整
- 数值分析期末考试复习(逼近问题)
- 代码开源许可证 区别 Apache MIT GPL
- Linux中光驱对应的设备文件,Linux硬盘对应的设备文件
- 电商后台项目 + 源码
- Rhino在java中的用法
- 3DS MAX 基础知识 材质编辑器
- 搜狗AI走向产业改造:纵横捭阖术与录音笔的新声态
- 单盘黑群晖更换硬盘实操记录
- java 首字母大写方法
- REST ful风格