Ubuntu12.04下手动配置安装apache+php+mysql

分别上mysql、php、apache官网下载源码包

package(将这三个包放到/opt目录下备用,以下以root安装):
mysql-standard-5.0.9-beta-linux-i686.tar.gz
httpd-2.0.54.tar.gz
php-5.0.4.tar.gz
--------------------------------------------------------------------------------
mysql的安装
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /opt/mysql-standard-5.0.9-beta-linux-i686.tar.gz
shell> ln -s /opt/mysql-standard-5.0.9-beta-linux-i686 mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
改变相应权限
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
运行mysql
shell> bin/mysqld_safe --user=mysql &

如果安装正确会出现下面字样
[1] 17673 <----进程pid号~:)
root@ubuntu:/usr/local/mysql # Starting mysql daemon with databases from /usr/local/mysql/data
okey,出现上面信息说明mysql正在运行了~
呵呵,用 ps -aux|grep mysql命令可以看到进程

--------------------------------------------------------------------------------
apache2的安装
shell>cd /opt
shell>tar zxvf httpd-2.0.54.tar.gz
shell>cd httpd-2.0.54
shell> ./configure --enable-so --enable-so;make;make install
shell> cd /usr/local/apache2/bin
shell> ./apachectl start
这时终端没有错误提示说明安装运行成功了哦,用浏览器浏览http://127.0.0.1看看。 Smile
--------------------------------------------------------------------------------
php的安装(我安装的时候遇到错误,经过对错误信息的分析,编译安装需要flex这个包,安装前建议先sudo apt-get install flex装下看看~^^)
shell>cd /opt
shell>tar zxvf php-5.0.4.tar.gz
shell>cd php-5.0.4
shell> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql

我在装的时候,在这里出现了错误提示: xml2-config not found. Please check your libxml2 installation.

sudo apt-get libxml2 提示已经是最新的的版本
实际上缺少libxml2-dev

ubuntu安装libxml2-dev命令apt-get install libxml2-dev

安装完后再运行

shell> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql

就OK了


如果当configure结束的时候出现
+--------------------------------------------------------------------+
│ License: │
│ This software is subject to the PHP License, available in this │
│ distribution in the file LICENSE. By continuing this installation │
│ process, you are bound by the terms of this license agreement. │
│ If you do not agree with the terms of this license, you must abort │
│ the installation process at this point. │
+--------------------------------------------------------------------+

Thank you for using PHP.
那就恭喜了说明配置成功,下面可以安装了,如果出现错误只能一个一个的分析错误。
shell>make;make install
shell> cp php.ini-dist /usr/local/lib/php.ini
将php整合到apache2上
shell>gedit /usr/local/apache2/conf/httpd.conf
找到DirectoryIndex改为如下:
DirectoryIndex index.html index.php index.htm index.html.var


找到
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在它后面添加
AddType application/x-httpd-php .php


重启apache
shell> /usr/local/apache2/bin/apachectl restart


测试php
shell>gedit /usr/local/apache2/htdocs/index.php
添加<? phpinfo();?>

打开浏览器,输入
http://127.0.0.1/index.php

可以看到关于php的信息,证明php安装成功。
--------------------------------------------------------------------------------
开机运行mysql & apache
在/etc/init.d目录下建立两个软联接
shell>cd /etc/init.d
shell>ln -s /usr/local/apache2/bin/apachectl apche2
shell>ln -s /usr/local/mysql/support-files/mysql.server mysql
在/etc/rc2.d目录下建立两个软联接
shell>cd /etc/rc2.d
shell>ln -s /init.d/apache2 S17apache
shell>ln -s /init.d/mysql S18mysql
重启操作系统
shell>reboot
重启后看看mysql的进程内容
shell>ps -aux|grep mysql
查看apche2的进程内容
shell>ps -aux|grep apche2
--------------------------------------------------------------------------------
/usr/bin下建立两个shell脚本
shell>cd /usr/bin
shell>gedit apache2
输入一下两段保存退出
#! /bin/sh

exec /usr/local/apache2/bin/apachectl "$@"
shell>gedit mysql
输入以下两端保存退出
#! /bin/sh

exec /usr/local/mysql/support-files/mysql.server "$@"

付予两个脚本可执行权限
shell>chmod +x mysql
shell>chmod +x apache2
这样只要在任何地方即可使用
apache2 start|stop|restart|reload
mysql start|stop|restart|reload


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值
>