欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Install Apache2 On Debian
来自开放百科 - 灰狐
(版本间的差异)
小 (→配置PHP) |
|||
(未显示2个用户的37个中间版本) | |||
第1行: | 第1行: | ||
+ | 寻找安装包 | ||
#apt-cache search apache2 | #apt-cache search apache2 | ||
− | + | ==快速安装== | |
#apt-get insall apache2 | #apt-get insall apache2 | ||
− | #apt-get install libapache2-mod-php4 | + | #apt-get install libapache2-mod-php4 or libapache2-mod-php5 |
#apt-get install libapache2-mod-python2.3 | #apt-get install libapache2-mod-python2.3 | ||
− | #apt-get install libapache2-mod-ruby | + | #apt-get install apt-get install ruby1.8 ruby1.8-examples |
+ | #ruby1.8 -version// ruby version info | ||
+ | #apt-get install libapache2-mod-ruby libfcgi-ruby1.8 libfcgi-dev | ||
#apt-get install libapache2-mod-perl2 | #apt-get install libapache2-mod-perl2 | ||
− | #apt-get install php4-mysql | + | #apt-get install mysql-server-4.1 mysql-client-4.1 |
+ | #apt-get install php4-mysql or php5-mysql | ||
+ | #apt-get install python2.3-mysqldb | ||
+ | #apt-get libdbd-mysql-ruby1.8 // Ruby/DBI MySQL driver for Ruby 1.8 | ||
+ | #apt-get install libdbd-mysql-perl // A Perl5 database interface to the MySQL database | ||
+ | |||
+ | #apt-get install postgresql // install postgresql 7.4.7 | ||
+ | #apt-get install php4-pgsql // PostgreSQL module for php4 | ||
+ | #apt-get install python2.3-pygresql // PostgreSQL module for Python | ||
+ | #apt-get install python2.3-pgsql // A Python DB-API 2.0 interface to PostgreSQL v7.x | ||
+ | #apt-get install libdbd-pg-ruby1.8 // Ruby/DBI PostgreSQL driver for Ruby 1.8 | ||
+ | #apt-get install libpg-perl // Perl modules for PostgreSQL | ||
+ | |||
+ | ==修改Apache2== | ||
+ | vi /etc/apache2/sites-enabled/000-default | ||
+ | #RedirectMatch ^/$ /apache2-default/ | ||
+ | |||
+ | ==配置PHP== | ||
+ | 把PHP脚本放在 /var/www 目录下就可以支持运行啦。 | ||
+ | |||
+ | 编译源码 | ||
+ | apt-get install bison // 不安装会出现运行apache时,产生错误:不能加载libphp5.so:undefined symbol: zend_parse_parameters | ||
+ | ./configure --prefix=/usr/local/php5 --disable-libxml --disable-xml --disable-dom --disable-simplexml --disable-xmlreader --disable-xmlwriter | ||
+ | --with-apxs2=/usr/local/apache2/bin/apxs --disable-cli --with-mysqli=/usr/local/mysql5/ --with-pdo-mysql=/usr/local/mysql5/ | ||
+ | 重新编译需运行下 make distclean | ||
+ | or | ||
+ | ./configure --prefix=/usr/local/php5/ --with-mysql=/usr/local/mysql5/ --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib | ||
+ | 在 httpd.conf 中加上:AddType application/x-httpd-php .php | ||
+ | |||
+ | 可能出现问题:checking whether to enable embedded MySQLi support... no mysql_config not found | ||
+ | export PATH=/home/mysql5/bin:$PATH 到 /etc/profile | ||
+ | /usr/bin/ld: cannot find -lmysqld | ||
+ | |||
+ | ==配置Python== | ||
+ | vi /etc/apache2/sites-enabled/000-default, 加入以下内容 | ||
+ | <Directory /var/www/python/> | ||
+ | SetHandler mod_python | ||
+ | PythonHandler mod_python.publisher | ||
+ | </Directory> | ||
+ | |||
+ | 创建index.py文件 | ||
+ | def index(name): | ||
+ | return "Welcome %s" % name | ||
+ | |||
+ | http://localhost/python/?name=huihoo (OK :) | ||
+ | |||
+ | ==配置Perl== | ||
+ | vi /etc/apache2/sites-enabled/000-default, 加入以下内容 | ||
+ | Alias /perl/ /var/www/perl/ | ||
+ | <Location /perl/> | ||
+ | SetHandler perl-script | ||
+ | PerlResponseHandler ModPerl::Registry | ||
+ | PerlOptions +ParseHeaders | ||
+ | Options +ExecCGI | ||
+ | Order allow,deny | ||
+ | Allow from all | ||
+ | </Location> | ||
+ | |||
+ | touch index.pl | ||
+ | #!/usr/bin/perl | ||
+ | print "Content-type: text/plain\n\n"; | ||
+ | print "mod_perl \n"; | ||
+ | |||
+ | http://localhost/perl/index.pl (OK :) | ||
+ | ==配置Ruby== | ||
+ | ruby在apache里是以cgi或是fastcgi的形式运行的。 | ||
+ | |||
+ | vi /etc/apache2/sites-enabled/000-default, 加入以下内容 | ||
+ | Alias /ruby/ "/var/www/ruby/" | ||
+ | <Location /ruby/> | ||
+ | Options ExecCGI | ||
+ | AddHandler cgi-script .cgi | ||
+ | AddHandler fastcgi-script .fcgi .fcg .fpl | ||
+ | AllowOverride all | ||
+ | Order allow,deny | ||
+ | Allow from all | ||
+ | </Location> | ||
+ | |||
+ | touch index.fcgi | ||
+ | #!/usr/bin/ruby1.8 | ||
+ | print "Content-type: text/plain\n\n"; | ||
+ | print "ruby \n"; | ||
+ | |||
+ | ==配置Java== | ||
+ | apt-get install libapache2-mod-jk | ||
+ | 获得jk包 http://www.apache.org/dist/tomcat/tomcat-connectors/jk/ | ||
+ | ./configure --with-apxs=/usr/local/apache2/bin/apxs | ||
+ | 可能出现的问题:configure: error: C++ preprocessor "/lib/cpp" fails sanity check | ||
+ | 解决方法:apt-get install build-essential | ||
+ | make | ||
+ | cp apache-2.0/mod_jk.so /usr/local/apache2/modules/ | ||
+ | 在/apache2/conf添加2个文件:mod_jk.conf和workers.properties. | ||
+ | |||
+ | mod_jk.conf | ||
+ | JkWorkersFile /usr/local/apache2/conf/workers.properties | ||
+ | JkLogLevel info | ||
+ | JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" | ||
+ | JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories | ||
+ | JkRequestLogFormat "%w %V %T" | ||
+ | JkMount /servlet/* worker1 | ||
+ | JkMount /*.jsp worker1 | ||
+ | |||
+ | workers.properties | ||
+ | worker.list=worker1 | ||
+ | worker.worker1.type=ajp13 | ||
+ | worker.worker1.host=localhost | ||
+ | worker.worker1.port=8009 | ||
+ | worker.worker1.lbfactor=50 | ||
+ | worker.worker1.cachesize=10 | ||
+ | worker.worker1.cache_timeout=600 | ||
+ | worker.worker1.socket_keepalive=1 | ||
+ | worker.worker1.socket_timeout=300 | ||
+ | |||
+ | httpd.conf | ||
+ | 在DirectoryIndex中添加 index.jsp | ||
+ | LoadModule jk_module modules/mod_jk.so | ||
+ | Include /usr/local/apache2/conf/mod_jk.conf | ||
+ | |||
+ | *参考: [http://hi.baidu.com/toicine/blog/item/3785ed31154c0a1aebc4af00.html 整合apache2,tomcat.架构web简单服务器] | ||
+ | *[http://tomcat.apache.org/connectors-doc/ Apache Tomcat Connector] | ||
+ | |||
+ | ==参考== | ||
+ | *http://wiki.rubyonrails.com/rails/pages/GettingStartedWithRails | ||
+ | *RailsOnDebianStable - http://wiki.rubyonrails.org/rails/pages/RailsOnDebianStable | ||
+ | |||
+ | [[Category:Apache]] | ||
+ | [[Category:Debian]] |
2012年3月13日 (二) 07:14的最后版本
寻找安装包
#apt-cache search apache2
目录 |
[编辑] 快速安装
#apt-get insall apache2 #apt-get install libapache2-mod-php4 or libapache2-mod-php5 #apt-get install libapache2-mod-python2.3 #apt-get install apt-get install ruby1.8 ruby1.8-examples #ruby1.8 -version// ruby version info #apt-get install libapache2-mod-ruby libfcgi-ruby1.8 libfcgi-dev #apt-get install libapache2-mod-perl2
#apt-get install mysql-server-4.1 mysql-client-4.1 #apt-get install php4-mysql or php5-mysql #apt-get install python2.3-mysqldb #apt-get libdbd-mysql-ruby1.8 // Ruby/DBI MySQL driver for Ruby 1.8 #apt-get install libdbd-mysql-perl // A Perl5 database interface to the MySQL database
#apt-get install postgresql // install postgresql 7.4.7 #apt-get install php4-pgsql // PostgreSQL module for php4 #apt-get install python2.3-pygresql // PostgreSQL module for Python #apt-get install python2.3-pgsql // A Python DB-API 2.0 interface to PostgreSQL v7.x #apt-get install libdbd-pg-ruby1.8 // Ruby/DBI PostgreSQL driver for Ruby 1.8 #apt-get install libpg-perl // Perl modules for PostgreSQL
[编辑] 修改Apache2
vi /etc/apache2/sites-enabled/000-default #RedirectMatch ^/$ /apache2-default/
[编辑] 配置PHP
把PHP脚本放在 /var/www 目录下就可以支持运行啦。
编译源码
apt-get install bison // 不安装会出现运行apache时,产生错误:不能加载libphp5.so:undefined symbol: zend_parse_parameters ./configure --prefix=/usr/local/php5 --disable-libxml --disable-xml --disable-dom --disable-simplexml --disable-xmlreader --disable-xmlwriter --with-apxs2=/usr/local/apache2/bin/apxs --disable-cli --with-mysqli=/usr/local/mysql5/ --with-pdo-mysql=/usr/local/mysql5/ 重新编译需运行下 make distclean
or
./configure --prefix=/usr/local/php5/ --with-mysql=/usr/local/mysql5/ --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib
在 httpd.conf 中加上:AddType application/x-httpd-php .php
可能出现问题:checking whether to enable embedded MySQLi support... no mysql_config not found
export PATH=/home/mysql5/bin:$PATH 到 /etc/profile
/usr/bin/ld: cannot find -lmysqld
[编辑] 配置Python
vi /etc/apache2/sites-enabled/000-default, 加入以下内容
<Directory /var/www/python/> SetHandler mod_python PythonHandler mod_python.publisher </Directory>
创建index.py文件
def index(name): return "Welcome %s" % name
http://localhost/python/?name=huihoo (OK :)
[编辑] 配置Perl
vi /etc/apache2/sites-enabled/000-default, 加入以下内容
Alias /perl/ /var/www/perl/ <Location /perl/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all </Location>
touch index.pl
#!/usr/bin/perl print "Content-type: text/plain\n\n"; print "mod_perl \n";
http://localhost/perl/index.pl (OK :)
[编辑] 配置Ruby
ruby在apache里是以cgi或是fastcgi的形式运行的。
vi /etc/apache2/sites-enabled/000-default, 加入以下内容
Alias /ruby/ "/var/www/ruby/" <Location /ruby/> Options ExecCGI AddHandler cgi-script .cgi AddHandler fastcgi-script .fcgi .fcg .fpl AllowOverride all Order allow,deny Allow from all </Location>
touch index.fcgi
#!/usr/bin/ruby1.8 print "Content-type: text/plain\n\n"; print "ruby \n";
[编辑] 配置Java
apt-get install libapache2-mod-jk 获得jk包 http://www.apache.org/dist/tomcat/tomcat-connectors/jk/ ./configure --with-apxs=/usr/local/apache2/bin/apxs 可能出现的问题:configure: error: C++ preprocessor "/lib/cpp" fails sanity check 解决方法:apt-get install build-essential make cp apache-2.0/mod_jk.so /usr/local/apache2/modules/
在/apache2/conf添加2个文件:mod_jk.conf和workers.properties.
mod_jk.conf
JkWorkersFile /usr/local/apache2/conf/workers.properties JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" JkMount /servlet/* worker1 JkMount /*.jsp worker1
workers.properties
worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300
httpd.conf
在DirectoryIndex中添加 index.jsp LoadModule jk_module modules/mod_jk.so Include /usr/local/apache2/conf/mod_jk.conf
[编辑] 参考
分享您的观点