Freebsd 6.0安装配置Apache+MySQL+PHP+Myphpadmin+Webmin
番茄系统家园 · 2022-09-27 06:42:11
一、Freebsd
A、分区
很多人在使用自己的作业时,不知道如何对分区,对于分区方案没有最好的,只是跟据自己的情况去分。
下面是我的分区方案。
硬盘为120G ,/(根)1G 左右就差不多了,但考滤到/root 工作目录也在这里,所以分大一点。
/home/data 主要是用来存放Email /ftp用户的数据
/tmp 1G 也是考虑到临时文件多,所以给大也点。
/usr/ 10G 因为要软件,还有下载的软件,我没有装GUI 所以只分了10G我认为足够了。
/var 3G这个目录存放的东西比较多,如日志、邮件的临时目录,如果空间不够amavisd-new 无法解开邮件进行杀毒。
%df -h Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1a 1.9G 481M 1.3G 26% /devfs 1.0K 1.0K 0B 100% /dev
/dev/ad0s1g 92G 353M 84G 0% /home/data
/dev/ad0s1e 989M 224K 910M 0% /tmp
/dev/ad0s1f 9.7G 1.8G 7.1G 20% /usr
/dev/ad0s1d 2.9G 105M 2.6G 4% /var
B、基本
对于的,我选择了minimal(最小)和ports ,因为有些没必要的包就不装,减少体积,
另外作为一台器,我从来不装GUI 。
下载BSD时,只需要下载DISK 1 就行了,缺少的软件包可以通过。
C、配置如果你在后期没有配置,在启动完成后以root的身份登陆,运行sysinstall 进行,
或通过ee编辑器编辑/etc/rc.conf文件,在这里提醒各位,一会大多数都需要在/etc/rc.conf加入启动内容才能正常启动。
好固定IP,或通过DHCP 自动分配置机器IP。使用SSH 客户端进行管理器将会为你的工作提供方便。
使用SSH 要注意:
启用 sshd
sshd 的启用是作为 FreeBSD 中 Standard 过程中的一步来进行的。 要查看 sshd 是否已被启用, 请检查 rc.conf 文件中的:
sshd_enable="YES"
这表示在下次启动时加载 OpenSSH 的程序 。 此外,也可以手动使用脚本 /etc/rc.d/sshd 来启动 OpenSSH:
/etc/rc.d/sshd start
允许用户登录 AllowUsers 选项
通常限制哪些用户能够登录, 以及从何处登录会是好主意。 采用 AllowUsers 选项能够方便地达到这一目的。 例如, 想要只允许 root 用户从 192.168.1.32 登录, 就可以在 /etc/ssh/sshd_config 文件中加入下述:
AllowUsers root@192.168.1.32
要允许用户 admin 从任何地方登录, 则只需列出用户名:
AllowUsers admin
可以在同一行指定多个用户, 例如:
AllowUsers root@192.168.1.32 admin
注意: 列出需要登录机器的用户很重要; 否则他们将被锁在外面。
在完成对 /etc/ssh/sshd_config 的修改之后您必须告诉重新加载其配置文件, 是执行:
#/etc/rc.d/sshd reload
a、不能用root直接登陆,需要添加一个新用户,指定到wheel 组,用此用户登陆后用使用 su - 提升到管理员。
b、 以我的SecureCRT 为例,Session options ->Authentication ->Primary 选择keyboard Interactive
c、如果你要使用像LINUX 一样的彩色显示,需要把 Emulation -> Terminal ->Xterm 选中ANSI Color 并在/etc/csh.cshrc加入
setenv LSCOLORS ExGxFxdxCxegedabagExEx setenv CLICOLOR yes
set autolist
然后执行
sed -i.bak -E s/set\ prompt/#set\ prompt/g /root/.cshrc
退出重新登陆即可看到彩色目录了。
二、更新软件包
采用Freebsd 最好的地方就是软件方便,还可以装到最新的软件包,这就是强大的posts 。如果你的在时没有选择posts ,具休如何看BSD 的handbook.
对ports 进行更新,首先修改默认下载的FTP地址:
#vi /etc/make.conf
添加下列四个连接地址,第一个为HTTP连接其余都是FTP.
MASTER_SITE_OVERRIDE?= \
\
\
\
\
CVSUP 的站点很多,你可以选择离你最快的站点去更新posts ,具体查看 freebsd.org /freebsdchina.org.cn
在使用cvsup之前你必须连接到互联网,并需要cvsup 这个软件
a、cvsup-without-gui
% cd /usr/ports/net/cvsup-without-gui/ % make install clean
b、更新ports
完cvsup软件后,
% /usr/local/bin/cvsup -gL 2 -h cvsup4.freebsdchina.org /usr/share/examples/cvsup/ports-supfile
三、数据库 MySQL
MySQL 版本很多,大家可以据自己需要自行。
%cd /usr/ports/databases/mysql41-server/ %make install clean在/etc/rc.conf 加入
mysql_enable="YES"复制配置文件(非必需)
cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf在此说明:
1、如果不在/etc/rc.conf 加入以上内容,手工是无法启动MySQL的。
2、如果你想知道这个软件应该在/etc/rc.conf加入什么内容,
打开/usr/local/etc/rc.d 目录,找到此软件的启动脚本。然后打开文件,如果有详细的说明。
%/usr/local/etc/rc.d/mysql-server.sh start Starting mysql.如何去检查一个是否正常启动:1、通过ps查看进程,2、检查所打开的端口。
%ps aux|grep mysql mysql 948990.20.516441240p0S 3:52PM 0:00.07 /bin/sh /usr/local/bin/mysqld_safe -- mysql 949190.0 10.8 55564 27428p0S 3:52PM 0:01.54 /usr/local/libexec/mysqld --defaults- % %netstat -an|grep 3306 tcp4 00*.3306 *.*LISTENMySQL安装时,器的密码为空,建议你装好后,第一时间去更改密码。
% /usr/local/bin/mysqladmin -u root -p password 你的新密码 Enter password:如果你器只供本站内部使用建议在 my.cnf 里加入下面内容,以增加器的安全性。
[mysqld] bind_address=127.0.0.1四、Apache
1、apache server
作为的今天apache web服务器已经是街知港闻了。 % cd /usr/ports/www/apache22/ % make install clean │ Options for python 2.4.3 │ │ │ [X] THREADS Enable thread support │ ││ │ [ ] HUGE_STACK_SIZE Use a larger thread stack │ │
│ │ [X] UCS4 Use UCS4 for unicode support │ │
│ │ [X] PYMALLOC Use python's internal malloc │ │
│ │ [ ] IPV6 Enable IPv6 support │ │
│ │ [ ] FPECTL Enable floating point exception handling
在/etc/rc.conf 中加入:
apache22_enable="YES"如果启动时出现httpd: Could not reliably determine the
server's fully qualified domain name, using mail.sharesky.cn for ServerName 的错误,
在/usr/local/etc/apache22/httpd.conf 约第144行的位置加入下面的内容。
ServerName mail.extmail.org启动apahce
% /usr/local/etc/rc.d/apache22.sh start Performing sanity check on apache22 configuration: Syntax OK Starting apache22.2、PHP
% cd /usr/ports/www/mod_php4/ % make install cleanOptions for mod_php4 4.4.2_1,1x x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x x x [ ] DEBUGEnable debugx x x x [X] MULTIBYTEEnable zend multibyte support x x x x [ ] IPV6 Enable ipv6 support x x x x [X] OPENSSLBuild static OpenSSL extension在/usr/local/etc/apache22/httpd.conf 里加入
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps加入目录索引 index.php,约在httpd.conf 的212行
DirectoryIndex index.html index.phprestart或reload Apache 使之生效
% /usr/local/etc/rc.d/apache22.sh reload Performing sanity check on apache22 configuration: Syntax OK Performing a graceful restart3、PHP 扩展
% cd /usr/ports/lang/php4-extensions/ % make install clean在这里建议大家,如果没有必要尽量不要GD库免得浪费时间,大家可据自己需要选择模块lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x Options for php4-extensions 1.0x x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x x x[ ] BCMATH bc style precision math functionsx x x x[X] BZ2bzip2 library supportx x x x[ ] CALENDAR calendar conversion supportx x x x[ ] CRACKcrack supportx x x x[X] CTYPEctype functionsx x x x[X] CURL CURL support x x x x[ ] DBAdba supportx x x x[ ] DBASEdBase library supportx x x x[ ] DBXdbx supportx x x x[ ] DIODirect I/O support x x x x[ ] DOMXML DOM supportx x x x[ ] EXIF EXIF support x x x x[ ] FILEINFO fileinfo support x x x x[ ] FILEPROfilePro supportx x x x[ ] FRIBIDIFriBidi support x x[X] FTPFTP supportx x x x[ ] GD GD library support x x x x[X] GETTEXTgettext library supportx x x x[ ] GMPGNU MP support x x x x[X] ICONViconv supportx x x x[ ] IMAGICKImageMagick supportx x x x[X] IMAP IMAP support x x x x[ ] INTERBASEInterbase 6 database support (Firebird)x x x x[ ] LDAP OpenLDAP support x x x x[X] MBSTRING multibyte string support x x x x[ ] MCAL Modular Calendar Access Library supportx x x x[X] MCRYPT Encryption support x x x x[ ] MCVE MCVE support x x x x[ ] MHASHCrypto-hashing support x x x x[ ] MING ming shockwave flash support x x x x[ ] MNOGOSEARCHmnoGoSearch supportx x x x[ ] MSSQLMS-SQL database supportx x x x[X] MYSQLMySQL database support x x x x[ ] NCURSESncurses support (CLI only) x x x x[ ] ODBC unixODBC support x x x x[X] OPENSSLOpenSSL supportx x x x[ ] ORACLE Oracle support x x x x[X] OVERLOAD user-space object overloading supportx x x x[ ] PANDApanda supportx x x x[ ] PCNTLpcntl support (CLI only) x x x x[X] PCRE Perl Compatible Regular Expression support x x x x[ ] PDFPDFlib support (implies GD)x x x x[ ] PFPROPayFlow Pro supportx x x x[ ] PGSQLPostgreSQL database supportx x x x[X] POSIXPOSIX-like functions x x x x[ ] PSPELL pspell support x x x x[ ] READLINE readline support (CLI only)x x x x[ ] RECODE recode support x x x x[X] SESSIONsession supportx x x x[ ] SHMOPshmop supportx x x x[ ] SNMP SNMP support x x x x[ ] SOCKETSsockets supportx x x x[ ] SYBASE_CTSybase database supportx x x x[ ] SYSVMSGSystem V message support x x x x[ ] SYSVSEMSystem V semaphore support x x x x[ ] SYSVSHMSystem V shared memory support x x x x[X] TOKENIZERtokenizer supportx x x x[ ] WDDX WDDX support (implies XML) x x x x[X] XMLXML supportx x x x[ ] XMLRPC XMLRPC-EPI support x x x x[ ] XSLT XSLT Sablotron support x x x x[ ] YAZYAZ support (ANSI/NISO Z39.50) x x x x[ ] YP YP/NIS support x x x x[ ] ZIPZIP supportx x x x[X] ZLIB ZLIB support x x
# vi /usr/local/www/apache22/data/test.php
输入:
4、phpmyadmin 管理数据库
为了去除无聊的过程,这里选择手工,先下载软件包,然后解压,再复制到/usr/local/www/apache22/data 下面
%cd /usr/ports/databases/phpmyadmin/ %make fetch %cd /usr/ports/distfile %tar jxvf phpMyAdmin-2.7.0-pl2.tar.bz2 %cp -r /usr/ports/distfiles/phpMyAdmin-2.7.0-pl2 /usr/local/www/apache22/data/phpmyadmin %cd /usr/local/www/apache22/data/phpmyadmin/ %ee config.default.php将$cfg['Servers'][$i]['auth_type'] = 'config'; 改为
$cfg['Servers'][$i]['auth_type'] = 'http'; 打开页面弹出验证窗口。打开http://ip/phpmyadmin 就可以管理你的mysql 数据库了
推出保存 #chmod 755 test.php
大家注意,可能你下载的版本与我下载的不一样,不能照搬。
phpmyadmin
phpMyAdmin-2.8.1 版的Port .
# whereis phpmyadmin
phpmyadmin: /usr/ports/databases/phpmyadmin
cd /usr/ports/databases/phpmyadmin
make install clean
#cd /usr/local/www/phpMyAdmin/
进入phpmyadmin下的libraries 目录!
修改 config.default.php
#vi libraries/config.default.php
找到$cfg['PmaAbsoluteUri'] = '';
修改成 $cfg['PmaAbsoluteUri'] = 'http://你的IP/phpmyadmin';
找到
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = '';
写上你的Mysql用户名and密码!保存退出!
因为phpmyadmin的PATH 是:/usr/local/www/phpmyadmin
所以我们需要在APACHE里面建立一个Alias:
#vi /usr/local/etc/apache22/httpd.conf
在Alias 组加入下列内容:
*******
Alias /phpmyadmin "/usr/local/www/phpMyAdmin/"
Allow from all
*******
保存退出.
弹出验证窗口。
修改/usr/local/www/phpMyAdmin/libraries/config.default.php
中的:$cfg['Servers'][$i]['auth_type'] = "config"
改成:
$cfg['Servers'][$i]['auth_type'] = 'http';
# /usr/local/etc/rc.d/apache22.sh reload
然后用 IP/phpmyadmin访问!
5 使用同一个IP的虚拟主机:
取消中心主机,在ServerName 前面加井号屏蔽. 添加虚拟主机,比如说,假设你正在为域名提供, 而你又想在同一个IP地址上加一个名叫www.otherdomain.tld的虚拟主机, 你只需在httpd.conf中加入以下内容: NameVirtualHost * 和添加别名是雷同的. 6 WEBMIN mail# whereis webmin make install clean cd /usr/local/etc/webmin sh start
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
DocumentRoot /www/otherdomain
webmin: /usr/ports/sysutils/webmin
cd /usr/ports/sysutils/webmin
然后访问 http://IP:10000
免责声明: 凡标注转载/编译字样内容并非本站原创,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如果你觉得本文好,欢迎推荐给朋友阅读;本文链接: https://m.nndssk.com/xtwt/206058LrANbR.html。
