linux下的apache2 + mysql5 + php4 + gd2 源码完整安装详解

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
1.安装mysql
 
小五注释:mysql的安装包实在是太多了,我在学习的时候,遇到最大的问题就是安装mysql的问题,后来才发现,原来是自己选择安装包不对,非常郁闷,为了避免其他朋友也遇到同样的问题,所以,我把本文所涉及的mysql安装包放到skydrive网盘上,这样,你就不会下载错了,希望对需要的朋友能有所帮组,下载地址
 
 
下载速度可能慢一些,但是绝对好用

shell> groupadd -g 500 mysql
shell> useradd -u500 -gmysql -M mysql
shell> tar -xzf mysql.**.tar.gz
shell> cd mysql.**
shell> ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
shell> make
shell> make install
shell> cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql //开机启动mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql & 

注意直接执行后会出现下面错误:
Starting mysqld daemon with databases from /usr/local/mysql/data STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid 070514 19:15:13 mysqld ended
需执行 shell> chown -R mysql.mysql data

修改root密码:
use mysql
update user set Password=password("123456") where User="root";
delete from user where User="";

2.apache安装
shell> tar -xzf httpd-2.2.4.tar.gz
shell> cd httpd-2.2.4
shell> ./configure --prefix=/usr/local/apache2 --enable-rewrite=shared --enable-speling=shared --enable-module=so
shell> make
shell> make install

3.iconv安装
shell> ./configure --prefix=/usr/local/iconv
shell> make
shell> make install

4.gd部分安装
zlib包
shell> ./configure --prefix=/usr/local/zlib
shell> make check
shell> make install

libpng包(支持PNG)
shell> ./configure --prefix=/usr/local/libpng
shell> make
shell> make install

jpeg-6b包(支持jpg格式)
shell> ./configure --prefix=/usr/local/jpeg-6b --enable-share --enable-static
shell> make test
shell> make
shell> make install
shell> make install-lib

freetype包(字体支持)
shell> ./configure --prefix=/usr/local/freetype
shell> make
shell> make install

最后安装gd包
shell> ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg-6b --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
shell> make
shell> make install

make时会出现
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/tmp/gd-2.0.26gif'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/gd-2.0.26gif'
make: *** [all] Error 2
需要复制/usr/local/libpng/include/目录下的cp /usr/local/libpng/include/pngconf.h /home/jong/tmp/gd-2.0.34
cp /usr/local/libpng/include/png.h /home/jong/tmp/gd-2.0.34

5.安装php

shell> ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg-6b --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --enable-trace-vars -with-mysql=/usr/local/mysql -with-iconv=/usr/local/iconv --enable-mbstring=all --with-curl --enable-track-vars --with-DBA --enable-mbstr-enc-trans --enable-mbregex --with-config-file-path=/usr/local/php --with-xml --with-gettext
shell> make
shell> make install
shell> cp php.ini-dist /usr/local/php/php.ini 

编辑apache配置档
shell> cd /usr/local/apache2/conf
shell> vi httpd.conf
在LoadModule php4_module modules/libphp4.so
添加AddType application/x-httpd-php .php

OK,基本的安装已经完成,如果重新起动APACHE出现:/usr/local/apache2/bin/apachectl start Syntax error . line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解决:

编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux . the system.
# SELINUX= can take .e of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing 

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。

编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux . the system.
# SELINUX= can take .e of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing 

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。

如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。



本文转自 Jhuster 51CTO博客,原文链接:http://blog.51cto.com/xwnet/124588,如需转载请自行联系原作者
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
9天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
60 0
|
9天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
28 0
|
10天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
15 0
|
10天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
35 0
|
21天前
|
Java Linux Maven
Linux中安装MAVEN环境配置
Linux中安装MAVEN环境配置
47 3
|
22天前
|
消息中间件 Java Linux
Linux下RabbitMQ安装与使用
Linux下RabbitMQ安装与使用
32 1
|
1天前
|
Java 关系型数据库 MySQL
一套java+ spring boot与vue+ mysql技术开发的UWB高精度工厂人员定位全套系统源码有应用案例
UWB (ULTRA WIDE BAND, UWB) 技术是一种无线载波通讯技术,它不采用正弦载波,而是利用纳秒级的非正弦波窄脉冲传输数据,因此其所占的频谱范围很宽。一套UWB精确定位系统,最高定位精度可达10cm,具有高精度,高动态,高容量,低功耗的应用。
一套java+ spring boot与vue+ mysql技术开发的UWB高精度工厂人员定位全套系统源码有应用案例
|
2天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
12 0
|
9天前
|
监控 安全 关系型数据库
基于vue2 + element +mysql医院不良事件上报系统源码
不良事件管理系统从时间上报、PDCA分析、事件整改、评估效果实行闭环管理和分析,满足医院追根溯源,全流程闭环管理,提高不良事件上报率,减少同类不良事件发生,提高医疗安全。通过报告不良事件,及时发现潜在的不安全因素
17 1
|
10天前
|
NoSQL Linux PHP
php添加redis扩展 linux和windos图文详解 l
php添加redis扩展 linux和windos图文详解 l
3 0