分类: BSD
2008-08-25 21:10:10
安装mysql
cd /usr/ports/databases/mysql41-server
make BUILD_OPTIMIZED=yes SKIP_DNS_CHECK=yes WITH_LANG=simplified-chinese
make install clean;
/usr/local/bin/mysql_install_db # 如果不设置这个,将不能启动
chown -R root /var/db/mysql # 或者 chown -R mysql /var/db/mysql
chgrp -R mysql /var/db/mysql
chmod -R 777 /var/db/mysql
/usr/local/bin/mysqld_safe --user=mysql & # //--user=mysql &
手工启动mysql
/usr/local/etc/rc.d/mysql-server.sh
/usr/local/bin/mysqld_safe & //--user=mysql &
/usr/local/libexec/mysqld
自动启动脚本
chmod 777 mysql-server
/usr/local/etc/rc.d/mysql-server { start | stop } 脚本启动
Usage: /usr/local/etc/rc.d/mysql-server [fast|force|one](start|stop|restart|rcvar|status|poll)
测试:
ps -aux | grep mysql
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
/usr/local/bin/mysql_secure_installation
/usr/local/bin/mysqladmin -u root password '123456'
mysql -u root -p #连接数据库
安装apache
#2.2与1.X版本区别 apache22 后面的数字变化;1无,2为2x
#cd usr/ports/www/apache
#make WITH_APACHE_SUEXEC=yes APACHE_HARD_SERVER_LIMIT=1024 APACHE_PERF_TUNING=yes install #编译时带上suexec和优化。可选
#make install clean
手动启动:
/usr/local/sbin/httpd
/usr/local/sbin/apachectl start
自动启动:
ee /etc/rc.conf
apache_enable="YES"
chmod 755 /usr/local/etc/rc.d/apache
/usr/local/etc/rc.d/apache
配置文件路径:
/usr/local/etc/apache/httpd.conf
bsd 7.0 ports 安装已经存在;必须检查下
DirectoryIndex index.php index.html index.html.var
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps #解析php ,并以加亮形式将源代码显示出来
LoadModule php4_module modules/libphp4.so
AddDefaultCharset ISO-8859-1 --> AddDefaultCharset GB2312
#再设置apache默认字符集为简体中文<可选>
安裝php && php5-extensions
# 安装PHP5。不要选择debug选项,否则Zend不管用的apache2.2+php5+php_e5)
#cd /usr/ports/lang/php4 # 不同的版本可能路径是不相同的,可以参考官方网站的目录更改
# cd /usr/ports/www/mod_php4
#make config
#make &&make install clean
cd /usr/ports/lang/php4-extensions/
# make -DWITHOUT_X11 install clean #知道模块直接编译安装(1)
#make config #选择相应的模块2(2)
#make install clean #暂时不安装
#cd /usr/local/etc
#cp php.ini-recommended php.ini
cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini
cp php.ini-dist /usr/local/apache/conf/php.ini #以上任选一个
apache+php5+mysql5 整合
开机自动启动 mysql 和 apache:
echo ' mysql_enable = "YES" ' >> /etc/rc.conf
echo ' apache_enable="YES" ' >> /etc/rc.conf
或者
vi /etc/rc.conf
mysql_enable="YES"
apache_enable="YES"
启动脚本编写:<可选>
方式一
/usr/local/etc/rc.d/apache start/stop/restart
方式二
vi
/usr/local/apache/bin/apachectl start &
chmod 777 apache22.sh
手动启动apache
#/usr/local/sbin/httpd -k start/stop/restart #启动/停止/重启 apache
#/usr/local/sbin/apachectl -k start/stop/restart #启动/停止/重启 apache
測試php.
检测apache + php + mysql
cd /www/htdocs apache2/1.3主目录
cd /usr/local/www/apache22/data/ apache2.22的主目录 #版本不同,路径不同;具体分析.
# touch test.php
# vi test.php
phpinfo( );
?>
上面是4的测试文件
phpinfo( );
?>
上面的是5的测试文件
保存退出 :wq
打开浏览器
# touch mysqltest.html
# vi mysqltest.html
$link=mysql_connect('localhost','root');
mysql_select_db('mysql');
$str="select * from user;";
$result=mysql_query($str,$link);
$show=mysql_num_rows($result);
mysql_close($link);
for ($i=0;$i < $show;$i++)
{
$arr[$i]=mysql_fetch_array($result);
};
?>
Host User Password
};?>