rpm 命令的再学习
strace 命令的再学习
strace慢怎么解决
/etc/hosts
下载软件我们选择 .gz 不选 bz2
<IfModule dir_module> 首页文件
DirectoryIndex oldboy.html index.html
</IfModule>
apache两个模式的区别
[root@web01 conf]# ../bin/apachectl start
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
[root@web01 conf]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 84432 root 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85352 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85353 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85354 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85436 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
[root@web01 conf]# kill httpd
-bash: kill: httpd: arguments must be process or job IDs
[root@web01 conf]# kill 84432
[root@web01 conf]# lsof -i :80
[root@web01 conf]# ../bin/apachectl start
[root@web01 conf]# ../bin/apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@web01 conf]# vim httpd.conf
ServerName 127.0.0.1:80
[root@web01 conf]# ../bin/apachectl -t
Syntax OK
[root@backup conf]# for name in www blog bbs;do echo "http://$name.etiantian.org" >/var/html/$name/index.html;done
[root@backup conf]# for name in www blog bbs;do cat /var/html/$name/index.html;done
http://www.etiantian.org
http://blog.etiantian.org
http://bbs.etiantian.org
[root@backup extra]# ../../bin/apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@backup extra]# vim ../httpd.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-mpm.conf
[root@backup extra]# ../../bin/apachectl -t
Syntax OK
[root@backup conf]# vim httpd.conf
<Directory "/var/html">
AllowOverride None
Options None
Require all granted
</Directory>
apache日志
通用日志格式:CommonLog Format
组合日志格式:CombinedLog Format
轮询工具
自带:rotatelog
常用:cronolog
方法1
下载cronlog软件
cd /home/lvnian/tools
wget http://down1.chinaunix.net/distfiles/cronolog-1.6.2.tar.gz
tar xf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make && make install
ll /usr/local/sbin/cronolog
#######3
cronlog系统自带方式.把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容
###按天轮询
CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d.log" combined
##按周轮询
##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%w.log" combined
##按小时轮询
##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d%H.log" combined
#########结果
[root@A_WEB logs]# ll /application/apache/logs/
total 52
-rw-r--r-- 1 root root 598 Sep 21 10:50 www.access_20150921.log
###方法2
##系统自带的rotatelogs
###把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined
##重启http服务就可以了
/application/apache/bin/apachectl -t
/etc/init.d/httpd restart
netstat -lnt
ll /application/apache/logs
方法3:
定时任务切割
cd /application/apache/logs/
mv www-access.log www-access_$(date +%F).log
/application/apache/bin/apachectl graceful
修改版本号:
编译安装前
[root@web01 ~]# vim /home/oldboy/tools/httpd-2.4.29/include/ap_release.h
#define AP_SERVER_BASEPRODUCT "Apache"
#define AP_SERVER_MAJORVERSION_NUMBER 2
#define AP_SERVER_MINORVERSION_NUMBER 4
#define AP_SERVER_PATCHLEVEL_NUMBER 29
#define AP_SERVER_DEVBUILD_BOOLEAN 0
改成:
#define AP_SERVER_BASEPRODUCT "IIS"
#define AP_SERVER_MAJORVERSION_NUMBER 7
#define AP_SERVER_MINORVERSION_NUMBER 0
#define AP_SERVER_PATCHLEVEL_NUMBER 0
#define AP_SERVER_DEVBUILD_BOOLEAN 0
[root@web01 ~]# vim /home/oldboy/tools/httpd-2.4.29/os/unix/os.h
改成不是“unix”
#define PLATFORM "windows"
编译安装后:
[root@web01 ~]# vim /application/apache/conf/extra/httpd-default.conf
ServerTokens Prod
ServerSignature Off
[root@web01 ~]# vim /application/apache/conf/extra/httpd-default.conf
Include conf/extra/httpd-default.conf
[root@web01 ~]# curl -I 10.0.0.8
HTTP/1.1 200 OK
Date: Tue, 12 Jun 2018 08:54:53 GMT
Server: Apache
Last-Modified: Tue, 12 Jun 2018 06:49:24 GMT
ETag: "19-56e6c444bf85e"
Accept-Ranges: bytes
Content-Length: 25
Content-Type: text/html
apache 403 Forbidden
原创lvnian20092015-09-20 22:43:25评论(0)208人阅读
1.禁止Indexes参数
下面是设置站点目录/application/apache2.22.27/htdocs的权限问题,其中Indexes参数,是在该站点目录下,如果没有首页文件 index.XXX 如果带有Indexes参数就会显示这个站点目录的结构,如果把Indexes参数去掉,那么就出出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#####################相关参数设置成下面,将出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html ##只要在/application/apache2.22.27/htdocs目录下面不存在index.html文件就会出现403
</IfModule>
Apache 403 Forbidden
1.禁止Indexes参数,且站点目录中不存在首页文件
下面是设置站点目录/application/apache2.22.27/htdocs的权限问题,其中Indexes参数,是在该站点目录下,如果没有首页文件 index.XXX 如果带有Indexes参数就会显示这个站点目录的结构,如果把Indexes参数去掉,那么就出出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#####################相关参数设置成下面,将出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
禁止Indexes参数是一个优化的功能,因为如果你不禁止Indexes参数,那么在没有首页文件的时候,那么访问这个网站的时候就会列出整个站点的目录结构,这是极其不安全的
2.每增加一个站点目录,就需要增加下面内容,给增加的目录赋予相关权限
<Directory "增加的目录路径如:/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
如果你不增加上面的内容,那么就出出现403错误
3.就算你正确设置了2中的权限问题,但是站点目录不设置对其他人为可读。
<Directory "增加的目录路径如:/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
也指定的首页文件 index.html,你的站点目录也存在index.html 但是如果你的这个站点chmod 权限不允许其他人读。那么也会是403 错误
[root@A_WEB apache]# ll htdocs -d
d-wx--x--x 2 root root 4096 Sep 20 23:11 htdocs
apache日志不记录指定格式元素的日志
apache不记录指点网站元素的日志,为什么需要这样做,什么情况下需要这样做:
当计算日志pv时,一般不需要统计图片元素的日志,因为,打开一个网页才是一个PV,当RS服务器不希望记录
来自前端负责均衡健康检查的无用日志,整个配置需要mod_setenvif模块的支持,下面我们的案例
案例1:apache不记录图片日志
答:因为统计日志PV时一个页面才算一个PV,而图片js,css等只是图片的元素,如果记录在日志里,然后按日志统计pv那么统计的PV是不准确的。所以考虑不记录图片等日志信息
<FilesMastch "\.(css|js|gif|jpg|ico|swf)">
SetEnv IMAG 1
<\FilesMastch>
实际的日志配置
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined env=!IMAG
案例2:RS服务器不记录负载均衡健康检查日志
虚拟主机不记录负载均衡向下健康检查文件的日志
SetEnvIf Request_URL "^/check\.txt$" dontlog
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined env=!dontlog
#########################################################################################
mysql
[root@web01 ~]# groupadd mysql
[root@web01 ~]# useradd mysql -g mysql -M -s /sbin/nologin
[root@web01 ~]# id mysql
[root@web01 tools]# rz
[root@web01 tools]# ll
[root@web01 tools]# tar xf mysql-5.5.54-linux2.6-x86_64.tar.gz
#########################################################################################
Nginx
配置简单,更灵活
高并发(静态小文件),静态1--2W
占用资源少。2W并发开10个线程服务,内存消耗几百M
功能种类比较多(Web,cache,proxy),每一个功能都不是特别强
支持epoll模型。使得NGINX可以可以支持高并发!
nginx配合动态服务和apache有区别
利用nginx可以对IP限速,可以限制连接数
对比讲解LAMP和LNMP实现原理,架构:
Nginx的应用场合:
1.静态服务器(图片,视频服务),另一个ligettpd。并发:1--3W
html,js,css,flv等。
2.动态服务,nginx+fastcgi的方式运行php,jdp。并发:500-1500。
apache+php,lighttpd+fcgi php
3.反向代理,负载均衡。日PV2000W以下,都可以直接用NGINX做代理
hapcrocxy , F5 , a10
4.缓存服务。SQUID VARNISH.
nginx虚拟主机 :
nginx虚拟主机 :
<VirtualHost> ==> server { }
一个server标签就是一个虚拟主机
1.基于域名的虚拟主机。通过域名来区分虚拟主机 ==》应用:外部网站
2.基于端口的虚拟主机。通过端口来区分虚拟主机 ==》应用:公司内部网站,外部网站的后端
3.基于IP的虚拟主机。几乎不用。不支持ifconfig别名,配置文件可以。
pcre库软件 中文perl兼容正则表达式。是为了 是NGINX支持 HTTP Rewrite 作用
yum 安装软件的 经验 软件 软件 +devel
openssl库软件 作用
nginx 安装
准备
yum pcre pcre-devel -yum
yum install openssl openssl-devel
安装
wget
tar xf
cd nginx-1.6.2
./configure
nginx 安装出现的错误即改错方法
排错
ping 物理通不通
telnet 浏览器到 web服务通不通
curl WEB服务开没开
默认站点
apache默认站点目录的参数
DocumnetRoot htdocs
Nginx默认站点目录的参数
root html
学会通过 http://nginx.org/en/docs/查看模块的使用帮助
apache和 nginx的首页文件 各是什么
DirectoryIndex
index
./configure --prefix=/application/php5.5.27 --with-mysql=/application/mysql/ --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-openssl --with-mhash --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no
ip配 ifconfig可以看到
[root@lb01 ~]# ip addr add 10.0.0.3/24 dev eth0 label eth0:0
LNMP的配置
nginx和apache
首页文件
别名
功能:
1)别名地址栏还是 lg.com ==》www.lg.com的内容
2)lg.com跳转地址栏www.lg.com(rewrite)
3)ip访问,第一个标签的内容
4)解决恶意域名绑定。 方法
apache日志轮询:
1.cronolog
2.rotatelog
3.cron+mv+graceful
nginx日志轮询:
3.cron+mv
生产环境常见的HTTP状态码列表
200 服务器成功返回网页
301 永久跳转,请求的网页已永久跳转到新位置
403 禁止访问,服务器拒绝请求
404 服务器找不到请求的页面
500 内部服务器错误
##########################################################################################
strace 命令的再学习
strace慢怎么解决
/etc/hosts
下载软件我们选择 .gz 不选 bz2
<IfModule dir_module> 首页文件
DirectoryIndex oldboy.html index.html
</IfModule>
apache两个模式的区别
[root@web01 conf]# ../bin/apachectl start
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
[root@web01 conf]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 84432 root 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85352 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85353 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85354 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
httpd 85436 daemon 4u IPv6 70843 0t0 TCP *:http (LISTEN)
[root@web01 conf]# kill httpd
-bash: kill: httpd: arguments must be process or job IDs
[root@web01 conf]# kill 84432
[root@web01 conf]# lsof -i :80
[root@web01 conf]# ../bin/apachectl start
[root@web01 conf]# ../bin/apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@web01 conf]# vim httpd.conf
ServerName 127.0.0.1:80
[root@web01 conf]# ../bin/apachectl -t
Syntax OK
[root@backup conf]# for name in www blog bbs;do echo "http://$name.etiantian.org" >/var/html/$name/index.html;done
[root@backup conf]# for name in www blog bbs;do cat /var/html/$name/index.html;done
http://www.etiantian.org
http://blog.etiantian.org
http://bbs.etiantian.org
[root@backup extra]# ../../bin/apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@backup extra]# vim ../httpd.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-mpm.conf
[root@backup extra]# ../../bin/apachectl -t
Syntax OK
[root@backup conf]# vim httpd.conf
<Directory "/var/html">
AllowOverride None
Options None
Require all granted
</Directory>
apache日志
通用日志格式:CommonLog Format
组合日志格式:CombinedLog Format
轮询工具
自带:rotatelog
常用:cronolog
方法1
下载cronlog软件
cd /home/lvnian/tools
wget http://down1.chinaunix.net/distfiles/cronolog-1.6.2.tar.gz
tar xf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make && make install
ll /usr/local/sbin/cronolog
#######3
cronlog系统自带方式.把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容
###按天轮询
CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d.log" combined
##按周轮询
##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%w.log" combined
##按小时轮询
##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d%H.log" combined
#########结果
[root@A_WEB logs]# ll /application/apache/logs/
total 52
-rw-r--r-- 1 root root 598 Sep 21 10:50 www.access_20150921.log
###方法2
##系统自带的rotatelogs
###把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined
##重启http服务就可以了
/application/apache/bin/apachectl -t
/etc/init.d/httpd restart
netstat -lnt
ll /application/apache/logs
方法3:
定时任务切割
cd /application/apache/logs/
mv www-access.log www-access_$(date +%F).log
/application/apache/bin/apachectl graceful
修改版本号:
编译安装前
[root@web01 ~]# vim /home/oldboy/tools/httpd-2.4.29/include/ap_release.h
#define AP_SERVER_BASEPRODUCT "Apache"
#define AP_SERVER_MAJORVERSION_NUMBER 2
#define AP_SERVER_MINORVERSION_NUMBER 4
#define AP_SERVER_PATCHLEVEL_NUMBER 29
#define AP_SERVER_DEVBUILD_BOOLEAN 0
改成:
#define AP_SERVER_BASEPRODUCT "IIS"
#define AP_SERVER_MAJORVERSION_NUMBER 7
#define AP_SERVER_MINORVERSION_NUMBER 0
#define AP_SERVER_PATCHLEVEL_NUMBER 0
#define AP_SERVER_DEVBUILD_BOOLEAN 0
[root@web01 ~]# vim /home/oldboy/tools/httpd-2.4.29/os/unix/os.h
改成不是“unix”
#define PLATFORM "windows"
编译安装后:
[root@web01 ~]# vim /application/apache/conf/extra/httpd-default.conf
ServerTokens Prod
ServerSignature Off
[root@web01 ~]# vim /application/apache/conf/extra/httpd-default.conf
Include conf/extra/httpd-default.conf
[root@web01 ~]# curl -I 10.0.0.8
HTTP/1.1 200 OK
Date: Tue, 12 Jun 2018 08:54:53 GMT
Server: Apache
Last-Modified: Tue, 12 Jun 2018 06:49:24 GMT
ETag: "19-56e6c444bf85e"
Accept-Ranges: bytes
Content-Length: 25
Content-Type: text/html
apache 403 Forbidden
原创lvnian20092015-09-20 22:43:25评论(0)208人阅读
1.禁止Indexes参数
下面是设置站点目录/application/apache2.22.27/htdocs的权限问题,其中Indexes参数,是在该站点目录下,如果没有首页文件 index.XXX 如果带有Indexes参数就会显示这个站点目录的结构,如果把Indexes参数去掉,那么就出出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#####################相关参数设置成下面,将出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html ##只要在/application/apache2.22.27/htdocs目录下面不存在index.html文件就会出现403
</IfModule>
Apache 403 Forbidden
1.禁止Indexes参数,且站点目录中不存在首页文件
下面是设置站点目录/application/apache2.22.27/htdocs的权限问题,其中Indexes参数,是在该站点目录下,如果没有首页文件 index.XXX 如果带有Indexes参数就会显示这个站点目录的结构,如果把Indexes参数去掉,那么就出出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#####################相关参数设置成下面,将出现403 Forbidden
<Directory "/application/apache2.22.27/htdocs">
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
禁止Indexes参数是一个优化的功能,因为如果你不禁止Indexes参数,那么在没有首页文件的时候,那么访问这个网站的时候就会列出整个站点的目录结构,这是极其不安全的
2.每增加一个站点目录,就需要增加下面内容,给增加的目录赋予相关权限
<Directory "增加的目录路径如:/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
如果你不增加上面的内容,那么就出出现403错误
3.就算你正确设置了2中的权限问题,但是站点目录不设置对其他人为可读。
<Directory "增加的目录路径如:/application/apache2.22.27/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
也指定的首页文件 index.html,你的站点目录也存在index.html 但是如果你的这个站点chmod 权限不允许其他人读。那么也会是403 错误
[root@A_WEB apache]# ll htdocs -d
d-wx--x--x 2 root root 4096 Sep 20 23:11 htdocs
apache日志不记录指定格式元素的日志
apache不记录指点网站元素的日志,为什么需要这样做,什么情况下需要这样做:
当计算日志pv时,一般不需要统计图片元素的日志,因为,打开一个网页才是一个PV,当RS服务器不希望记录
来自前端负责均衡健康检查的无用日志,整个配置需要mod_setenvif模块的支持,下面我们的案例
案例1:apache不记录图片日志
答:因为统计日志PV时一个页面才算一个PV,而图片js,css等只是图片的元素,如果记录在日志里,然后按日志统计pv那么统计的PV是不准确的。所以考虑不记录图片等日志信息
<FilesMastch "\.(css|js|gif|jpg|ico|swf)">
SetEnv IMAG 1
<\FilesMastch>
实际的日志配置
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined env=!IMAG
案例2:RS服务器不记录负载均衡健康检查日志
虚拟主机不记录负载均衡向下健康检查文件的日志
SetEnvIf Request_URL "^/check\.txt$" dontlog
CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined env=!dontlog
#########################################################################################
mysql
[root@web01 ~]# groupadd mysql
[root@web01 ~]# useradd mysql -g mysql -M -s /sbin/nologin
[root@web01 ~]# id mysql
[root@web01 tools]# rz
[root@web01 tools]# ll
[root@web01 tools]# tar xf mysql-5.5.54-linux2.6-x86_64.tar.gz
#########################################################################################
Nginx
配置简单,更灵活
高并发(静态小文件),静态1--2W
占用资源少。2W并发开10个线程服务,内存消耗几百M
功能种类比较多(Web,cache,proxy),每一个功能都不是特别强
支持epoll模型。使得NGINX可以可以支持高并发!
nginx配合动态服务和apache有区别
利用nginx可以对IP限速,可以限制连接数
对比讲解LAMP和LNMP实现原理,架构:
Nginx的应用场合:
1.静态服务器(图片,视频服务),另一个ligettpd。并发:1--3W
html,js,css,flv等。
2.动态服务,nginx+fastcgi的方式运行php,jdp。并发:500-1500。
apache+php,lighttpd+fcgi php
3.反向代理,负载均衡。日PV2000W以下,都可以直接用NGINX做代理
hapcrocxy , F5 , a10
4.缓存服务。SQUID VARNISH.
nginx虚拟主机 :
nginx虚拟主机 :
<VirtualHost> ==> server { }
一个server标签就是一个虚拟主机
1.基于域名的虚拟主机。通过域名来区分虚拟主机 ==》应用:外部网站
2.基于端口的虚拟主机。通过端口来区分虚拟主机 ==》应用:公司内部网站,外部网站的后端
3.基于IP的虚拟主机。几乎不用。不支持ifconfig别名,配置文件可以。
pcre库软件 中文perl兼容正则表达式。是为了 是NGINX支持 HTTP Rewrite 作用
yum 安装软件的 经验 软件 软件 +devel
openssl库软件 作用
nginx 安装
准备
yum pcre pcre-devel -yum
yum install openssl openssl-devel
安装
wget
tar xf
cd nginx-1.6.2
./configure
nginx 安装出现的错误即改错方法
排错
ping 物理通不通
telnet 浏览器到 web服务通不通
curl WEB服务开没开
默认站点
apache默认站点目录的参数
DocumnetRoot htdocs
Nginx默认站点目录的参数
root html
学会通过 http://nginx.org/en/docs/查看模块的使用帮助
apache和 nginx的首页文件 各是什么
DirectoryIndex
index
./configure --prefix=/application/php5.5.27 --with-mysql=/application/mysql/ --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-openssl --with-mhash --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no
ip配 ifconfig可以看到
[root@lb01 ~]# ip addr add 10.0.0.3/24 dev eth0 label eth0:0
LNMP的配置
nginx和apache
首页文件
别名
功能:
1)别名地址栏还是 lg.com ==》www.lg.com的内容
2)lg.com跳转地址栏www.lg.com(rewrite)
3)ip访问,第一个标签的内容
4)解决恶意域名绑定。 方法
apache日志轮询:
1.cronolog
2.rotatelog
3.cron+mv+graceful
nginx日志轮询:
3.cron+mv
生产环境常见的HTTP状态码列表
200 服务器成功返回网页
301 永久跳转,请求的网页已永久跳转到新位置
403 禁止访问,服务器拒绝请求
404 服务器找不到请求的页面
500 内部服务器错误
##########################################################################################