Redhat 7.3 离线安装apache2.4.6+php5.4.16+mysql5.7

离线安装apache2.4.6
可以检查一下环境自带了哪些没有安装的包 yum install available,
那些是已经安装的yum install installed ,可以发现没有httpd的包,那是因为有些环境的yum源当中没有httpd,所以需要自己装。可以检查一下自带了哪些没有安装的包 yum install available。哪些是已经安装的yum install installed ,可以发现没有httpd的包,那是因为总行云平台的yum源当中没有httpd,所以需要自己装。
注意:在测试环境22.56.50.191因为安装系统的时候已经顺便选择了PHP开发环境,测试环境的httpd2.4.6和php5.4.16都是已经预装好的,所以在测试环境不需要单独离线安装httpd2.4.6和php5.4.16了。
首先准备下面四个离线安装包(注意版本号不能错!)。(虽然总行云平台自带的yum源里面有这三个软件包,但是yum install 这三个安装包之后,在离线安装apache2.4.6依然报错提示没有这些包,所以最好是离线安装—-如果不信可以自己试试。)
apr-1.4.8.tar.gz,
apr-util-1.5.2.tar.gz;
pcre-8.33.tar.gz
httpd-2.4.6.tar.gz
将这三个离线包放在/home/jzcz目录下。

tar -zxvf apr-1.4.8.tar.gz

cd apr-1.4.8

./configure --prefix=/usr/local/apr

make && make install

tar -zxvf apr-util-1.5.2.tar.gz

cd apr-util-1.5.2

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

make && make install

tar -zxvf pcre-8.32.tar.gz

cd pcre-8.32

./configure --prefix=/usr/local/pcre

make && make install

tar -zxvf httpd-2.4.6.tar.gz

cd httpd-2.4.6

./configure --prefix=/usr/local/apache --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/ --enable-ssl --enable-deflate --enable-expires --with-mpm=event

make && make install

–prefix=/usr/local/apache:apache安装路径

–enable-rewrite:支持网站地址重写

–enable-so:支持动态加载模块

–with-apr=/usr/local/apr:apache可移植库的路径

–enable-ssl:支持ssl加密

–enable-deflate:支持传输前进行压缩

–enable-expires:支持设置页面缓存时间

–with-mpm=prefork:指定Apache的运行模式(本人的默认是event)

–enable-modeles=most(常用的模块)


执行安装命令之后,如果报错显示:
mod_deflate has been requested but can not build duo to prerequisite failures .
还需要yum install zlib-devel.安装一下就解决了!
继续执行
#./configure --prefix=/usr/local/apache --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/ --enable-ssl --enable-deflate --enable-expires --with-mpm=event

报错显示openssl 版本低,所以需要从yum更新!
这个是更新openssl
[root@localhost httpd-2.4.6]# yum install openssl openssl-devel

继续执行安装命令,执行完make && make install后显示如下,表示安装成功。

[root@localhost home]#cd /usr/local/apache

[root@localhost local]# cd apache
[root@localhost apache]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost apache]# cd bin
启动apache2.4.6
[root@localhost bin]# ./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

在浏览器输入本机ip地址,显示“It works”
表示安装成功。

下面配置环境变量可以使得httpd –v命令生效!!

4.3.2离线安装PHP5.4.16
安装依赖包:yum -y install glibc gcc perl pkgconfig curl-devel gd-devel libXpm-devel zlib-devel readline-devel libxml2-devel libjpeg-devel freetype-devel

准备好php5.4.16源码包php5.4.16.tar.gz

将该包传到/home/jzcz目录。
tar -zxxf php5.4.16.tar.gz
cd php5.4.16

./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --enable-fd-setsize=65535 --enable-fpm --disable-ipv6 --without-sqlite3 --without-pdo-sqlite --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop --enable-mbstring --enable-zip --enable-bcmath --enable-ftp --enable-soap --with-mhash --with-pcre-regex --with-pcre-dir --with-readline --with-zlib --with-curl --with-openssl --with-iconv --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-xpm-dir --enable-mysqlnd -with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
注意:增加一行-with-mysql=mysqlnd,否则phpinfo() 显示的信息里面找不到mysql,如果PHP连接数据库用的是老的写法mysql_connect就不会起作用,也就连接不上数据库了!现在都用的是mysqli_connect,安全性和性能更好,具体区别可以自己百度。
执行完命令之后,报错:

虽然我们已经yum -y install libXpm-devel但是依然报错
解决办法:
cd /usr/lib目录
ln -s /usr/lib64/libXpm.so
ln -s /usr/lib64/libXpm.so.4
ln -s /usr/lib64/libXpm.so.4.11.0
执行这三条命令,这个问题可以解决!
如果报错如下:

可以执行 yum install freetype-devel

如果报错png.not found,可以执行:yum install libpng libpng-devel
如果报错configure: error: Please reinstall readline - I cannot find readline.h
可以执行yum install readline-devel
然后执行:./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --enable-fd-setsize=65535 --enable-fpm --disable-ipv6 --without-sqlite3 --without-pdo-sqlite --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop --enable-mbstring --enable-zip --enable-bcmath --enable-ftp --enable-soap --with-mhash --with-pcre-regex --with-pcre-dir --with-readline --with-zlib --with-curl --with-openssl --with-iconv --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-xpm-dir --enable-mysqlnd -with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

然后执行 make & make install.

上面的报错make: *** [libphp5.la] Error 1
可以执行
yum install libtool libtool-ltdl-devel或者yum install libtool*

可以执行make clean ,清除一下,然后make

然后make install,效果如下图:

下面检查httpd是否能加载PHP模块

root@localhost php-5.4.16]# cd /usr/local/apache/bin
[root@localhost bin]# apachectl -M
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
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
php5_module (shared)
[root@localhost bin]#
说明存在php5_module模块!

cd /usr/local/apache/conf
vi httpd.conf
修改三处地方:
1.修改Require all denied为 Require all granted

AllowOverride none

Require all denied

Require all granted
2.在 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz 下面增加: AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 3.在index.html前增加index.php DirectoryIndex index.php index.html cd /usr/local/apache/htdocs 然后vi index.php 输入:<?php phpinfo(); ?>

然后重启httpd
cd /usr/local/httpd
[root@localhost bin]# ./apachectl stop
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 bin]# ./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 bin]#

可以检查下PHP的安装配置信息包含了mysql、mysqli等。
chmod –R 755 /usr/local/apache/htdocs
然后将jzcz.zip移动到 /usr/local/apache/htdocs 目录
unzip jzcz.zip
然后http://ip/jzcz/jzcz1.php就可以访问了

证明解析PHP成功!
然后访问软件出现空白页
解决办法
cd /etc/ php.ini
将off 变为On
display_errors = On
此时可以重启下
[root@localhost bin]# ./apachectl restart

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值