跳转到帖子
  • 游客您好,欢迎来到黑客世界论坛!您可以在这里进行注册。

    赤队小组-代号1949(原CHT攻防小组)在这个瞬息万变的网络时代,我们保持初心,创造最好的社区来共同交流网络技术。您可以在论坛获取黑客攻防技巧与知识,您也可以加入我们的Telegram交流群 共同实时探讨交流。论坛禁止各种广告,请注册用户查看我们的使用与隐私策略,谢谢您的配合。小组成员可以获取论坛隐藏内容!

    TheHackerWorld官方

推荐的帖子

目录
  • 安装httpd
  • 安装mysql
  • 安装php


安装httpd

下载依赖包
[root@localhost yum.repos.d]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
Last metadata expiration check: 0:00:52 ago on Tue 02 Aug 2022 08:28:45 PM CST.

Dependencies resolved.

 Package                Arch   Version                       Repo       Size

Installing:
 expat-devel            x86_64 2.2.5-4.el8                   base       55 k
 gcc                    x86_64 8.5.0-4.el8_5                 AppStream  23 M
 gcc-c++                x86_64 8.5.0-4.el8_5                 AppStream  12 M
 libtool                x86_64 2.4.6-25.el8                  AppStream 709 k
 openssl-devel          x86_64 1:1.1.1k-5.el8_5              base      2.3 M
 pcre-devel             x86_64 8.42-6.el8                    base      551 k
Upgrading:

.......

  pkgconf-m4-1.4.2-1.el8.noarch                                              
  pkgconf-pkg-config-1.4.2-1.el8.x86_64                                      
  zlib-devel-1.2.11-17.el8.x86_64                                            

Complete!

解压

[root@localhost local]# tar xf apr-1.7.0.tar.gz 
[root@localhost local]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost local]# ls
apr-1.7.0              include
apr-1.7.0.tar.gz       lib
apr-util-1.6.1         lib64
apr-util-1.6.1.tar.gz  libexec
bin                    mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz
etc                    sbin
games                  share
httpd-2.4.54.tar.gz    src

编译三部曲

[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

[root@localhost apr-1.7.0]# make && make install
make[1]: Entering directory '/usr/local/apr-1.7.0'
/bin/sh /usr/local/apr-1.7.0/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/usr/local/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/usr/local/apr-1.7.0/include/arch/unix -I/usr/local/apr-1.7.0/include -I/usr/local/apr-1.7.0/include/private -I/usr/local/apr-1.7.0/include/private  -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
/usr/local/apr-1.7.0/build/mkdir.sh tools
......
    /usr/bin/install -c -m 644 /usr/local/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

apr-util编译三部曲

[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
.....
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 && make install
make[1]: Entering directory '/usr/local/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/usr/local/apr-util-1.6.1/include -I/usr/local/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
......
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config

安装依赖包

[root@localhost ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
Last metadata expiration check: 0:33:46 ago on Tue 02 Aug 2022 10:39:40 PM CST.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.

Dependencies resolved.

 Package                    Arch   Version                  Repo       Size

Installing:
 cmake                      x86_64 3.20.2-4.el8             AppStream  12 M
 ......
   ncurses-c++-libs-6.1-9.20180224.el8.x86_64                                
  ncurses-devel-6.1-9.20180224.el8.x86_64                                   

Complete!

编译三部曲httpd

[root@localhost local]# tar xf httpd-2.4.54.tar.gz 
[root@localhost local]# cd httpd-2.4.54
[root@localhost httpd-2.4.54]# ./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
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
configure: 
.....
configure: summary of build options:

    Server Version: 2.4.54
    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 httpd-2.4.54]# make && make install
Making all in srclib
make[1]: Entering directory '/usr/local/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/local/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/usr/local/httpd-2.4.54/os'
Making all in unix
make[2]: Entering directory '/usr/local/httpd-2.4.54/os/unix'
make[3]: Entering directory '/usr/local/httpd-2.4.54/os/unix'
.................
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory '/usr/local/httpd-2.4.54'

//设置环境变量
[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 local]# vim /etc/man_db.conf
MANDATORY_MANPATH                       /usr/local/apache/man

启动apache

取消Servername前面的注释
[root@localhost local]# vim /etc/httpd24/httpd.conf
ServerName www.example.com:80
[root@localhost local]# apachectl start
[root@localhost local]# 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                  *:80                  *:*              
LISTEN  0       128               [::]:22               [::]:*  

安装mysql

[root@localhost ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
Last metadata expiration check: 0:39:29 ago on Tue 02 Aug 2022 10:39:40 PM CST.
Package ncurses-devel-6.1-9.20180224.el8.x86_64 is already installed.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package cmake-3.20.2-4.el8.x86_64 is already installed.
Package mariadb-devel-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost ~]# groupadd -r -g 306 mysql
[root@localhost ~]# useradd -rMs /sbin/nologin -g 306 -u 306 mysql
[root@localhost local]# tar xf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz 
[root@localhost local]# ln -s mysql-5.7.39-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Aug  2 23:28 /usr/local/mysql -> mysql-5.7.39-linux-glibc2.12-x86_64/
设置环境变量
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh 
[root@localhost local]# ln -s /usr/local/mysql/include/ /usr/include/mysql/
[root@localhost local]# vim /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# cat /etc/ld.so.conf.d/mysql.conf 
/usr/local/mysql/lib
[root@localhost local]# ldconfig 
[root@localhost local]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/local/mysql/man
建立存放目录
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Aug  2 23:34 data
初始化
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2022-08-02T15:37:36.145176Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T15:37:36.317700Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T15:37:36.348292Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T15:37:36.410237Z 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: 08aab86a-1279-11ed-9071-000c291857bd.
2022-08-02T15:37:36.410895Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T15:37:36.637865Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T15:37:36.637879Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T15:37:36.638290Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T15:37:36.664064Z 1 [Note] A temporary password is generated for root@localhost: Njutr7qPgk?8

生成配置文件
[root@localhost etc]# vim/etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[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 etc]# cd /usr/local/mysql
[root@localhost mysql]# ls
bin  data  docs  include  lib  LICENSE  man  README  share  support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysqld
datadir=/opt/data
[root@localhost support-files]# chmod +x /etc/init.d/mysqld
启动mysql
[root@localhost support-files]# service mysql start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
 SUCCESS! 
使用临时密码进入mysql
[root@localhost ~]# 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.39

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> 
设置新密码
mysql> set password = password('liuyang123!');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye
[root@localhost ~]# 


安装php

//安装依赖包
[root@localhost src]# 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
Extra Packages for Enterprise Linux 7 - x86_  32 kB/s | 4.7 kB     00:00    
Package libxml2-2.9.7-9.el8.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
..........
  readline-devel-7.0-10.el8.x86_64                                           
  xz-devel-5.2.4-3.el8.x86_64                                                
  zlib-1.2.11-17.el8.i686                                                    

Complete!
编译安装
./configure --prefix=/usr/local/php \
 --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
[root@localhost php-7.4.30]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
/bin/sh /usr/src/php-7.4.30/libtool --silent --preserve-dup-deps --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/opcache/ -I/usr/src/php-7.4.30/ext/opcache/ -DPHP_ATOM_INC -I/usr/src/php-7.4.30/include -I/usr/src/php-7.4.30/main -I/usr/src/php-7.4.30 -I/usr/src/php-7.4.30/ext/date/lib -I/usr/include/libxml2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/src/php-7.4.30/ext/mbstring/libmbfl -I/usr/src/php-7.4.30/ext/mbstring/libmbfl/mbfl -I/usr/src/php-7.4.30/TSRM -I/usr/src/php-7.4.30/Zend    -I/usr/include -g -O2 -fvisibility=hidden -Wall -Wno-strict-aliasing -DZEND_SIGNALS    -c /usr/src/php-7.4.30/ext/opcache/ZendAccelerator.c -o ext/opcache/ZendAccelerator.lo 
/bin/sh /usr/src/php-7.4.30/libtool --silent --preserve-dup-deps --mode=compi
.......
pharcommand.inc
invertedregexiterator.inc
directorytreeiterator.inc
directorygraphiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.
[root@localhost php-7.4.30]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM defconfig:     /usr/local/php/etc/
.....
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/src/php-7.4.30/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin/phar.phar
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
[root@localhost php-7.4.30]# 
安装后配置
[root@localhost php]# echo 'export PATH=/usr/local/php/bin:$PATH' > /etc/profile.d/php.sh
[root@localhost php]# source /etc/profile.d/php.sh 
[root@localhost php-7.4.30]# which php
/usr/local/php/bin/php
[root@localhost php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug  3 2022 02:30:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[root@localhost php]# vim /etc/ld.so.conf.d/php.conf
[root@localhost php]# cat /etc/ld.so.conf.d/php.conf
/usr/local/php/lib
[root@localhost php]# ln -s /usr/local/php/include/ /usr/include/php
[root@localhost system]# vim /lib/systemd/system/php.service
[Unit]
Description=php server daemon
After=network.target sshd-keygen.target
Wants=sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
ExecStop=ps -ef |grep php |grep -v grep|awk '{print$2}'|xargs kill -9
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
//配置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]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.4.30]# chmod +x /etc/rc.d/init.d/php-fpm 
[root@localhost php-7.4.30]#  cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp: overwrite '/usr/local/php/etc/php-fpm.d/www.conf'? y
//编辑php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
//配置fpm的相关选项为你所需要的值:
[root@localhost php-7.4.30]# vim /usr/local/php/etc/php-fpm.conf              
[root@localhost php-7.4.30]# cat /usr/local/php/etc/php-fpm.conf |tail -4
pm.max_children=50 最多同时提供50个进程提供50个并发服务
pm.start_servers=5 启动时启动5个进程
pm.min_spare_servers=2 最小空闲进程数
pm.max_spare_servers=8 最大空闲进程数
[root@localhost ~]# tail /usr/local/php/etc/php-fpm.conf
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/php otherwise
include=/usr/local/php/etc/php-fpm.d/*.conf
pm.max_children=50
pm.start_servers=5
pm.min_spare_servers=2
pm.max_spare_servers=8

启动服务并且开机自启
[root@localhost ~]# systemctl  daemon-reload
[root@localhost ~]# systemctl  start php.service
[root@localhost ~]# systemctl  enable php.service
Created symlink /etc/systemd/system/multi-user.target.wants/php.service → /usr/lib/systemd/system/php.service.
查看服务状态
[root@localhost ~]# systemctl  status php.service
● php.service - php server daemon
   Loaded: loaded (/usr/lib/systemd/system/php.service; enabled; vendor pres>
   Active: active (running) since Wed 2022-08-03 02:46:26 CST; 48s ago
 Main PID: 247521 (php-fpm)
    Tasks: 3 (limit: 4743)
   Memory: 25.5M
   CGroup: /system.slice/php.service
           ├─247521 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
           ├─247522 php-fpm: pool www
           └─247523 php-fpm: pool www

Aug 03 02:46:26 localhost.localdomain systemd[1]: Starting php server daemon>
Aug 03 02:46:26 localhost.localdomain systemd[1]: Started php server daemon.
查看端口信息
[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                *:* 
链接帖子
意见的链接
分享到其他网站

黑客攻防讨论组

黑客攻防讨论组

    You don't have permission to chat.
    • 最近浏览   0位会员

      • 没有会员查看此页面。
    ×
    ×
    • 创建新的...