Maison > Article > développement back-end > lighttpd+php+mysql+openssl
FreeBSD 下Web环境的构建.
1 安装MySQL
这里是自己使用源码编译安装。
需要下载MySQL-4.0.25源码包。
cd /opt/distfiles
wget xxx
tar -zxvf mysql-4.0.25.tar.gz -C src
cd src/mysql-4.0.25/
./configure ?prefix=/opt/modules/mysql
?enable-assembler
?with-mysqld-ldflags=-all-static
?with-charset=gb2312
?without-debug
make
make install
/opt/modules/mysql/bin/mysql_install_db
chown -R mysql.mysql /opt/modules/mysql/var
chgrp mysql /opt/modules/mysql
2 安装PHP
./configure
?prefix=/opt/modules/phpcgi
?enable-fastcgi
?enable-force-cgi-redirect
?enable-bcmath
?enable-inline-optimization
?enable-magic-quotes
?enable-wddx?disable-debug
?enable-sysvmsg
?enable-sockets
?enable-mbstring
?enable-calendar
?with-trans-sid
?with-ldap
?with-ldap-sasl
?with-mysql=/opt/modulels/mysql
3 安装lighttpd
cd /usr/ports/www/lighttpd/
make install clean
执行后,将会提示一些选项只要选中OPENSSL 就可以了,其他的不用选。
4 整合配置
4.1 修改默认网站文件路径
server.document-root = “/opt/data/www/”
4.2 打开fastcgi模块支持
将 #”mod_fastcgi”, 的#去掉
4.3 设定PHP支持
#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( “.php” =>
( “localhost” =>
(
“socket” => “/tmp/php-fastcgi.socket”,
“bin-path” => “/opt/modules/phpcgi/bin/php”,
# 如果你的网站很繁忙,可以加入如下设置
#”bin-environment” => (
# “PHP_FCGI_CHILDREN” => “16″,
# “PHP_FCGI_MAX_REQUESTS” => “10000″
#)
#”bin-path” => “/usr/local/bin/php”
)))
4.4 创建日志文件及设置权限
touch /var/log/lighttpd.error.log
touch /var/log/lighttpd.access.log
chown www:www /var/log/lighttpd.*
4.5 设置SSL支持
4.5.1 创建证书
cd /opt/etc/
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
4.5.2 打开SSL支持
#### SSL engine
ssl.engine = “enable”
ssl.pemfile = “/opt/etc/server.pem”
4.6 设置监听端口
默认的监听端口是 80,如果需要更改端口,可以修改配置设定。
## bind to port (default: 80)
#server.port = 81
5 启动
5.1 设置自动启动
vi /etc/rc.conf
lighttpd_enable=”YES”
5.2 手工启动
/usr/local/etc/rc.d/lighttpd.sh start
注意,如果没有在/etc/rc.conf添加 /etc/rc.conf ,是不能启动的。所以需要先添加。