centos6.5搭建LAMP
实验前准备
(1)service iptables stop #关闭防火墙
service iptables status #查看防火墙是否已经关闭
iptables: Firewall is not running. 这说明防火墙 已经关闭
(2) setenforce 0 关闭selinux
通过sestatus查看selinux是否关闭
图
(3)确认没有使用RPM方式源代码安装php及相关依赖包
[root@crushlinux ~]# rpm -e httpd httpd-manual webalizer subversion mod_python mod_ssl mod_perl system-config-httpd php php-cli php-ldap php-common php-mysql mysql-server mysql dovecot –nodeps
实验部分
一、安装httpd
1、下载apache
wget http://archive.apache.org/dist/httpd/httpd-2.2.17.tar.gz
2、解压压缩包
tar xf httpd-2.2.17.tar.gz
3、编译源码包,并且安装
(1)cd httpd-2.2.17
(2)./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
图1
编译完成后,如上图,说明已经编译成功
如果出现以下错误
则在编译时入加 --with-included-apr 即可解决。
4、安装
make && make install
图2
编译完成后,如上图,说明已经编译成功
(1)ln -s /usr/local/httpd/bin/* /usr/local/bin/
(2)cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
#复制启动脚本
(3)vi /etc/init.d/httpd #编辑启动脚本,增加红色部分内容
#!/bin/sh
#chkconfig:345 66 88
#description:http apache
解释:
345 66 88表示:345运行级别是开启的,66为服务启动顺序,88服务为停止顺序。
(4)chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
5、启动服务
service httpd start
报错1:httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
解决:vim /usr/local/httpd/conf/httpd.conf
97 #ServerName www.example.com:80
98 ServerName localhost:80
在配置文件中加入97行下加入98行显示内容
报错2:
/usr/local/apache/bin/httpd: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
有很多so模块在/usr/local/lib目录下,所以在/etc/ld.so.conf中加入/usr/local/lib这一行
[root@crushlinux conf]# vi /etc/ld.so.conf
/usr/local/lib
[root@crushlinux conf]# /sbin/ldconfig -v
现在您已经将 Apach源代码安装在 /usr/local/apache。本源代码安装支持可装载模块
和标准的 MPM prefork。之后,可以使用如下命令启动 Apache 服务器:
/usr/local/httpd/bin/apachectl start
二、安装mysql
准备工作:
[root@Centos2 mysql]# rpm -q mysql-server mysql
package mysql-server is not installed
package mysql is not installed
如果已经安装,先卸载,以免发生端口或是程序冲突
mysql5.5以上的版本都需要cmake编译。而不是./configure
所以需要安装cmake
tar xf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./configure
gmake && gmake install
或这是
yum -y install cmake
1、创建mysql用户
groupadd mysql
useradd -M -s /sbin/nologin -g mysql mysql
2、解压,编译、安装
tar xf mysql-5.5.22.tar.gz
cd mysql-5.5.22
[root@Centos2 mysql-5.5.22]#
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
-DCMAKE_INSTALL_PREFIX: 指定数据库安装目录
-DSYSCONFDIR=/etc :指定配置文件目录
-DDEFAULT_CHARSET:指定默认使用的字符集编码。如utf8
-DDEFAULT_COLLATION=utf8_general_ci:设定默认排序规则(utf8_general_ci快速/utf8_unicode_ci准确)
-DEXTRA_CHARSETS=all:启用额外的字符集类型(默认为all)
如下图表示编译完成
图1
配置
make && make install
3、权限调整
chown -R mysql:mysql /usr/local/mysql
4、建立配置文件
rm -rf /etc/my.cnf
cd mysql-5.5.22
cp support-files/my-medium.cnf /etc/my.cnf
5、初始化数据库
cd /usr/local/mysql
scripts/mysql_install_db
--user=mysql
--basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
初始化数据库成功
6.设置软连接
为了在任何目录下都能使用mysql命令。可以创建软连接
ln -s /usr/local/mysql/bin/* /usr/local/bin/
7、将mysql添加为系统服务
cd mysql-5.5.22/support-files
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
8、启动mysql服务
service mysqld start
Starting MySQL.. [ OK ]
[root@Centos2 ~]# netstat -antp |grep mysqld
tcp 0 0 0.0.0.0:3306 . 0.0.0:* LISTEN 13611/mysqld
9、登陆验证
mysql搭建完成
三、安装php
1.源代码安装libmcrypt
[root@crushlinux ~]# tar zxf libmcrypt-2.5.8.tar.gz [root@crushlinux ~]# cd libmcrypt-2.5.8/
[root@crushlinux libmcrypt-2.5.8]# ./configure
[root@crushlinux libmcrypt-2.5.8]# make && make install
[root@crushlinux libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib/
2.源代码安装mhash
[root@crushlinux ~]# tar zxf mhash-0.9.9.9.tar.gz
[root@crushlinux ~]# cd mhash-0.9.9.9/
[root@crushlinux mhash-0.9.9.9]# ./configure
[root@crushlinux mhash-0.9.9.9]# make && make install
[root@crushlinux mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib/
3、源代码安装mcrypt
[root@crushlinux ~]# tar zxf mcrypt-2.6.8.tar.gz
[root@crushlinux ~]# cd mcrypt-2.6.8/
[root@crushlinux mcrypt-2.6.8]# ./configure
[root@crushlinux mcrypt-2.6.8]# make && make install
编译时候报错:
configure: error: *** libmcrypt was not found
解决办法:
第一步:ln -s
/usr/local/bin/libmcrypt_config /usr/bin/libmcrypt_config
第二步:
export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
4、编译php
root@crushlinux ~]# tar zxf php-5.3.6.tar.gz
[root@crushlinux ~]# cd /php-5.3.6
[root@crushlinux php-5.3.6]# ./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring
编译参数解释:
--prefix=/usr/local/php5 //指定安装目录
--with-mcrypt //加载扩展工具支持
--with-apxs2=/usr/local/httpd/bin/apxs //设置Apache提供的apxs模块 程序文件位置
--with-mysql=/usr/local/mysql //指定mysql服务的安装路径
--with-config-file-path=/usr/local/php5 //指定php配置文件“php.ini” 的存放路径
--enable-mbstring //启用多字节字符串功能
如下图表示编译成功
图1
Make && make install
如下图表示安装成功:
到此apache、mysql、php源码包安装完成。
四、整合LANMP环境
[root@crushlinux php-5.3.6]# cd php-5.3.6
[root@crushlinux php-5.3.6]# ls php.ini-*
/usr/src/php-5.3.6/php.ini-development //开发版样例文件,用户学习,测试
/usr/src/php-5.3.6/php.ini-production //生产版样例文件,用户实际运用
1)复制样例文件
[root@crushlinux php-5.3.6]#
cp php.ini-development /usr/local/php5/php.ini
2)php.ini配置调整
[root@crushlinux php-5.3.6]# vi /usr/local/php5/php.ini
773 default_charset = "utf-8" //设置默认字符集为utf-8
871 file_uploads = On //允许通过PHP网页上传文件
880 upload_max_filesize = 2M //允许上传的文件大小限制
883 max_file_uploads = 20 //每个HTTP请求最多允许上传的文件数
728 post_max_size = 8M //每次通过表单POST提交的数据量限制
226 short_open_tag = On //允许识别PHP短语法标记,即<? … ?>
3)调整Apache配置
[root@crushlinux ~]# vim /usr/local/httpd/conf/httpd.conf
53 LoadModule php5_module modules/libphp5.so
配置加载PHP程序的模块文件
54 AddType application/x-httpd-php .php .phtml
添加对“.php”类型网页支持
169 DirectoryIndex index.php index.html
识别常见的php首页文件
[root@crushlinux ~]# /usr/local/httpd/bin/apachectl restart
五、测试
1)测试PHP能否正常提供服务
[root@crushlinux ~]# vim /usr/local/httpd/htdocs/test1.php
<?php
phpinfo(); 内建函数用于显示PHP环境信息
?>
[root@crushlinux ~]# /usr/local/httpd/bin/apachectl restart
浏览器输入:http://10.3.0.209/test1.php
有如上信息为正确
2)测试PHP能否正常访问mysql数据库
[root@crushlinux ~]# vi /usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect('localhost','root','');
if($link) echo "OK!!";
else echo "FAILD!!";
?>
centos6.5搭建LAMP的更多相关文章
- 基于centOS6.7搭建LAMP(httpd-2.4.18+mysql-5.5.47+php-5.6.16)环境
首先确保系统可以联网.设置IP地址以及虚拟机安装linux在此略过.本文采用centos6.7 64位minimal版.php5.6.16.httpd-2.4.18.mysql-5.5.47版搭建la ...
- Centos6.5 搭建LAMP环境
1.Centos6.5 处于对安全的考虑,严格控制网络的进去.所以安装 Apache 或 MySQL 的时候,需要开放 80 或 3306 端口 首先,执行如下命令查看当前防火墙开放了哪些端口: [ ...
- centos6.4yum搭建lamp环境
1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 8 ...
- 在centos6中编译安装httpd-2.4/搭建LAMP
首先确保centos6安装平台安装一下环境: #yum groupinstall "Development Tools" "Server Platform Develo ...
- Centos6.4版本下搭建LAMP环境
Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...
- CentOS6.5下搭建LAMP+FreeRadius+Daloradius Web管理和TP-LINK路由器、H3C交换机连接,实现,上网认证和记账功能
什么是RADIUS服务: RADIUS:(Remote Authentication Dial In User Service)中文名为远程用户拨号认证服务,简称RADIUS,是目前应用最广泛的AAA ...
- CentOS6.5下搭建LAMP环境(源码编译方式)
CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL) 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP ,WAMP,MAMP等.这里我介 ...
- linux搭建LAMP
先简要概述下本文要点:(操作系统采用CentOS6.5 x64) 1.分别安装搭建lamp服务环境: 2.采用lamp一键安装包搭建环境: 3.在lamp环境中初步搭建起一个网站: 一. 分别安装搭建 ...
- 64位CentOS 6.0下搭建LAMP环境
系统环境:Centos6.0 x64 1.确认搭建LAMP所需要的环境是否已经安装 [root@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libai ...
随机推荐
- 分布式系统为什么不用自增id,要用雪花算法生成id???
1.为什么数据库id自增和uuid不适合分布式id id自增:当数据量庞大时,在数据库分库分表后,数据库自增id不能满足唯一id来标识数据:因为每个表都按自己节奏自增,会造成id冲突,无法满足需求. ...
- 用oracle中的Row_Number实现分页
Row_Number实现分页 1:首先是 select ROW_NUMBER() over(order by id asc) as 'rowNumber', * from table1 生成带序号 ...
- postman 中get传参数
mybatis中: @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET, produces = & ...
- list.jsp页面
<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@tag ...
- 简单的Spring Boot项目——实现连接Mysql数据库
一.创建Spring Boot项目 参考:使用IntelliJ IDEA创建简单的Spring Boot项目 二.数据库.表的创建 三.项目开发 3.1 pom.xml文件配置 <?xml ve ...
- 【Matlab】向图像域添加噪声/高斯/均匀/伽马/指数/椒盐
[向图像域添加噪声] matlab自带一个函数:imnoise,可以对图像添加噪声. Matlab的说明 https://www.mathworks.com/help/images/ref/imnoi ...
- Containing ViewControllers
Containing ViewControllers 转自:https://www.cocoanetics.com/2012/04/containing-viewcontrollers/ For a ...
- 设置项目的日程排定方式(Project)
<Project2016 企业项目管理实践>张会斌 董方好 编著 [项目]>[属性]>[项目信息]>[日程排定方法]>选取: 默认项是[项目开始日期]. 这两位是干 ...
- CF1099A Snowball 题解
Content 有一个重量为 \(w\) 的雪球从高度为 \(h\) 的位置开始滚落,每秒它的高度会减少 \(1\),同时在高度为 \(i\) 的位置它的重量会增加 \(i\).在雪球滚动的路线上还有 ...
- python 银行管理系统
这是一个使用python连接mysql的例子 涉及到类的使用 import pymysql import function as f def mysql(): db=pymysql.connect(h ...