NGINX
来源:互联网 发布:生命之花 伤感网络歌曲 编辑:程序博客网 时间:2024/05/20 01:38
1.LN|NMP
Linux + Apache + Mysql +PHPLinux:免费的类unix操作系统,可以免费使用和自由传播PHP:编程的脚本语言Mysql:开源、免费、高性能的关系型数据库Apache:轮循机制web服务器软件,监听端口|接收请求|解析HTTP协议|转发给PHPNginx:监听服务器软件比Apache前景更好|配置轻松|性能更优
2.编译安装
将下载的软件的源代码进行编译安装
·编译=前的准备工作: ./configure·编译: make·安装:make install
3.安装nginx
[root@VM_138_144_centos ~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz#wget:可以使使自己链接到远程的服务器下载资源[root@VM_138_144_centos ~]# tar -zxvf nginx-1.10.3.tar.gz [root@VM_138_144_centos ~]# cd nginx-1.10.3[root@VM_138_144_centos nginx-1.10.3]# ./configure checking for OS + Linux 2.6.32-504.30.3.el6.x86_64 x86_64checking for C compiler ... not found./configure: error: C compiler cc is not found #c编译器cc没有找到[root@VM_138_144_centos ~]# yum install gcc.x86_64 -y[root@VM_138_144_centos ~]# cd nginx-1.10.3[root@VM_138_144_centos nginx-1.10.3]# ./configure 安装Nginx时报错./configure: error: the HTTP rewrite module requires the PCRE library.安装pcre-devel解决问题 yum -y install pcre-devel错误提示:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library. You can either disable the module by using --without-http-cache option, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-http_ssl_module --with-openssl=<path> options.解决办法:yum -y install openssl openssl-devel总结:yum -y install pcre-devel openssl openssl-devel[root@VM_138_144_centos ~]# yum install openssl-devel.x86_64 openssl.x86_64 -y如果报错:Error Downloading Packages: e2fsprogs-1.41.12-22.el6.x86_64: failure: Packages/e2fsprogs-1.41.12-22.el6.x86_64.rpm from os: [Errno 256] No more mirrors to try.解决方案:[root@VM_138_144_centos ~]# yum clean metadataLoaded plugins: fastestmirror, securityCleaning repos: epel extras os updates8 metadata files removed4 sqlite files removed0 metadata files removed[root@VM_138_144_centos ~]# yum clean allLoaded plugins: fastestmirror, securityCleaning repos: epel extras os updatesCleaning up EverythingCleaning up list of fastest mirrors[root@VM_138_144_centos ~]# yum install openssl-devel.x86_64 openssl.x86_64 -y[root@VM_138_144_centos nginx-1.10.3]# ./configure [root@VM_138_144_centos nginx-1.10.3]# make[root@VM_138_144_centos nginx-1.10.3]# make install
4.启动nginx
[root@VM_138_144_centos sbin]# cd /usr/local/nginx/sbin/[root@VM_138_144_centos sbin]# ./nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] still could not bind()[root@VM_138_144_centos sbin]# netstat -lnp | grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24874/nginx [root@VM_138_144_centos sbin]# pkill -9 nginx #强制停止nginx[root@VM_138_144_centos sbin]# vim /usr/local/nginx/conf/nginx.conf ----------#修改配置文件worker_processes 5; #指定子工作进程数...server { listen 80; 监听80端口 server_name localhost; #配置域名 #charset koi8-r; #access_log logs/host.access.log main; location / { #配置目录 root html; index index.html index.htm; }----------[root@VM_138_144_centos sbin]# ps aux | grep nginxroot 25151 0.0 0.0 24432 824 ? Ss 21:36 0:00 nginx: master process ./nginxnobody 25152 0.0 0.1 24852 1504 ? S 21:36 0:00 nginx: worker processnobody 25153 0.0 0.1 24852 1504 ? S 21:36 0:00 nginx: worker processnobody 25154 0.0 0.1 24852 1504 ? S 21:36 0:00 nginx: worker processnobody 25155 0.0 0.1 24852 1432 ? S 21:36 0:00 nginx: worker processnobody 25156 0.0 0.1 24852 1484 ? S 21:36 0:00 nginx: worker processroot 25167 0.0 0.0 6384 696 pts/0 S+ 21:36 0:00 grep nginx[root@VM_138_144_centos sbin]#[root@VM_138_144_centos sbin]# ../sbin/nginx -s reload #重启nginx
4.安装PHP
[root@VM_138_144_centos php-7.1.4]# wget http://hk1.php.net/get/php-7.1.4.tar.gz/from/this/mirror[root@VM_138_144_centos php-7.1.4]# tar -zxvf php-7.1.4.tar.gz [root@VM_138_144_centos ~]# yum install gcc gcc++ libxml2-devel[root@VM_138_144_centos php-7.1.4]# cd php-7.1.4[root@VM_138_144_centos php-7.1.4]# ./configure ----------Thank you for using PHP.#出现,标志着安装成功----------[root@VM_138_144_centos php-7.1.4]# make----------#标志着编译成功Don't forget to run 'make test'.----------
安装keepalived
[root@VM_138_144_centos mnt]# wget http://www.keepalived.org/software/keepalived-1.2.18.tar.gz[root@VM_138_144_centos mnt]# lskeepalived-1.2.18.tar.gz[root@VM_138_144_centos mnt]# tar -zxvf keepalived-1.2.18.tar.gz [root@VM_138_144_centos mnt]# yum search openssl[root@VM_138_144_centos mnt]# yum install openssl-devel.x86_64 openssl.x86_64 -y[root@VM_138_144_centos mnt]# cd keepalived-1.2.18[root@VM_138_144_centos keepalived-1.2.18]# lsAUTHOR COPYING INSTALL README VERSION configure doc install-sh keepalived.spec.inCONTRIBUTORS ChangeLog Makefile.in TODO bin configure.in genhash keepalived lib[root@VM_138_144_centos keepalived-1.2.18]# ./configure [root@VM_138_144_centos keepalived-1.2.18]# make && make install 首先将keepalived装成linux系统服务,因为没有使用keepalived的默认安装路径( 默认:/usr/local),装完之后需要对文件做一些修改[root@VM_138_144_centos rc.d]# cd ~ * 创建文件夹,讲keepalived配置文件将以复制 [root@VM_138_144_centos ~]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/*复制keepalived的脚本文件[root@VM_138_144_centos ~]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/[root@VM_138_144_centos ~]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/*建立系统服务软连接[root@VM_138_144_centos ~]# ln -s /usr/local/sbin/keepalived /usr/sbin/[root@VM_138_144_centos ~]# ln -s /usr/local/sbin/keepalived /sbin/ [root@VM_138_144_centos ~]# cd /usr/local/[root@VM_138_144_centos local]# lsbin etc games include lib lib64 libexec nginx php qcloud sa sbin share src var[root@VM_138_144_centos local]# cd /mnt/keepalived-1.2.18[root@VM_138_144_centos keepalived-1.2.18]# ls AUTHOR COPYING INSTALL Makefile.in TODO bin config.status configure.in genhash keepalived keepalived.spec libCONTRIBUTORS ChangeLog Makefile README VERSION config.log configure doc install-sh keepalived.conf keepalived.spec.in[root@VM_138_144_centos keepalived-1.2.18]# chkconfig keepalived on#开机启动#制作keepalived服务完成[root@VM_138_144_centos keepalived-1.2.18]# service keepalived start|stop|restartStarting keepalived: [ OK ]*此时就可以看到keepalived相关进程了[root@VM_138_144_centos keepalived-1.2.18]# ps -ef | grep keepalivedroot 31664 1 0 08:31 ? 00:00:00 keepalived -Droot 31666 31664 0 08:31 ? 00:00:00 keepalived -Droot 31667 31664 0 08:31 ? 00:00:00 keepalived -Droot 31800 26131 0 08:33 pts/1 00:00:00 grep keepalived[root@VM_138_144_centos keepalived-1.2.18]# [root@VM_138_144_centos ~]#
Nginx默认读取文件
*在启动nginx之前需要吧=把http关掉[root@VM_138_144_centos sbin]# service httpd stopStopping httpd: [ OK ][root@VM_138_144_centos sbin]# vim /usr/local/nginx/html/index.html [root@VM_138_144_centos sbin]# ./nginx -s reload
Nginx实现https访问
[root@VM_138_144_centos ssl]# openssl genrsa -des3 -out server.key 1024Generating RSA private key, 1024 bit long modulus........++++++....++++++e is 65537 (0x10001)Enter pass phrase for server.key:Verifying - Enter pass phrase for server.key:[root@VM_138_144_centos ssl]# openssl req -new -key server.key -out server.csrEnter pass phrase for server.key:You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [XX]:CNState or Province Name (full name) []:shanxiLocality Name (eg, city) [Default City]:xianOrganization Name (eg, company) [Default Company Ltd]:Organizational Unit Name (eg, section) []:Common Name (eg, your name or your server's hostname) []:Email Address []:1552897819@qq.comPlease enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:[root@VM_138_144_centos ssl]# cp server.key server.key.org[root@VM_138_144_centos ssl]# lsserver.csr server.key server.key.org[root@VM_138_144_centos ssl]# openssl rsa -in server.key.org -out server.keyEnter pass phrase for server.key.org:writing RSA key[root@VM_138_144_centos ssl]# lsserver.csr server.key server.key.org[root@VM_138_144_centos ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt Signature oksubject=/C=CN/ST=shanxi/L=xian/O=Default Company Ltd/emailAddress=1552897819@qq.comGetting Private key[root@VM_138_144_centos ssl]#
0 0
- nginx
- Nginx
- Nginx
- Nginx
- Nginx
- nginx
- nginx
- nginx
- nginx
- nginx
- nginx
- nginx
- nginx
- Nginx
- nginx
- nginx
- nginx
- nginx
- 记录安装Urho3D的过程
- java数据结构(二)——Set(HashSet,TreeSet),泛型,Map(HashMap,TreeMap)
- Iterator<FileItem>的使用,实现文件(图片)上传,限制图片格式,设置随机文件名
- 【腾讯Bugly干货分享】经典随机Crash之二:Android消息机制
- Apache安装以及配置
- NGINX
- POJ 3190 Stall Reservations
- waitKey (x)的两个作用
- codeforces710c Magic Odd Square
- 题目1107:搬水果
- LeetCode-515. Find Largest Value in Each Tree Row (JAVA)(二叉树每行的最大值)
- [Lpp]PHP的文件处理系统
- 继承ArrayAdapter类的实例
- UDP协议的客户机和服务器通信