4/09/2005

一个完整WebServer的建立过程

平台为Fedora Core/Apache, 动态页面是PHP5.x, 数据库是mysql4.X

--------------------------------------------------------------------------------
登陆webserver,以root身份打开httpd
打开进入/etc/httpd/conf/httpd.conf,找到UserDir disable,关闭此项;同时找到#UserDir public_html,去掉注释;找到index.html,加上index.php
在自己用户下建立一public_html目录,讲自己的用户主目录权限改成至少711,public_html目录改成至少755
如果希望以http://hostname/username/方式访问,可以在/var/www/html/下建立一个soft link指向/home/username/public_html,link名字叫username
测试webserver是否工作正常
--------------------------------------------------------------------------------
下载php5.x软件包,解压,然后配置:./configure --with-apxs2=/usr/sbin/apxs --with-libxml-dir --with-openssl --with-zlib --with-zlib-dir --enable-bcmath --with-bz2 --enable-calendar --with-jpeg-dir --with-tiff-dir --with-curl --with-curlwrappers --with-inifile --with-flatfile --enable-dio --enable-exif --with-fam --enable-filepro --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-ttf --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --without-iconv --with-imap --with-kerberos --with-imap-ssl --with-ldap --with-ldap-sasl --enable-mbstring --with-libmbfl --with-openssl-dir --with-mysql --with-mysql-sock --enable-shmop --enable-sqlite-utf8 --with-sqlite --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-expat-dir --with-iconv-dir --with-pcre-regex --with-pear --enable-maintainer-zts --enable-memory-limit
编译make然后安装make install
在public_html目录下建立一个index.php,里面就一个函数: phpinfo(),用浏览器访问,看看php是否工作正常,这时应该看到php版本是4.3.x,因为/etc/http/conf.d/php.conf文件中已经加载了libphp4.so,而/etc/httpd/conf/httpd.conf中加载了libphp5.so,会互相冲突,所以应该注释掉libphp4.so,这样再测试,就是5.0.4版本了,而且配置也全了。
--------------------------------------------------------------------------------
增加一个usergroup: mysql
增加一个用户: mysql
将下载的mysql-xx-xx.tar.gz解压到/usr/local/mysql目录下
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql data
bin/mysqld_safe --user=mysql & (注意用户必须对data目录有读写权限)
--------------------------------------------------------------------------------
下载phpMyAdmin
解压到自己的用户目录,设置好用户权限
通过浏览器访问这个目录http://hostname/phpmyadmin/
按提示完成设置
在phpmyadmin目录下,编辑config.inc.php文件:
$cfg['PmaAbsoluteUri'] = ' ' 改成 $cfg['PmaAbsoluteUri'] = 'https://hostname/phpmyadmin/';
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password 改成
$cfg['Servers'][$i]['user'] = 'mysql'; // MySQL user
$cfg['Servers'][$i]['password'] = 'password'; // MySQL password