Fedora 8下测试php+mysql+apache的介绍

来源:爱站网时间:2020-11-24编辑:网友分享
Fedora 8 的apahce服务器可以运行php程序是非常值得高兴的事情,但是有很多用户们对于Fedora 8下测试php+mysql+apache都不是很了解的,那么下面我们就去看看Fedora 8下测试php+mysql+apache的介绍。

Fedora 8 的apahce服务器可以运行php程序是非常值得高兴的事情,但是有很多用户们对于Fedora 8下测试php+mysql+apache都不是很了解的,那么下面我们就去看看Fedora 8下测试php+mysql+apache的介绍。
    下面这个不知道有没有用,应该是在没有装相应软件的情况下的步骤。
一、关闭图形界面

因为用于开发测试使用,所以没有必要使用图形环境,固将其关闭,以减少资源占用。

编辑/etc/inittab文件:
[root@webapp ~]# cat /etc/inittab

id:3:initdefault:

二、安装所需软件

装完Fedora 7后默认已经安装了Apache,所以我们需要安装的是php和Mysql以及subversion:

1、安装PHP

[root@webapp ~]# yum install php

2、安装Mysql 5

3、安装安装Subversion
[root@webapp ~]# yum install subversion
4、安装php-mysql链接库
yum install php-mysql

linux

三、配置mysql
编辑/etc/my.cnf

四、配置subversion

我的svn库位置放在 /shanmin/svn,请根据自己保存的位置更改相应的命令

创建svn库:svnadmin create /shanmin/svn/

编辑/shanmin/svn/conf/svnserve.conf,把匿名权限设置为none,验证权限设置为write,并且使用passwd验证用户,修改完的代码:
 [root@dev conf]# cat svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option
controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory.  If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
# realm = My First Repository

设置passwd文件

 [root@dev conf]# cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
harry = harryssecret
# sally = sallyssecret

passwd文件中,格式是 用户名=密码

linux

设置自动发布.这个是用于我们远程提交到svn的代码,自动的发布到apache的目录下,这样我们就可以把提交代码和ftp合并成一个了(这也是我为什么在整个安装过程未提及FTP的原因)。

在/shanmin/svn/hooks下增加post-commit文件。(这里我的web目录为/var/www/html)

 [root@dev hooks]# cat post-commit
#!/bin/sh

export LANG=en_US.UTF-8
/usr/bin/svn update /var/www/html

把这个文件设置成可执行文件。例如:chmod 777 post-commit

五、打开所需服务,关闭无用服务

根据我的习惯,我使用setup关闭和打开了几个服务。(注:因为我把Fedora7放在VMWare里面,所以我尽量的让Fedora7少占资源,把能关的服务都关掉)(从默认开始)
autofs 关闭。不使用移动存储设备就关掉这个。

bluetooth 关闭。没有蓝牙设备,没有任何用处。

cpuspeed 关闭。用于CPU降速的,如果CPU不支持降速就关掉这个。

httpd 打开

iptables 关闭。因为是在内网开发测试使用,所以防火墙基本上没有什么用途。

ip6tables 关闭。没有使用ipv6

isdn 关闭。没有使用ISDN

irqbalance 关闭。不在多CPU环境下,这个服务没有什么用处。

mysqld 打开

netfs 关闭。如果不使用网络挂接就关掉。

yum-updatest 关闭。这个用于自动升级提醒,不进图形界面就没有用处。

 

运行Subversion服务

默认没有给svn提供一个开启的服务,所以我们得手动添加到rc.local文件中(其实完全可以不使用svn服务,而使用Apache。但是因为开发测试环境也在Apache下,我会影响开发,所以一直使用单独的svn服务)。

编辑/etc/rc.local文件,加入svn服务器运行命令

 [root@dev ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

svnserve -d -r /shanmin/svn

六、重起服务器,做最后设置和测试

 把svn中的数据取到apache目录下:

[root@dev ~]# svn checkout svn://127.0.0.1/ /var/www/html/

验证是否正常取出

[root@dev ~]# ll /var/www/html/ -a
total 24
drwxr-xr-x 3 root root 4096 2007-06-24 17:08 .
drwxr-xr-x 6 root root 4096 2007-05-26 03:46 ..
drwxr-xr-x 6 root root 4096 2007-06-24 17:08 .svn

如果有.svn目录证明正常取出。

配置mysql远程管理,默认mysql的root在本机管理,简单起见,我都是把localhost改为%

 [root@dev ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where host='localhost' and user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>

完成。

后面的对我的帮助也很大,现在也把它贴在这里,以备以后能够用得着。
apache+mysql+php这是一个经典的应用组合,每次学习都要配置,我自己还是很喜欢用这个组合来实现一些东西的。
首先,在官方下载apache、mysql和php的最新版本:

数据库:mysql-standard-5.0.27-linux-i386-glibc23.tar.gz
web服务器:httpd-2.2.3.tar.gz
脚本:php-5.2.0.tar.bz2

然后安装(下载好的安装包都放置在/usr/local/下面)

一、安装mysql

# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# tar zvxf mysql-standard-5.0.27-linux-i386-glibc23.tar.gz
# ln -s mysql-standard-5.0.27-linux-i386-glibc23 mysql
# cd mysql
# scripts/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql data
# chgrp -R mysql .
# cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件,当启动mysql时会读取配置
# vi /etc/my.cnf
查找 The Mysql server
[mysqld]
添加一行:set-variable = max_connections=150
保存并退出
# /usr/local/mysql/bin/safe_mysqld --user=mysql & //启动mysql
此时可以使用/usr/local/mysql/bin/mysqladmin version 查看Mysql DBMS版本和使用信息.
# /usr/local/mysql/bin/mysqladmin -uroot password xxxxx //为root访问设置密码
当计算机重新启动后mysql不会启动,如果想同时启动就添加下面的内容:
# vi /etc/rc.local
添加:/usr/local/mysql/bin/safe_mysqld --user=mysql &
保存并退出

二、安装apache

# cd /usr/local
# tar -zxvf httpd-2.2.3.tar.gz
# cd httpd-2.2.3
# ./configure --prefix=/usr/local/apache --enable-module=most --enable-shared=max
# make
# make install
启动Apache服务: # /usr/local/apache/bin/apachectl start
关闭Apache服务: # /usr/local/apache/bin/apachectl stop
重启Apache服务: # /usr/local/apache/bin/apachectl restart

三、安装php

# cd /usr/local
# tar -jxvf php-5.2.0.tar.bz2
# cd php-5.2.0
# ./configure --prefix=/usr/local/php --with-mysqld=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini

四、配置apache

编辑httpd.conf文件
# vi /usr/local/apache/conf/httpd.conf
在LoadModule处添加: LoadModule php5_module module/libphp5.so
在DirectoryIndex处添加: index.php
在AddType application处添加: AddType application/x-httpd-php .php .phtml
AddType applicatoin/x-httpd-php-source .phps

五、测试php模块的加载

# /usr/local/apache/bin/apachectl start //开启apache
在浏览器中输入:http://localhost/
浏览器中显示:It Works 表示apache开启www服务
在/var/www/html目录下建一个文件phpinfo.php
输入:phpinfo();
保存并退出
在浏览器中输入:http://localhost/phpinfo.php
浏览器中显示一个关于apache和php安装的Web页,表示成功加载php模块。

上文就是关于Fedora 8下测试php+mysql+apache的介绍,其实不管这些东西是不是真的有用,但是还是建议收藏起来以备不时之需。

上一篇:如何配置PHP并关联MySQL

下一篇:Ubuntu7.10下安装配置Tomcat的教程

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载