linux as5 启动mysql_linux下LAMP安装

linux 下面安装apache+mysql+php

平台是linux as5(2.6.18-92.el5) + httpd-2.2.6 + mysql-5.0.45 +

php-5.2.5

首先准备安装包httpd-2.2.6.tar.gz,mysql-5.0.45.tar.gz,php-5.2.5.tar.gz。这些包可以到官方网站上自行下载,都是免费的。把它们

放到/usr/local/src目录下解压。/usr/local/src是放置源码的目录,一般情况下人们都习惯把源码文件放到这里。

1.Mysql的安装

进雖ysql解压的源码文件目录

tar zxvfmysql-5.0.45.tar.gz

cd mysql-5.0.45

./configure --prefix=/usr/local/mysql --enable-assembler

--with-mysqld-ldflags=-all-static

--with-charsets=utf8--without-debug --without-isam --without-innodb

--enable-thread-safe-client --with-charsets=all(查看./configure

--help选择需要的参数安装)

没有报错就

make && make install

#编译,进行安装。

配置mysql

groupadd mysql #添加mysql组

useradd -g mysql mysql #添加mysql用户并加入到mysql组

cd /usr/local/mysql/ #切换到cd /usr/local/mysql/目录下

chown -R mysql:mysql .

#改变当前目录下的所有者和用户组为mysql("."前面一定要有空格)

cd /usr/local/src/mysql-5.0.22/support-files

#到源码mysql目录下的support-files下

cp my-medium.cnf /etc/my.cnf #拷贝文件到/etc/覆盖my.cnf 文件

cd /usr/local/mysql/bin #改变目录到/usr/local/mysql/bin

./mysql_install_db --user=mysql #以mysql身份初始化数据库

cd /usr/local/mysql #改变目录到/usr/local/mysql

chown -R mysql:mysql var

#改变var目录所属mysql用户到mysql组

chmod 755 var #改变var目录权限

cd /usr/local/mysql/bin #改变目录到/usr/local/mysql/bin

./mysqld_safe --user=mysql &

("&"是后台运行,必须使用) #以mysql用户启动库生成套接字

netstat -tunlp | grep mysqld #查看mysql是否启动,mysql用的是3306端口

mysqladmin -u root password 'new-paasword'

#给mysql的root用户设置密码

cd /usr/local/src/mysql-5.0.22/support-files/ #改变目录到cd

/usr/local/src/mysql-5.0.22/support-files/

cp mysql.server /etc/init.d/mysqld #拷贝文件用于开机自动启动

chmod 700 /etc/init.d/mysqld #给mysqld权限

chkconfig --add mysqld #添加mysqld服务到系统

chkconfig --level 345 mysqld on #打开myslqd服务

service mysqld restart #启动mysql服务

测试mysql:

cd /usr/local/mysql/bin #改变目录到cd /usr/local/mysql/bin

mysql -u root -p #登陆mysql

输入密码:

show databases; (mysql以分号结束) #查看数据库表

2.Apache的安装

首先检查是否安装了linux自带的apache,若果有将其卸载。

命令:rpm -qa|grep httpd #查询安装的软件

rpm -e --nodeps 软件名称 #卸载软件部检查依赖关系

进入Apache解压的源码目录

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

--with-mysql=/usr/local/mysql/ --enable-module=so

--enable-mods-shared=max --sysconfdir=/etc/http #设置

Apache的安装路径,指定mysql的路径,打开so模块,so模块是用来提DSO支持的apache核心模块,所有模块加载为动态模块。

make && make install

#编译,进行安装。

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

#拷贝启动文件,让系统启动时自动运行httpd服务

把# chkconfig: - 85 15

# description: Apache is a World Wide Web

server. It is used to serve

# HTML files and CGI.

这些内容拷贝到/etc/init.d/httpd文件#!/bin/bash下面行。

想让服务支持chkconfig工具必须在脚本里有chkconfig和description相关内容的描述。

想了解chkconfig更多信息可参看man文档说明。

chkconfig --add httpd #添加httpd服务到系统

chkconfig --level 345 httpd on #打开httpd服务

service httpd start #启动httpd服务

netstart -ant | grep :80 #查看服务是否启动

配置Apache

vi /etc/http/httpd.conf

取消ServerName前的#,添加ip或是域名及端口。

例: ServerName 192.168.8.55:80

测试APache:

用浏览器输入自己的ip及端口进行测试。

例:浏览器中输入:http://192.168.8.55:80

3.Php安装

进入php解压的源码文件目录

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

--with-mysql=/usr/local/mysql

--with-apxs2=/usr/local/httpd/bin/apxs

--with-mysqli=/usr/local/mysql/bin/mysqli-config

--with-apxs2=/usr/local/httpd/bin/apxs #支持apache2

make && make install

#编译,进行安装。

cp php.ini-dist /usr/local/lib/php/php.ini

vi /etc/httpd/httpd.conf

找到“#AddType application/x-gzip .gz .tgz”

并在后面加入

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

这两行的目的是让apache识别php。

再找到“DirectoryIndex index.html”

加上 index.php 让它把index.php做为默认页

测试环境:

cd /usr/local/httpd/htdocs/

# vi /usr/local/httpd/htdocs/index.php

输入:

phpinfo();

?>

# service httpd restart 重启apache服务器

例:浏览器中输入:http://192.168.8.55/index.php测试一下。如果成功会有相关的php的说明,没成功会提示你保存文件内容。

多次编译可能出的问题:

1.service httpd restart 出现

(98)Address already in use:

make_sock: could not bind to address

0.0.0.0:80

你编译安装的httpd中有一个已经启动,第二个启动时便会出现无法监听指定(或者默认)地址和端口的问题,

killall -9 httpd

在service httpd restart一切正常

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值