nginx服务与LNMP的部署
原创
©著作权归作者所有:来自51CTO博客作者A~良人归未的原创作品,请联系作者获取转载授权,否则将追究法律责任
- 俄罗斯
- 与apache区别的最大优点:高并发连接(30000~50000)
低消耗
- useradd -M -s /sbin/nologin
- --with-http_stub_status_module
- 做软连接,需要注意的是nginx有两个命令目录。都需要做软连接。
- #!/bin/bash
#chkconfig: - 99 20
#description:Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
pkill nginx
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
- 运行用户
工作进程数量
错误日志文件位置:消息等级
pid文件位置
- 在events中可添加use epoll
提高并发连接,支持非活跃连接。
- 定义了服务的基本信息:访问日志,http端口,字符集等
- location /status {
stub_status on;
access_log off;
}
- 软件包:httpd-tools
- 用htpasswd创建用户与文件
- htpasswd -c /usr/local/nginx/passwd.db test
- 为了提高安全性将该文件权限设置为400
- 在主配置文件中,对需要进行访问控制的站点写入如下语句
- auth_basic "secret";
auth_basic_user_file /usr/local/nginx/passwd.db;
- deny:拒绝
- allow:允许
- deny 192.168.10.3;
allow all;
- 开启多个server,保证其中 server_name www.benet.com; 该选项都不同来进行区分。
- 可以创建访问日志来专门查看
- access_log logs/www.benet.com.access.log;
- 基于端口与IP修改不同server中的listen即可
- yum 安装Mariiadb
- 初始化: /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
- 设置密码,两种方式
- mysqladmin -u root password '123.com'
- set password=password(主机,用户,密码吗)
- yum -y install gd libxml2-devel libjpeg-devel libpng-devel
- ./configure
- --prefix=/usr/local/php5
- --with-gd
- --with-zlib
- --with-mysql=mysqlnd 基本mysql函数集
- --with-mysqli=mysqlnd 扩展mysql函数集
- --with-config-file-path=/usr/local/php5 配置文件路径
- --enable-mbstring 编码
- --enable-fpm (fast-cgi)
- 设置为全局命令
- 安装zend提高解析php语言的速度
- 修改php-fpm.conf中的相关参数
- 在主配置文件中将代理部分取消注释,修改相关参数,将php解析人物交给其他web服务器
- location / {
root /var/www/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}