+ -
当前位置:首页 → 问答吧 → Slackware 12.0的变化--Apache2

Slackware 12.0的变化--Apache2

时间:2007-07-07

来源:互联网

Web 服务器的简单配置

Slackware 12.0 包括 Kernel 2.6.21.5,Apache 2, MySQL 5, PHP 5. 最主要的变化是apache2配置,配置文件的位置从/etc/apache/httpd.conf变为/etc/httpd/httpd.conf. 而且DocumentRoot 从/var/www/htdocs变为/srv/httpd/htdocs/。 Web 服务器的配置通常包括Linux Apache, MySql, PHP (LAMP).

启动apache2

启动apache2只需要对/etc/rc.d/rc.httpd增加一个可执行位
引用:
# chmod +x /etc/rc.d/rc.httpd
# /etc/rc.d/rc.httpd start
这时,web服务已经启动。打开firefox,在地址栏输入http://localhost,如果你看到了It works!的字样,那么祝贺你,apache2已经成功运行。

配置PHP5

PHP5的配置需要两个文件php.ini和mod_php.conf。这两个文件都在/etc/httpd目录中。
引用:
# cd /etc/httpd/
# mv php.ini-recommended php.ini
# mv mod_php.conf.example mod_php.conf
在配置文件/etc/httpd/httpd.conf中,去掉mod_php.conf行前面的注释。并在DirectoryIndex index.html的后面增加 index.htm index.php
引用:
#Include /etc/httpd/mod_php.conf
改为
Include /etc/httpd/mod_php.conf
...
DirectoryIndex index.html index.htm index.php
然后重新启动apache
引用:
# /etc/rc.d/rc.httpd restart
这时可以用下列方法测试 PHP 是否工作
在 /srv/httpd/htdocs/生成一个文件info.php,输入下面内容
引用:
<html>
<head>
<title> PHP Test Script </title>
</head>
<body>
<?php
phpinfo( );
?>
</body>
</html>
然后打开firefox,在地址栏输入http://localhost/info.php, 如果你能看到PHP的info信息,表明PHP工作正常。

MySQL 5
首先需要初始化MySql,以root身份
引用:
$ su
# su mysql
$ mysql_install_db
$ su root
# mv /etc/my-small.cnf /etc/my.cnf
# chown -R mysql:mysql /var/lib/mysql/
然后启动MySql
引用:
# chmod +x /etc/rd.d/rc.mysqld
# /etc/rc.d/rc.mysqld start
如果没有任何出错信息, MySql已经运行。接下来设置口令并生成一个测试数据库testdb。
引用:
# mysqladmin -u root password <Your_Pass_Word>
# mysqladmin -u root -p create testdb
可以使用下列命令来测试MySql是否运行
引用:
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.37 Source distribution

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

mysql>
如果你看到了mysql>的提示符,则表明MySql运行正常。

为了让PHP也支持MySql,打开/etc/httpd/php.ini找到 extension=msql.so这一行,并去掉前 面的注释(分号; )

引用:
; Filename: /etc/httpd/php.ini

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
extension=msql.so

SSL配置
SSL 是一种安全机制,如果你经常去网上银行,你会发现地址栏以https:// 开头而不是以 http:// 开头。https:// 即是增加了安全机制的http协议。为了增加SSL支持,需要产生私有密钥和共有密钥.
引用:
$ openssl req -new > myserver.csr
按要求填写有关信息,当提示输入Common Name时,请输入你的网站全名比如 www. myweb. com, 为测试的目的,我在这一步直接输入localhost.
然后删除掉私有密钥中passphras并生成 certificate.
引用:
$ openssl rsa -in privkey.pem -out myserver.key
$ openssl x509 -in myserver.csr -out myserver.cert -req -signkey myserver.key -days 365
最后将生成的密钥和证书拷贝到/etc/httpd/
引用:
# cp myserver.cert /etc/httpd/server.crt
# cp myserver.key /etc/httpd/server.key
并修改/etc/httpd/httpd.conf的相应配置。打开/etc/httpd/httpd.conf,搜索包含mod_ssl.so行,将前面的注释去掉

引用:
# Filename: /etc/httpd/httpd.conf
...
...

LoadModule ssl_module lib/httpd/modules/mod_ssl.so
重新启动 httpd,
引用:
# /etc/rc.d/rc.httpd restart
SSL使用443端口,至此可以测试 443 端口是否被所监听
引用:
$ netstat -tpan | grep 443
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::443 :::* LISTEN -
一切正常后,打开 firefox在地址栏输入 https://localhost 证书被验证后,你可以看到It works!字样。

作者: lchxr   发布时间: 2007-07-07

hehe,楼主好心人阿~~~加油!!!!

作者: dogking   发布时间: 2007-07-08

很好,顶帖再看完。一直比较喜欢BSD风格的启动方式

作者: jazzly   发布时间: 2007-07-08

还是比较喜欢自己编译。
虽然系统自带的很方便。^_^

作者: 基督山伯爵   发布时间: 2007-07-08

今天打算在slackware 12上架个Jabber服务器,用的mysql和openfire,结果openfire死活连不上mysql数据库。找了半天,没发现mysql和openfire有什么问题,同样的设置在Windows下做了N遍都没问题。
我的步骤如下:
安装openfire到/opt目录下
设置好mysql(slackware12自带的那个版本),启动服务,建个名叫openfire的数据库并用openfire自带的那个进行脚本初始化,增加个用户jabber专门用来操作openfire数据库。
启动openfire服务,登录http://localhost:9090进行设置->到设置数据库的时候死活连不上
有谁知道是怎么回事?

作者: Yei   发布时间: 2007-09-01

另一种启用mysqld的办法
# mysql_init_db
# chown -R mysql.mysql /var/lib/mysql
# mv /etc/my.cnf-sample /etc/my.cnf
如果不希望mysqld自启动,可执行
# sh /etc/rc.d/rc.mysqld start

作者: chendy   发布时间: 2007-09-02

这是openfire产生的error.log
上传的附件
error.zip (5.2 KB, 2 次查看)

作者: Yei   发布时间: 2007-09-02

解决了,原来只要在rc.mysqld中把--skip-networking选项去掉就行了。

好多天上不了Sir,真是郁闷

作者: Yei   发布时间: 2007-09-17