Ubuntu配置记录-2:关于开发环境的配置
[转]在Emacs下用C、C++编程

Ubuntu配置记录-3:安装网络服务(未完)

Tiger Soldier posted @ 2008年4月04日 03:53 in linux with tags ubuntu apache php mysql ssh vsftpd , 4761 阅读

一、安装Web服务器

1、Apache

首先是安装Apache,输入

sudo apt-get install apache2

安装后的Apache就已经直接可以运行了,可以输入http://127.0.0.1查看效果。 之后是根据自己需要配置了 Apache的配置文件在/etc/apache2/apache2.conf中 Apache的默认站点配置文件在/etc/apache2/sites-enabled/000-default中 Apache的默认站点目录在/var/www/中 要为站点建立子目录,可以在/var/www/下建立相应的目录,也可以在/etc/apache2/sites-enabled创建专用的配置文件。

 

接下来是设置虚拟站点。我是直接在/etc/apache2/sites-enabled下创建专用的配置文件的。

 

在其中任意创建一个文件,然后写入别名站点信息:

Alias /test/ "/home/www/"

Alias的作用是为地址创建别名。假设主机地址是localhost,那么http://localhost/test/就会被Apache映射到/home/www目录下

注意:要确保Apache对目标目录至少有读取权限,最好是有读写权限。一个简单的方法是用“sudo chmod 777 目录名”来开放权限,但是更好的方法是将此目录的所有者设为www-data(Apache所使用的账号)或者将组设为www-data并用chmod 775或者chmod 771。

接着就是写入权限设置了,使用<Directory />段来配置:

<Directory "/home/www/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

相关选项的含义如下:


Options: 提供一系列权限选项,有Indexes(允许列出目录)、MultiViews(多种内容显示方法)、FollowSymLinks(使用符号链接)。其 中Indexes是非常危险的,如果不是作为调试或者个人使用,最好去除。FollowSymLinks应该是指能把Linux的符号链接当作一个正常的 文件吧,没仔细研究。


AllowOverride:是否启用.htaccess配置文件。

 

Order:控制默认的访问状态与Allow和Deny指令生效的顺序。

AllowDeny:设置授权和禁止列表,格式为 Allow(Deny) from all|host|env=env-variable [host|env=env-variable] ...。一般主要用All和host,其中host可以有以下几种用法:

一个(部分)域名

示例:

Allow from apache.org
Allow from .net example.edu

主机名与给定字符串匹配或者以给定字符串结尾的主机允许访问。只有完整的名字组成部分才被匹配,因此上述例子将匹配foo.apache.org但不能匹配fooapache.org 。这样的配置将导致Apache不管HostnameLookups指令是如何设置的,对一个对客户IP地址都要执行两次DNS查询:一次正查询保证IP没有伪造,一次反查询保证主机名没有伪造。只有两次查询的结果都吻合,并且主机名能够被匹配,访问才被允许。

完整的IP地址

示例:

Allow from 10.1.2.3
Allow from 192.168.1.104 192.168.1.205

;允许拥有这些IP地址的主机进行访问。

部分IP地址

示例:

Allow from 10.1
Allow from 10 172.20 192.168.2

IP地址的开始1到3个字节,用于子网限制。

网络/掩码对

示例:

Allow from 10.1.0.0/255.255.0.0

一个网络"a.b.c.d"和一个掩码"w.x.y.z",用于更精确的子网限制。

网络/nnn无类别域间路由规格(CIDR specification)

示例:

Allow from 10.1.0.0/16

同前一种情况相似,除了掩码由nnn个高位字节构成。

注意以上例子中的后三个匹配完全相同的一组主机。

IPv6地址和IPv6子网可以像下面这样指定:

Allow from 2001:db8::a00:20ff:fea7:ccea
Allow from 2001:db8::a00:20ff:fea7:ccea/10

安装PHP

安装PHP很简单,直接用apt-get就行:

sudo apt-get install php5

安装后自动与Apache集成,不用进行额外设置,很方便。

安装MySQL

首先安装MySQL:

sudo apt-get install mysql-server

安装过程中会要求设置root账号。 然后是安装PHP对MySQL的支持:

sudo apt-get install php5-mysql
安装SSH服务

安装:

sudo apt-get install openssh-*

安完就能用了

要重启ssh,可以使用这个命令

sudo /etc/init.d/ssh restart

 

 

要启动和停止ssh,只要把restart换成start和stop就行了

安装vsftpd

安装:

sudo apt-get install vsftpd

为了使用虚拟帐户,还要安装Berkeley Database Utilities:

sudo apt-get install db4.6-util

编辑配置文件:

sudo gedit /etc/vsftpd.conf

内容如下:

# 开启监听模式
listen=YES
# 允许列出文件
dirlist_enable=YES
# 本地用户登录后的要目录位置为home目录
local_root=
# 允许匿名用户
anonymous_enable=YES
# 允许本地用户登录
local_enable=YES
# 默认不允许上传文件
write_enable=NO
# 上传的文件的权限设为644
local_umask=022
# 定义用户个人配置文件所在的目录
user_config_dir=/etc/vsftpd/vsftpd_user_dir
# 允许使用目录欢迎信息文件
dirmessage_enable=YES
# 启用默认数据链接端口
connect_from_port_20=YES
# 禁止用户访问local_root之上的目录,将local_root作为用户的根目录
chroot_local_user=YES
# 启用虚拟用户
guest_enable=YES
# 虚拟用户所使用的本地账号
guest_username=tigersoldier
# 赋予虚拟用户和本地对应账号相同的权限
virtual_use_local_privs=YES
# PAM服务名,用于虚拟用户验证
pam_service_name=vsftpd
#########################################
# 一些其他我不关心也不了解的默认选项
#
# 上传下载日志
xferlog_enable=YES
# 空目录,作为限制目录使用
secure_chroot_dir=/var/run/vsftpd
# SSL的RSA密钥
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

建立相关配置目录:

sudo mkdir -p /etc/vsftpd/vsftpd_user_dir/

 创建编辑虚拟用户文件

sudo gedit /etc/vsftpd/login.txt

内容为一行用户名一行密码,如

upload
up
anim
manga

就创建了两个虚拟用户,一个是upload,密码为up;另一个是anim,密码为manga

生成账号文件对应的db文件,要用上刚才安装的Berkeley Database Utilities:

sudo db4.6_load -T -t hash -f /etc/vsftpd/login.txt /etc/vsftpd/vsftpd_login.db
chmod 600 /etc/vsftpd/vsftpd_login.db

编辑vsftpd的pam服务,用于账号验证:

sudo gedit /etc/pam.d/vsftpd

注意服务的文件名是由vsftpd.conf的pam_service_name决定的

把服务替换成如下内容

auth    required    /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required    /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login  

这个文件原来可能有其他内容,必须去掉,不然会产生认证冲突无法登录

要注意的是,这样做之后就无法用本地账号登录了,如果在配置里没有开启virtual_use_local_privs,虚拟账号的权限等同于匿名用户

为每个账号作特别配置:

账号配置文件要放在vsftpd.conf的user_config_dir段所指定的目录下,在这里是/etc/vsftpd/vsftpd_user_dir

以upload账号为例,编辑文件

sudo gedit /etc/vsftpd/vsftpd_user_dir/upload

格式与vsftpd的配置文件相同,不过只能设置与用户相关的选项。在这里设置上传权限和根目录:

local_root=/home/ftp/upload
write_enable=YES
#anon_upload_enable=YES

注意anon_upload_enable,如果没有配置virtual_use_local_privs=YES,则虚拟账号相当于匿名用户,所以只设write_enable是不够的

研究中……

maid services dubai 说:
Sep 18, 2019 04:06:42 PM

Yet, if you are researching for “regular maintenance, ” you may need maid maintenance services which unfortunately charge usually in line with the number for maids, and also time demanded. Maid maintenance companies could possibly price your services for 25 that will 35 AED hourly.

eastern iowa news 说:
Nov 15, 2019 01:06:41 AM

Look at the skills you require to home based. Just just as in any career, when conversing with a prospective employer highlight those expertise outlined inside the job advertisement. Then give attention to what makes a simple yet effective employee which works from your home.

handi sports 说:
Mar 24, 2020 08:28:13 PM

Athletics Betting Champ c3300k, John Morrison, then took to create his existing, combining the two his love for athletics and figures, in the globe of specialized gambling. John can be well preferred, from people across the world, for the gambling suggestions.

mentholatum home 说:
Mar 24, 2020 08:28:40 PM

The majority of people define extravagance majorly with regard to price but there may be so much more to luxury than simply how much money did you expend. It can be quite hard to help define extravagance homes within the exact technique because it is something derived from several variables.

I sell pittsburgh ho 说:
Mar 24, 2020 08:29:04 PM

For anyone who is buying your dream house that was previously inspected then you need to have your unique inspection done for being protected seeing that fully as is possible. If anyone says to you it's fine make use of the preceding home check up report there're wrong. Your are not covered well by any means. When Habitation Research does your dream house inspection your customer has the ability to get a 18 thirty days warranty with the fee connected with 12 many weeks.

wanamassa reale stat 说:
Mar 24, 2020 08:29:31 PM

So you intend to be roaring success real real estate investor? Very well, you really need your goal setting tools in brand. In order to give the greatest probability of achieving ones goals you ought to be setting CLEVER goals. At this point, not this Webster meaning of clever, but quite SMART for acronym intended for Specific, Measurable, Feasible, Realistic, in addition to Timely.

north bama real esta 说:
Mar 24, 2020 08:29:53 PM

Real estate investment is this legal period encompassing area with something placed on the area like houses, particularly property or home. These usually are immobile or maybe fixed houses. It would be the common jargon utilised in several jurisdictions like Australia, The us, United Kingdom and north america.

atlanta black busine 说:
Mar 24, 2020 08:30:25 PM

One cause of capital of which businesses typically overlook is usually Vendor Credit ratings. Without a robust banking marriage and history of credit dealing having any traditional bank as your own business looking for just a traditional loan or maybe a working business loan can be quite hard and disheartening.

maids in dubai 说:
Apr 29, 2020 06:25:34 PM

After you hire some sort of servant maid to decontaminate you house or office, you usually are permitting her to reach to your very own belongings. And so before selecting a cleaning service, you really should ask a number of questions to discover more regarding her track record information in addition to personal experience. First matter is of which, you really should inquire your buddies, relatives or maybe acquaintances with regards to personal experience while using the servant maids.

painters in Dubai 说:
Apr 29, 2020 06:25:46 PM

If you would like give the house a certain style of atmosphere, then inner surface paints are important. The paints you choose are able to offer either temperature or coolness towards rooms of your dwelling and if you need to paint by yourself or seek the services of house painters; keep as the primary goal we now have many ideas that you consider. These thoughts include buying things such as right colour, colors, colours, schemes, coloration methods, as well as other related facets.

live in maids dubai 说:
Jun 07, 2021 03:10:47 PM

Try to avoid using cellular phones, tablets, televisions for the purpose of televisions whereas cleaning home. Because this will likely slow downwards the pace of this work. At the same time, you will end up having reduced energy in order to keep the vacuuming process. Which means, put separate these distractions to raise the general process.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter