liunx服务使用(apche服务器 也就是web发布)
2013-09-13 19:31
309 查看
有没有想过把自己好玩的东西发布到网上?自己的电脑明明可以练外网的,把自己的图片或者网页的路径到外网查找却显示不了,为什么?因为你的网页或者图片没有发布,学会apahce这个问题就可以解决了,这个服务我也喜欢,很有趣。
httpd
chkconfig --list 服务在那些级别下启用
NetworkManager 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
acpid 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
anacron 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
apmd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
atd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
auditd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
autofs 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
avahi-daemon 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
avahi-dnsconfd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
bluetooth 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
chkconfig --level 35 dhcpd on 把 3 5 里打开dhcpd服务
chkconfig --add dhcpd 添加dhcpd服务(安装源码包后,服务有可能没有装 需要这样自己装)
-----------------------------------------------------------------
web服务起(apache)
安装包:默认是进程模式
httpd-2.2.3-63.el5.i386.rpm
配置文件:
/etc/httpd/conf/httpd.conf
启动服务:
service httpd restart
想要添加数据目录:
/var/www/html/
touch index.html
端口:
80 443 ( https 加密 )
----------------------------------------------
进程模式(进程用的多)
100 <IfModule prefork.c>
101 StartServers 8
102 MinSpareServers 5
103 MaxSpareServers 20
104 ServerLimit 256
105 MaxClients 256
106 MaxRequestsPerChild 4000
线程模式
116 <IfModule worker.c>
117 StartServers 2
118 MaxClients 150
119 MinSpareThreads 25
120 MaxSpareThreads 75
121 ThreadsPerChild 25
122 MaxRequestsPerChild 0
------------------------------
进程模式和线程模式切换:
vim /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker 去注释
----
[root@localhost sbin]# ls /usr/sbin/httpd
httpd httpd.event 进程模式 httpd.worker 现成模式
mv /usr/sbin/httpd /usr/sbin/httpd.prefork
mv /usr/sbin/httpd.worker /usr/sbin/httpd
两种方法都要重启服务
ps -ef |grep httpd 查看httpd的是什么模式
---------------------------
基于用户家目录发布网页
<IfModule mod_userdir.c>
#UserDir disable 注释掉
UserDir public_html
</IfModule>
useradd tom
useradd jerry
mkdir /home/jerry/public_html
mkdir /home/jerry/public_html
echo "tom home" >> /home/tom/public_html/index.html
echo "jerry home" >> /home/jerry/public_html/index.html
chmod 755 /home/xu
----------------------------------------------
用文件模式看网页
elinks -dump 192.168.1.2
--------------------
别名
alias /down /usr
<directory /usr>
options indexes
order deny,allow
allow from 192.168.1.0/24 允许
deny from 10.10.10.10/24 拒绝
</directory>
如果规则冲突 由后往前读order表 处于后边的关键字优先生效
-------------------------------------
用户验证访问
alias /down /usr
<directory /usr>
options indexes
AuthType Basic 验证类型
AuthName "Please insert your name and passwd!!!!!!!" 提示语
AuthBasicProvider file 验证方式
AuthUserFile /etc/httpd/passwdb 文件位置
Require user robin 有效用户
#Require valid-user 所有文件内用户
</directory>
创建 添加
htpasswd -c -b /etc/httpd/passwdb robin 123
htpasswd -b /etc/httpd/passwdb eric 123
-------------------------------------
发布cgi脚本
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
-------------------------
touch /var/www/cgi-bin/cgi.sh
chmod +x cgi.sh
vim cgi.sh
#!/bin/bash
echo -e "Content-type: text/html\n" 固定格式
uname -a
echo "<br>"
date
echo
cat /etc/passwd
----------------------------------------------------
虚拟主机
基于域名的主机
vim /etc/httpd/conf/httpd.conf 配置文件
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/sina
ServerName www.sina.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/sohu
ServerName www.sohu.com
</VirtualHost>
mkdir /var/www/html/sina
mkdir /var/www/html/sohu
echo "sina" >> /var/www/html/sina/index.html
echo "sohu" >> /var/www/html/sohu/index.html
cat /etc/hosts
192.168.1.2www.sohu.com
192.168.1.2www.sina.com
基于ip
vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.1.2:80>
DocumentRoot /var/www/html/sina
ServerName www.sina.com
</VirtualHost>
<VirtualHost 10.10.10.1:80>
DocumentRoot /var/www/html/sohu
ServerName www.sohu.com
</VirtualHost>
mkdir /var/www/html/sina
mkdir /var/www/html/sohu
echo "sina" >> /var/www/html/sina/index.html
echo "sohu" >> /var/www/html/sohu/index.html
cat /etc/hosts
192.168.1.2www.sohu.com
10.10.10.1www.sina.com
基于端口
Listen 80
Listen 8080
<VirtualHost *:80>
DocumentRoot /var/www/html/sina
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /var/www/html/sohu
</VirtualHost>
本文出自 “history_xcy” 博客,请务必保留此出处http://historys.blog.51cto.com/7903899/1296664
httpd
chkconfig --list 服务在那些级别下启用
NetworkManager 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
acpid 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
anacron 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
apmd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
atd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
auditd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
autofs 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
avahi-daemon 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
avahi-dnsconfd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
bluetooth 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
chkconfig --level 35 dhcpd on 把 3 5 里打开dhcpd服务
chkconfig --add dhcpd 添加dhcpd服务(安装源码包后,服务有可能没有装 需要这样自己装)
-----------------------------------------------------------------
web服务起(apache)
安装包:默认是进程模式
httpd-2.2.3-63.el5.i386.rpm
配置文件:
/etc/httpd/conf/httpd.conf
启动服务:
service httpd restart
想要添加数据目录:
/var/www/html/
touch index.html
端口:
80 443 ( https 加密 )
----------------------------------------------
进程模式(进程用的多)
100 <IfModule prefork.c>
101 StartServers 8
102 MinSpareServers 5
103 MaxSpareServers 20
104 ServerLimit 256
105 MaxClients 256
106 MaxRequestsPerChild 4000
线程模式
116 <IfModule worker.c>
117 StartServers 2
118 MaxClients 150
119 MinSpareThreads 25
120 MaxSpareThreads 75
121 ThreadsPerChild 25
122 MaxRequestsPerChild 0
------------------------------
进程模式和线程模式切换:
vim /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker 去注释
----
[root@localhost sbin]# ls /usr/sbin/httpd
httpd httpd.event 进程模式 httpd.worker 现成模式
mv /usr/sbin/httpd /usr/sbin/httpd.prefork
mv /usr/sbin/httpd.worker /usr/sbin/httpd
两种方法都要重启服务
ps -ef |grep httpd 查看httpd的是什么模式
---------------------------
基于用户家目录发布网页
<IfModule mod_userdir.c>
#UserDir disable 注释掉
UserDir public_html
</IfModule>
useradd tom
useradd jerry
mkdir /home/jerry/public_html
mkdir /home/jerry/public_html
echo "tom home" >> /home/tom/public_html/index.html
echo "jerry home" >> /home/jerry/public_html/index.html
chmod 755 /home/xu
----------------------------------------------
用文件模式看网页
elinks -dump 192.168.1.2
--------------------
别名
alias /down /usr
<directory /usr>
options indexes
order deny,allow
allow from 192.168.1.0/24 允许
deny from 10.10.10.10/24 拒绝
</directory>
如果规则冲突 由后往前读order表 处于后边的关键字优先生效
-------------------------------------
用户验证访问
alias /down /usr
<directory /usr>
options indexes
AuthType Basic 验证类型
AuthName "Please insert your name and passwd!!!!!!!" 提示语
AuthBasicProvider file 验证方式
AuthUserFile /etc/httpd/passwdb 文件位置
Require user robin 有效用户
#Require valid-user 所有文件内用户
</directory>
创建 添加
htpasswd -c -b /etc/httpd/passwdb robin 123
htpasswd -b /etc/httpd/passwdb eric 123
-------------------------------------
发布cgi脚本
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
-------------------------
touch /var/www/cgi-bin/cgi.sh
chmod +x cgi.sh
vim cgi.sh
#!/bin/bash
echo -e "Content-type: text/html\n" 固定格式
uname -a
echo "<br>"
date
echo
cat /etc/passwd
----------------------------------------------------
虚拟主机
基于域名的主机
vim /etc/httpd/conf/httpd.conf 配置文件
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/sina
ServerName www.sina.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/sohu
ServerName www.sohu.com
</VirtualHost>
mkdir /var/www/html/sina
mkdir /var/www/html/sohu
echo "sina" >> /var/www/html/sina/index.html
echo "sohu" >> /var/www/html/sohu/index.html
cat /etc/hosts
192.168.1.2www.sohu.com
192.168.1.2www.sina.com
基于ip
vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.1.2:80>
DocumentRoot /var/www/html/sina
ServerName www.sina.com
</VirtualHost>
<VirtualHost 10.10.10.1:80>
DocumentRoot /var/www/html/sohu
ServerName www.sohu.com
</VirtualHost>
mkdir /var/www/html/sina
mkdir /var/www/html/sohu
echo "sina" >> /var/www/html/sina/index.html
echo "sohu" >> /var/www/html/sohu/index.html
cat /etc/hosts
192.168.1.2www.sohu.com
10.10.10.1www.sina.com
基于端口
Listen 80
Listen 8080
<VirtualHost *:80>
DocumentRoot /var/www/html/sina
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /var/www/html/sohu
</VirtualHost>
本文出自 “history_xcy” 博客,请务必保留此出处http://historys.blog.51cto.com/7903899/1296664
相关文章推荐
- 使用Axis的wsdd描述方式发布Web服务
- 使用Axis发布简单的Web服务
- Android版Web服务器实现(二)使用服务来监听HTTP请求
- 使用linux系统作为服务器发布web项目
- 使用XFire轻松将POJO发布成web 服务
- vue.js使用webpack发布,部署到服务器上之后在浏览器中可以查看到vue文件源码
- 使用Axis发布简单的Web服务
- 使用axis2插件来生成gsoap发布的Web服务的java客户端代码
- 使用Eclipse发布Web项目并部署到Tomcat服务器
- liunx服务(Nginx服务器 web服务器源码包和rpm 服务平滑升级)
- 在WebLogic服务器下 使用Apache Web 服务插件
- Maven搭建webService (二) 创建服务端---使用web方式发布服务
- 使用nginx反向代理发布多个域名80端口的WEB服务
- 杂记3:VS使用Web Deploy一键发布网站到服务器
- 使用HttpWebRequest从一台服务机器上下载到另一台服务器
- 使用XFire发布和调用web服务
- 个人电脑变成服务器,使用ngrok将本地Web服务映射到外网
- 使用Python WSGI编写Web服务器前端,并利用Boost.Python在同一进程内连接到C++服务后端实现
- 使用Python编写免安装运行时、以Windows后台服务形式运行的WEB服务器
- 使用Rsync+sersync架构(多实例),保持web服务器网页发布目录实时同步