LAMP环境安装

在Linux下搭建LAMP开发环境比Windows下复杂下,下面是安装过程的笔记

1)安装apache

#软件版本为httpd-2.2.9.tar.gz
shell> cd /usr/local/src
shell> tar -zxvf httpd-2.2.9.tar.gz
shell> cd httpd-2.2.9
 shell>./configure --prefix=/usr/local/apache  \
--enable-modules=all \
--enable-rewrite \
--enable-mods-shared=all \
--enable-so
shell> make 
shell> make install


#启动Apache
/usr/local/apache/bin/apachectl start
开启服务:/usr/local/apache/bin/apachectl start|stop|restart


#查看是否启动成功
netstat -tunpl | grep 80
#测试apache
浏览器打开: http://虚拟机IP 
看到 "it works!",即为成功


2): 编译安装MySQL
软件版本:mysql-5.1.58.tar.gz
shell>groupadd mysql
shell>useradd mysql -g mysql
shell>tar -zxvf mysql-5.1.58.tar.gz
shell>cd mysql-5.1.58
#配置mysql编译选项,指定安装路径及支持的字符集
shell>./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=gbk,gb2312,binary
#编译安装
shell>make
shell>make install
#配置并初始化mysql
shell>cp support-files/my-medium.cnf /etc/my.cnf
shell>cd /usr/local/mysql
#初始化数据库
shell>./bin/mysql_install_db --user=mysql \
--datadir=/usr/local/mysql/data

#为了安全,把所有文件修改为root用户所有,
shell>chown -R root .
#把data目录修改为mysql用户所有
shell>chown -R mysql data
shell>chgrp -R mysql .
#启动mysql服务
shell>bin/mysqld_safe --user=mysql &
#测试服务器,并设置mysql root用户密码
use mysql
update user set password=PASSWORD('root') where user='root'
#清空权限缓存,使更改立即生效。
flush privileges


3)安装php
shell>tar -zxvf php
shell>cd php
shell>./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql
shell>make && make install


4)整合LAMP
# 打开apache配置文件,添加AddType
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php

cp php-5.2.5/php.ini-dist /usr/local/php/lib/php.ini
5)把apache和mysql配置为开机启动。
打开 /etc/rc.local,linux系统每次启动后都会自动执行这个文件,在该文件中,加入以下两行内容:
/usr/local/apache/bin/apachectl start
/usr/local/mysql/bin/mysql_safe --user=mysql &


该socket文件,在/var/lib/mysql/mysql.sock
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值