准备软件包:
httpd-2.4.28.tar.gz #Apache主程序包
apr-1.5.2.tar.gz #Apache依赖包
apr-util-1.5.4.tar.gz #Apache依赖包
pcre-8.41.tar.gz #Apache依赖包
php-7.2.30.tar.gz
mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
下载地址:
https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.gz
http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
http://archive.apache.org/dist/apr/apr-util-1.6.0.tar.gz
https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gz
上传源码包
1 安装依赖
yum -y install make gcc gcc-c++ openssl openssl-devel expat-devel
编辑安装依赖包apr
tar zxvf apr-1.6.2.tar.gz && cd apr-1.6.2
./configure --prefix=/usr/local/apr
make && make install
编辑安装依赖包apr-util
tar zxvf apr-util-1.6.0.tar.gz && cd apr-util-1.6.0
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make -j 8 && make -j 8 install
编辑安装pcre
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41/
./configure --prefix=/usr/local/pcre
make -j 8 && make -j 8 install
编译安装Apache
tar zxvf httpd-2.4.51.tar.gz -C /usr/local/src/
cd /usr/local/src/httpd-2.4.51
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make -j 8 && make -j 8 install
生成启动脚本
cp /usr/local/apache/bin/apachectl /etc/init.d/
chmod +x /etc/init.d/apachectl
写个apache系统服务脚本, 以754的权限保存此文件(可以使用命令systemctl命令)
vim /usr/lib/systemd/system/apache.service
[Unit]
Description=apache
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/apachectl start
ExecReload=/etc/init.d/apachectl restart
ExecStop=/etc/init.d/apachectl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动服务
systemctl start apache
systemctl enable apache
安装数据库(看下期)
略略略
安装php
安装依赖包
yum -y install epel-release
yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel re2c
解压php
tar zxf php-7.2.30.tar.gz -C /usr/local/src
cd /usr/local/src/php*
编辑安装
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd --with-pdo-mysql=mysqlnd --enable-zip --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/tmp/mysql.sock --without-pear --with-zlib=/usr --with-openssl
make -j 8 && make -j 8 install
生成配置文件
cp php.ini-production /usr/local/php/etc/php.ini
添加Apache支持
vim /usr/local/apache/conf/httpd.conf
#在文件最后添加这一行
Addtype application/x-httpd-php .php .phtml
添加测试页
cd /usr/local/apache/htdocs/
vim index.php
<?php
phpinfo();
?>
重启apache
systemctl restart apache
出现此界面部署成功