Bootstrap

源代码编译安装

准备编译环境

//下载安装各种包
[root@rocklinux1 ~]# yum -y install bzip2  vim make wget openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ libxml2-devel
[root@rocklinux1 ~]# yum -y install lrzsz tar

//创建进入目录
[root@rocklinux1 ~]# mkdir /opt/software
[root@rocklinux1 ~]# cd /opt/software/

安装httpd

1、配置安装apr-1.7.0

[root@rocklinux1 software]# ls
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz

//解压apr-1.7.0.tar.gz到当前目录
[root@rocklinux1 software]# tar -zxvf apr-1.7.0.tar.gz 

//进入apr-1.7.0.tar.gz目录,编辑configure文件,删除下面一行
$RM "$cfgfile"

//配置
[root@rocklinux1 apr-1.7.0]# ./configure --prefix=/usr/local/apr
--prefix=  //指定安装路径

//编译
[root@rocklinux1 apr-1.7.0]# make //只能在解压的目录编译

//编译安装
[root@node1 apr-1.7.0]# make install

2、配置安装apr-util-1.6.1

//解压apr-util-1.6.1.tar.gz到当前目录
[root@rocklinux1 software]# tar -zxvf apr-util-1.6.1.tar.gz

//配置
[root@rocklinux1 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr
--with  //与哪个相关联

//编译
[root@node1 apr-util-1.6.1]# make

//编译安装
[root@node1 apr-util-1.6.1]# make install

3、配置安装httpd-2.4.54

//解压httpd-2.4.54.tar.gz到当前目录
[root@node1 httpd-2.4.54]# tar -zxvf httpd-2.4.54.tar.gz 

// 配置
[root@node1 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

// 编译
[root@node1 httpd-2.4.54]# make 

// 编译安装
[root@node1 httpd-2.4.54]# make install 

//启动服务
[root@node1 apache]# /usr/local/apache/bin/apachectl start
 /usr/local/apache/htdocs 存放网页的位置
 /usr/local/apache/bin 	存放执行文件的位置


3、编写启动文件


[root@node1 support-files]# vim  /usr/lib/systemd/system/httpd.service
[Unit]
Description=mysql server daemon
After=network.targe

[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@node1 software]# useradd -r -M -s /sbin/nologin mysql
[root@node1 software]# id mysql
uid=997(mysql) gid=994(mysql) groups=994(mysql)

// 安装依赖包
[root@node1 software]# yum -y install libncurses*

// 解压 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@node1 software]# tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/

//给 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz 做个链接
[root@node1 local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64 mysql

//修改 MySQL 的所有者和所属组
[root@node1 local]# chown -R mysql.mysql /usr/local/mysql

//创建目录,并修改所有者和所属组
[root@node1 local]#  mkdir /opt/data -p
[root@node1 local]# chown -R mysql.mysql /opt/data/

//安装依赖包
[root@node1 mysql]# yum -y install libaio

//数据库初始化
[root@node1 mysql]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data/

//编译
[root@node1 mysql]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql			//数据库的位置
datadir = /opt/data					//指定MySQL将存储其数据文件的目录位置			
socket = /tmp/mysql.sock			//指针位置
port = 3306							//端口位置
pid-file = /opt/data/mysql.pid		
user = mysql						// 用户	
skip-name-resolve					// 跳过名字解析
EOF

// 编辑 mysql.server 文件
[root@node1 mysql]# cd support-files/
[root@node1 support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@node1 support-files]# vim mysql.server
basedir=/usr/local/mysql
datadir=/opt/data

//编写启动文件
[root@node1 support-files]# vim  /usr/lib/systemd/system/mysqld.service

[Unit]
Description=mysql server daemon
After=network.targe

[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

//重启mysql
[root@node1 local]# systemctl restart mysqld 
[root@node1 local]# systemctl enabled mysqld 

// 添加环境变量
[root@node1 support-files]# vim /etc/profile
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH  //添加在最后一行
[root@node1 support-files]# source /etc/profile

//设置MySQL密码
[root@node1 support-files]# mysql -uroot -e "set password=password('123456')"

//登录MySQL
[root@node1 mysql]# mysql -u root -p

安装PHP

// 安装依赖包
[root@node1 ~]# yum install -y wget gcc gcc-c++ autoconf automake libtool make libxml2 libxml2-devel openssl openssl-devel sqlite-devel libpng libpng-devel libpsl libpsl-devel libicu-devel libcurl-devel
[root@node1 ~]# yum install openldap openldap-devel  -y
[root@node1 ~]# cp -frp /usr/lib64/libldap* /usr/lib/
[root@node1 ~]# yum install oniguruma oniguruma-devel -y
[root@node1 ~]# yum --enablerepo=devel -y install oniguruma-devel

//配置
[root@node1 ~]# ./configure --prefix=/usr/local/php \
> --with-apxs2=/usr/local/apache/bin/apxs \
> --with-mysql-sock=/tmp/mysql.sock \
> --enable-fpm \
> --enable-mysqlnd \
> --enable-mysqlnd-compression-support \
> --with-zlib \
> --enable-xml \
> --disable-rpath \
> --enable-bcmath \
> --enable-shmop \
> --enable-sysvsem \
> --enable-mbregex \
> --enable-mbstring \
> --enable-intl \
> --enable-ftp \
> --enable-gd-jis-conv \
> --with-openssl \
> --with-mhash \
> --enable-pcntl \
> --enable-sockets \
> --enable-soap \
> --with-gettext \
> --enable-fileinfo \
> --enable-opcache \
> --with-pear \
> --with-ldap=shared \
> --without-gdbm \
> --with-curl \
> --enable-ctype \
> --without-pear  --disable-phar

// 编译
[root@node1 ~]# make

// 编译安装
[root@node1 ~]# make install

// 复制文件
[root@node1 php-8.2.5]#  cp php.ini-development /usr/local/php/lib/php.ini
php.ini-development  //模拟环境使用
php.ini-production   //真实环境使用

//修改文件php.ini设置时间 Asia/Shanghai
[root@node1 php-8.2.5]# vim  /usr/local/php/lib/php.ini
date.timezone = Asia/Shanghai   //修改时间为Asia/Shanghai

// 在apache文件中添加内容
[root@node1 php-8.2.5]# vim  /etc/httpd24/httpd.conf
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@node1 php-8.2.5]# vim /usr/local/apache/htdocs/index.php
<?php
        phpinfo();
?>

// 重启服务
[root@node1 php-8.2.5]# systemctl restart httpd
[root@node1 php-8.2.5]# systemctl enable httpd
;