Web服务基础六之编译安装配置RHEL+Apache+MySQL+PHP+ZendOptimize

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

一、准备工作

1、开启80、3306端口,关闭selinux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@justin ~] # vim /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@justin ~] # sestatus
SELinux status:                 disabled
[root@justin ~] # /etc/init.d/iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@justin ~] #

2、下载软件包

软件源代码包存放位置:/usr/local/src          源码包编译安装位置:/usr/local/软件名字

a、下载apache

1
2
[root@justin ~] # cd /usr/local/src/
[root@justin src] # wget http://www.apache.org/dist/httpd/httpd-2.4.7.tar.gz

b、下载MySQL

http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz

c、下载php

http://cn2.php.net/distributions/php-5.4.25.tar.gz

d、下载libmcrypt(PHPlibmcrypt模块)

ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

e、下载apr(Apache库文件)

http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz

f、下载apr-util(Apache库文件)

http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.3.tar.gz

g、下载Zend Guard(PHP加速软件)

http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz

h、下载cmake(MySQL编译工具)

http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

1
2
3
4
5
[root@justin src] # ls
apr-1.5.0. tar .gz  libmcrypt-2.5.7. tar .gz  ZendGuardLoader-php-5.3-linux-glibc23-i386. tar .gz        cmake-2.8.12.2. tar .gz
apr-util-1.5.3. tar .gz      mysql-5.5.36. tar .gz
httpd-2.4.7. tar .gz         php-5.4.25. tar .gz
[root@justin src] #

二、安装

a、安装编译工具及库文件

1
yum  install  make  apr* autoconf automake gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch -y

b、安装libmcrypt

1
2
3
4
[root@justin src] # tar zxvf libmcrypt-2.5.7.tar.gz
[root@justin src] # cd libmcrypt-2.5.7
[root@justin libmcrypt-2.5.7] # ./configure
[root@justin libmcrypt-2.5.7] # make && make install

c、安装cmake

1
2
3
4
[root@justin src] # tar zxvf cmake-2.8.12.2.tar.gz
[root@justin src] # cd cmake-2.8.12.2
[root@justin cmake-2.8.12.2] # ./configure
[root@justin cmake-2.8.12.2] # make && make install

d、安装apr

1
2
3
4
[root@justin src] # tar zxvf apr-1.5.0.tar.gz
[root@justin src] # cd apr-1.5.0
[root@justin apr-1.5.0] # ./configure
[root@justin apr-1.5.0] # make && make install

e、安装apr-util

1
2
3
4
5
[root@justin src] # tar zxvf apr-util-1.5.3.tar.gz
[root@justin src] # cd apr-util-1.5.3
[root@justin apr-util-1.5.3] # mkdir -p /usr/local/apr-util
[root@justin apr-util-1.5.3] # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@justin apr-util-1.5.3] # make && make installl

f、安装mysql

1
2
3
4
5
6
7
8
9
10
11
12
[root@justin apr-util-1.5.3] # cd ..
[root@justin src] # groupadd mysql
[root@justin src] # useradd -g mysql mysql -s /sbin/nologin  --禁止登陆
[root@justin src] # mkdir -p /data/mysql   --mysql数据库目录
[root@justin src] # chown -R mysql:mysql /data/mysql/
[root@justin src] # mkdir -p /usr/local/mysql  --mysql安装目录
[root@justin src] # tar zxvf mysql-5.5.36.tar.gz
[root@justin mysql-5.5.36] # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/data/mysql  -DSYSCONFDIR=/etc
-- Could NOT  find  Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake /readline .cmake:83 (MESSAGE):
   Curses library not found.  Please  install  appropriate package,
       remove CMakeCache.txt and rerun cmake.On Debian /Ubuntu , package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

出错了,提示RHEL平台安装ncurses-devel并删除CMakeCache.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@justin mysql-5.5.36] # yum install -y ncurses-devel
[root@justin mysql-5.5.36] # rm -f CMakeCache.txt
[root@justin mysql-5.5.36] # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/data/mysql  -DSYSCONFDIR=/etc
[root@justin mysql-5.5.36] # make && make install
[root@justin mysql-5.5.36] # cd /usr/local/mysql/
[root@justin mysql] # cp ./support-files/my-huge.cnf /etc/my.cnf
cp : overwrite ` /etc/my .cnf'? y
[root@justin mysql] # vim /etc/my.cnf
[mysqld]     ---该部分下
port            = 3306
socket          =  /tmp/mysql .sock
skip-external-locking
datadir =  /data/mysql    ---添加此行,指定数据库路径
[root@justin mysql] # ./scripts/mysql_install_db --user=mysql  --生成mysql系统数据库
[root@justin mysql] # cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld  --把Mysql加入系统启动
[root@justin mysql] # chmod 755 /etc/init.d/mysqld
[root@justin mysql] # chkconfig mysqld on
[root@justin mysql] # vim /etc/rc.d/init.d/mysqld
  46 basedir= /usr/local/mysql
  47 datadir= /data/mysql
[root@justin mysql] # /etc/init.d/mysqld start
Starting MySQL......                                       [  OK  ]
[root@justin mysql] # vim /etc/profile  --把mysql服务加入系统环境变量
export  PATH=$PATH: /usr/local/mysql/bin  --文末添加该行
[root@justin mysql] # ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
[root@justin mysql] # ln -s /usr/local/mysql/include/mysql /usr/include/mysql  --把myslq的库文件链接到系统默认的位置,在编译类似PHP等软件时可以不用指定mysql的库文件地址
[root@justin mysql] # mysql_secure_installation
- bash : mysql_secure_installation:  command  not found  --需要先重启系统
[root@justin mysql] # init 6
[root@justin ~] # mysql_secure_installation
[root@justin ~] # service mysqld restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL...                                          [  OK  ]
[root@justin ~] #

g、安装apache

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@justin src] # cd /usr/local/src/
[root@justin src] # tar zxvf httpd-2.4.7.tar.gz
[root@justin src] # cd httpd-2.4.7
[root@justin httpd-2.4.7] # mkdir -p /usr/local/apache
[root@justin httpd-2.4.7] # ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-module=so --enable-rewrite --enable-cgid --enable-cgi
[root@justin httpd-2.4.7] # make && make install
[root@justin httpd-2.4.7] # /usr/local/apache/bin/apachectl -k start
[root@justin httpd-2.4.7] # vim /usr/local/apache/conf/httpd.conf
191 ServerName localhost
249     DirectoryIndex index.html index.php
229     Options FollowSymLinks   --不显示目录结构
236     AllowOverride All  ---开启apache支持伪静态
349     AllowOverride All
199     AllowOverride All
149 LoadModule rewrite_module modules /mod_rewrite .so  --开启apache支持伪静态
[root@justin httpd-2.4.7] # vi /etc/profile  --添加apache服务系统环境变量
export  PATH=$PATH: /usr/local/apache/bin   --最后添加下面这一行
[root@justin httpd-2.4.7] # cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
cp : overwrite ` /etc/rc .d /init .d /httpd '? y
[root@justin httpd-2.4.7] # vim /etc/init.d/httpd
#!/bin/sh   --添加以下两行
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
[root@justin httpd-2.4.7] # chown daemon.daemon -R /usr/local/apache/htdocs
[root@justin httpd-2.4.7] # chmod 700 !$
chmod  700  /usr/local/apache/htdocs
[root@justin httpd-2.4.7] # chkconfig httpd on
[root@justin httpd-2.4.7] # /etc/init.d/httpd start

h、安装PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@justin src] # tar zxvf php-5.4.25.tar.gz
[root@justin src] # cd php-5.4.25
[root@justin php-5.4.25] # mkdir -p /usr/local/php
[root@justin php-5.4.25] # ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs  --with-mysql=/usr/local/mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd  --with-iconv --with-freetype --with-jpeg --with-png --with-zlib --with-libxml --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt
[root@justin php-5.4.25] # make && make install
[root@justin php-5.4.25] # cp php.ini-production /usr/local/php/etc/php.ini  --复制php配置文件到安装目录
[root@justin php-5.4.25] # rm -rf /etc/php.ini --删除系统自带的配置文件
[root@justin php-5.4.25] # ln -s /usr/local/php/etc/php.ini /etc/php.ini  --创建配置文件软链接
[root@justin php-5.4.25] # vim /usr/local/php/etc/php.ini
309 open_basedir = .: /tmp/
  315 disable_functions = passthru, exec ,system,chroot,scandir, chgrp , chown ,shell_exec,proc_open,proc_get_     status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink, symlink ,popepassthru,stream_sock     et_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbypo     rt,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,p     osix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getp     grp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix     _getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setp     gid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname  --列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用
  919  date .timezone = PRC
  376 expose_php = OFF  --禁止显示php版本的信息
  479 display_errors = OFF  --关闭错误提示

i、安装Zend Guard

1
2
3
4
5
[root@justin php-5.4.25] # cd ..
[root@justin src] # mkdir /usr/local/zend
[root@justin src] # tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
[root@justin src] # cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/  --拷贝文件到安装目录
[root@justin src] #

j、配置PHP支持Zend Guard

1
2
3
4
5
6
7
[root@justin src] # vim /usr/local/php/etc/php.ini  --文末添加以下
[Zend Guard]
zend_extension= /usr/local/zend/ZendGuardLoader .so
zend_loader. enable =1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=

k、配置Apache支持PHP

1
2
3
4
5
[root@justin src] # vim /usr/local/apache/conf/httpd.conf
150 LoadModule php5_module        modules /libphp5 .so --此行后面添加以下行
151 AddType application /x-httpd-php  .php  --php .php这个点前面有一个空格
[root@justin src] # service httpd restart
[root@justin src] # service mysqld restart

三、测试

1
2
3
4
5
6
[root@justin src] # cd /usr/local/apache/htdocs/
[root@justin htdocs] # vim index.php  --添加以下内容
<?php
phpinfo();
?>
[root@justin htdocs] # mv index.html index.htmlbak

在浏览器里输入IP地址就可以访问到相关配置信息

网站程序上传到/usr/local/apache/htdocs/目录中,遇到安装问题,检查权限

1
2
[root@justin htdocs] # chown daemon.daemon -R /usr/local/apache/htdocs/
[root@justin htdocs] # chmod 700 -R /usr/local/apache/htdocs/

至此RHEL+Apache+MySQL+PHP+ZendOptimize配置完成



本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1360472,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
265
分享
相关文章
|
2月前
|
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
92 20
【01】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-硬件设备实时监控系统运营版发布-本产品基于企业级开源项目Zabbix深度二开-分步骤实现预计10篇合集-自营版
【01】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-硬件设备实时监控系统运营版发布-本产品基于企业级开源项目Zabbix深度二开-分步骤实现预计10篇合集-自营版
39 0
php中配置variables_order详解
`variables_order` 是 PHP 配置中的一个关键指令,它决定了不同来源的变量被导入到全局变量空间的顺序。正确配置 `variables_order` 不仅可以确保变量的正确处理和覆盖顺序,还能提高应用程序的安全性。开发者应根据具体应用的需求,合理配置 `variables_order`,确保应用的稳定和安全运行。
66 5
PHP与Ajax在Web开发中的交互技术。PHP作为服务器端脚本语言,处理数据和业务逻辑
本文深入探讨了PHP与Ajax在Web开发中的交互技术。PHP作为服务器端脚本语言,处理数据和业务逻辑;Ajax则通过异步请求实现页面无刷新更新。文中详细介绍了两者的工作原理、数据传输格式选择、具体实现方法及实际应用案例,如实时数据更新、表单验证与提交、动态加载内容等。同时,针对跨域问题、数据安全与性能优化提出了建议。总结指出,PHP与Ajax的结合能显著提升Web应用的效率和用户体验。
112 3
PHP与现代Web开发:构建高效的网络应用
【10月更文挑战第37天】在数字化时代,PHP作为一门强大的服务器端脚本语言,持续影响着Web开发的面貌。本文将深入探讨PHP在现代Web开发中的角色,包括其核心优势、面临的挑战以及如何利用PHP构建高效、安全的网络应用。通过具体代码示例和最佳实践的分享,旨在为开发者提供实用指南,帮助他们在不断变化的技术环境中保持竞争力。
深入浅出PHP:构建你的第一个Web应用
【10月更文挑战第35天】在数字时代的浪潮中,掌握编程技能已成为通往未来的钥匙。本文将带你从零开始,一步步走进PHP的世界,解锁创建动态网页的魔法。通过浅显易懂的语言和实际代码示例,我们将共同打造一个简单但功能强大的Web应用。无论你是编程新手还是希望扩展技能的老手,这篇文章都将是你的理想选择。让我们一起探索PHP的魅力,开启你的编程之旅!
PHP在Apache中如何运行?
PHP在Apache中如何运行?
163 5
|
5月前
|
优化 PHP-FPM 参数配置:实现服务器性能提升
优化PHP-FPM的参数配置可以显著提高服务器的性能和稳定性。通过合理设置 `pm.max_children`、`pm.start_servers`、`pm.min_spare_servers`、`pm.max_spare_servers`和 `pm.max_requests`等参数,并结合监控和调优措施,可以有效应对高并发和负载波动,确保Web应用程序的高效运行。希望本文提供的优化建议和配置示例能够帮助您实现服务器性能的提升。
202 3
|
5月前
|
探索PHP的现代演进:从Web开发到框架创新
PHP是一种流行的服务器端脚本语言,自诞生以来在Web开发领域占据重要地位。从简单的网页脚本到支持面向对象编程的现代语言,PHP经历了多次重大更新。本文探讨PHP的现代演进历程,重点介绍其在Web开发中的应用及框架创新,如Laravel、Symfony等。这些框架不仅简化了开发流程,还提高了开发效率和安全性。
56 3
|
5月前
|
探索PHP的现代演进:从Web开发到框架创新
PHP 自发布以来一直在 Web 开发领域占据重要地位,历经多次重大更新,从简单的脚本语言进化为支持面向对象编程的现代语言。本文探讨 PHP 的演进历程,重点介绍其在 Web 开发中的应用及框架创新。自 PHP 5.3 引入命名空间后,PHP 迈向了面向对象编程时代;PHP 7 通过优化内核大幅提升性能;PHP 8 更是带来了属性、刚性类型等新特性。
64 3

热门文章

最新文章

推荐镜像

更多