linux centos安装nginx常见错误及解决办法
- 格式:doc
- 大小:30.00 KB
- 文档页数:4
centos6.5服务器安装Nginx设置服务和开机⾃启的⽅法本⽂介绍了centos6.5服务器安装Nginx设置服务和开机⾃启的⽅法,分享给⼤家,也给⾃⼰留个笔记1、安装Nginx及其依赖⾸先是⽼套路,使⽤ssh链接服务器,还记得以前的代码吗?ssh -t ⽤户名@服务器IP或者域名 -p 22<!--⽤户名⼀般是root,⽅便操作,我的登录代码如下-->ssh -t root@ -p 22在终端中输⼊上⾯命令按下回车,要求我们输⼊密码,这个密码是不可见的,所以⼀定要输⼊正确。
链接到服务器后,我们切换到常⽤的安装路径,当然我服务器上⾯的安装路径是/usr/src,接着开始在终端操作:<!--切换到安装⽬录下-->cd /usr/src<!--创建Nginx⽂件夹⽤来存放Nginx相关的资源和依赖-->mkdir Nginx<!--下载资源和依赖-->yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel<!--上⾯的命令⼀般来说会是不需要安装什么,不过这都不重要,我们接着会重新安装指定的版本--><!--下载pcre-->wget ftp:///pub/software/programming/pcre/pcre-8.40.tar.gz<!--解压-->tar -zxvf pcre-8.40.tar.gz<!--切换到pcre⽬录-->cd pcre-8.40<!--设置-->./configure<!--编译-->make<!--安装-->make install<!--切换到Nginx主⽬录-->cd ..<!--下载及安装zlib-->wget /zlib-1.2.11.tar.gz<!--解压-->tar -zxvf zlib-1.2.11.tar.gz<!--切换到zlib⽬录-->cd zlib-1.2.11<!--设置、编译、安装-->./configuremakemake install<!--切换到Nginx主⽬录-->cd ..<!--下载及准备ssl-->wget /source/openssl-fips-2.0.14.tar.gz<!--解压-->tar -zxvf openssl-fips-2.0.14.tar.gz<!--yum安装ssl-->yum -y install openssl openssl-devel<!--下载及安装nginx-->wget /download/nginx-1.4.2.tar.gztar -zxvf nginx-1.4.2.tar.gzcd nginx-1.4.2<!--设置Nginx安装⽬录/opt/nginx,且添加ssl⽀持-->./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcremakemake install到这⾥来讲,我们的nginx安装完成了,但是我们还需要做更多的事情,那就是配置服务器,添加ssl访问,设置服务和开机启动2、配置服务器互联⽹上关于服务器设置的很多,但是准确阐述的却不是那么多,⽽我刚好是在看了他们的东西后就呵呵了。
解决 Linux 系统无响应的问题Linux 系统无响应的问题是常见的系统故障之一,特别是在复杂的应用程序和进程运行时。
这种问题不仅会影响用户体验,还可能导致数据丢失和应用程序崩溃。
为了解决这个问题,本文将探讨几种可能的原因和解决方法。
1. CPU 负载过高一种常见的原因是 CPU 负载过高。
这可能是由于应用程序或进程的错误、死循环或死锁等导致的。
当 CPU 无法满足请求时,系统就会无响应。
为了解决这个问题,我们可以使用 top 或 htop 等进程监视器来查看实际的 CPU 使用情况。
如果出现问题,可以使用 kill 或 pkill 等命令来停止应用程序或进程。
2. 内存泄漏另一种常见的原因是内存泄漏。
这种情况下,系统会尽量分配更多的内存,占用大量资源。
这种情况下,如果当前内存不够,系统就会无响应或崩溃。
为了解决这个问题,我们可以使用 top 或htop 等进程监视器来检查内存使用情况。
如果发现内存泄漏,可以使用 ps 或 kill 等命令停止应用程序或进程。
3. 硬盘故障硬盘故障往往会导致系统无响应。
例如,当硬盘发生故障时,可能无法读取或写入数据,从而导致文件系统崩溃。
这种情况下,可能需要替换硬盘。
为了避免这种情况,应该定期备份数据,以便在发生故障时进行恢复。
4. 网络问题网络问题也可能导致系统无响应。
例如,当系统无法连接到Internet 或局域网时,用户可能无法访问网络资源。
这种情况下,可能需要查找网络配置文件并进行必要的更改。
如果发现网络连接存在问题,可以使用 ifconfig 等命令进行故障排除。
5. 应用程序或进程的错误应用程序或进程的错误也可能导致系统无响应。
例如,当应用程序或进程未正确关闭或崩溃时,可能会导致系统无响应。
为了解决这个问题,我们可以使用 kill 或 pkill 等命令停止应用程序或进程。
如果问题仍存在,则可能需要重新安装应用程序。
总之,解决 Linux 系统无响应的问题需要耐心和找到相应的解决方法。
CentOS7安装Docker时的异常报错与解决⽅法重要:有些⼈在vmware中安装了新的centos⽤于使⽤docker,但是往往会忽略了更换源与进⾏系统update,这样会导致安装过程中出现诸多如下类问题,为了避免不必要的⿇烦在安装docker前最好最到⼀下⼏点:1.替换centos源为163或其他更适合的源,具体操作可以查看我另⼀篇⽂章《》2.清空缓存(yum clean\ yum makecache)3.系统更新(yum update)确认环境[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 7.0.1406 (Core)docker安装-> 报错[root@localhost ~]# yum install dockerLoaded plugins: fastestmirror, langpacksRepodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fastExisting lock /var/run/yum.pid: another copy is running as pid 11946.Another app is currently holding the yum lock; waiting for it to exit...The other application is: PackageKitMemory : 39 M RSS (444 MB VSZ)Started: Thu Jul 722:42:132016 - 08:57 agoState : Sleeping, pid: 11946解决⽅法rm -rf /run/yum.pid[root@localhost run]# rm -rf /run/yum.pid继续docker安装-> 报错[root@localhost run]# yum install dockerLoaded plugins: fastestmirror, langpacksRepodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fastbase | 3.6 kB 00:00:00extras | 3.4 kB 00:00:00updates | 3.4 kB 00:00:00(1/2): extras/7/x86_64/primary_db | 149 kB 00:00:00(2/2): updates/7/x86_64/primary_db | 5.7 MB 00:00:47Determining fastest mirrors* base: * extras: * updates: Resolving Dependencies--> Running transaction check---> Package docker.x86_64 0:1.10.3-44.el7.centos will be installed--> Processing Dependency: oci-systemd-hook = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: oci-register-machine = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-forward-journald = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-common = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: selinux-policy >= 3.13.1-23for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-selinux >= 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: device-mapper-libs >= 7:1.02.97for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: libsystemd.so.0()(64bit) for package: docker-1.10.3-44.el7.centos.x86_64--> Running transaction check---> Package device-mapper-libs.x86_64 7:1.02.84-14.el7 will be updated--> Processing Dependency: device-mapper-libs = 7:1.02.84-14.el7 for package: 7:device-mapper-1.02.84-14.el7.x86_64---> Package device-mapper-libs.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package docker-common.x86_64 0:1.10.3-44.el7.centos will be installed---> Package docker-forward-journald.x86_64 0:1.10.3-44.el7.centos will be installed---> Package docker-selinux.x86_64 0:1.10.3-44.el7.centos will be installed--> Processing Dependency: selinux-policy-targeted >= 3.13.1-23for package: docker-selinux-1.10.3-44.el7.centos.x86_64--> Processing Dependency: selinux-policy-base >= 3.13.1-23for package: docker-selinux-1.10.3-44.el7.centos.x86_64---> Package oci-register-machine.x86_64 0:1.10.3-44.el7.centos will be installed---> Package oci-systemd-hook.x86_64 0:1.10.3-44.el7.centos will be installed---> Package selinux-policy.noarch 0:3.12.1-153.el7 will be updated---> Package selinux-policy.noarch 0:3.13.1-60.el7_2.7 will be an update---> Package systemd-libs.x86_64 0:208-11.el7 will be updated--> Processing Dependency: systemd-libs = 208-11.el7 for package: systemd-208-11.el7.x86_64---> Package systemd-libs.x86_64 0:219-19.el7_2.11 will be an update--> Running transaction check---> Package device-mapper.x86_64 7:1.02.84-14.el7 will be updated--> Processing Dependency: device-mapper = 7:1.02.84-14.el7 for package: 7:device-mapper-event-1.02.84-14.el7.x86_64---> Package device-mapper.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package selinux-policy-targeted.noarch 0:3.12.1-153.el7 will be updated---> Package selinux-policy-targeted.noarch 0:3.13.1-60.el7_2.7 will be an update---> Package systemd.x86_64 0:208-11.el7 will be updated--> Processing Dependency: systemd = 208-11.el7 for package: libgudev1-208-11.el7.x86_64--> Processing Dependency: systemd = 208-11.el7 for package: systemd-sysv-208-11.el7.x86_64--> Processing Dependency: systemd = 208-11.el7 for package: systemd-python-208-11.el7.x86_64---> Package systemd.x86_64 0:219-19.el7_2.11 will be an update--> Processing Dependency: kmod >= 18-4for package: systemd-219-19.el7_2.11.x86_64--> Running transaction check---> Package device-mapper-event.x86_64 7:1.02.84-14.el7 will be updated---> Package device-mapper-event.x86_64 7:1.02.107-5.el7_2.5 will be an update--> Processing Dependency: device-mapper-event-libs = 7:1.02.107-5.el7_2.5for package: 7:device-mapper-event-1.02.107-5.el7_2.5.x86_64---> Package kmod.x86_64 0:14-9.el7 will be updated---> Package kmod.x86_64 0:20-5.el7 will be an update---> Package libgudev1.x86_64 0:208-11.el7 will be updated---> Package libgudev1.x86_64 0:219-19.el7_2.11 will be an update---> Package systemd-python.x86_64 0:208-11.el7 will be updated---> Package systemd-python.x86_64 0:219-19.el7_2.11 will be an update---> Package systemd-sysv.x86_64 0:208-11.el7 will be updated---> Package systemd-sysv.x86_64 0:219-19.el7_2.11 will be an update--> Running transaction check---> Package device-mapper-event-libs.x86_64 7:1.02.84-14.el7 will be updated---> Package device-mapper-event-libs.x86_64 7:1.02.107-5.el7_2.5 will be an update--> Processing Conflict: systemd-219-19.el7_2.11.x86_64 conflicts initscripts < 9.49.28-1--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package initscripts.x86_64 0:9.49.17-1.el7 will be updated---> Package initscripts.x86_64 0:9.49.30-1.el7_2.2 will be an update--> Processing Conflict: systemd-219-19.el7_2.11.x86_64 conflicts dracut < 033-243--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package dracut.x86_64 0:033-161.el7 will be updated--> Processing Dependency: dracut = 033-161.el7 for package: dracut-config-rescue-033-161.el7.x86_64--> Processing Dependency: dracut = 033-161.el7 for package: dracut-network-033-161.el7.x86_64---> Package dracut.x86_64 0:033-360.el7_2.1 will be an update--> Running transaction check---> Package dracut-config-rescue.x86_64 0:033-161.el7 will be updated---> Package dracut-config-rescue.x86_64 0:033-360.el7_2.1 will be an update---> Package dracut-network.x86_64 0:033-161.el7 will be updated---> Package dracut-network.x86_64 0:033-360.el7_2.1 will be an update--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================ Installing:docker x86_64 1.10.3-44.el7.centos extras 8.6 MUpdating:dracut x86_64 033-360.el7_2.1 updates 311 kinitscripts x86_64 9.49.30-1.el7_2.2 updates 429 kInstalling for dependencies:docker-common x86_64 1.10.3-44.el7.centos extras 59 kdocker-forward-journald x86_64 1.10.3-44.el7.centos extras 831 kdocker-selinux x86_64 1.10.3-44.el7.centos extras 77 koci-register-machine x86_64 1.10.3-44.el7.centos extras 1.0 Moci-systemd-hook x86_64 1.10.3-44.el7.centos extras 96 kUpdating for dependencies:device-mapper x86_64 7:1.02.107-5.el7_2.5 updates 252 kdevice-mapper-event x86_64 7:1.02.107-5.el7_2.5 updates 167 kdevice-mapper-event-libs x86_64 7:1.02.107-5.el7_2.5 updates 169 kdevice-mapper-libs x86_64 7:1.02.107-5.el7_2.5 updates 305 kdracut-config-rescue x86_64 033-360.el7_2.1 updates 50 kdracut-network x86_64 033-360.el7_2.1 updates 90 kkmod x86_64 20-5.el7 base114 klibgudev1 x86_64 219-19.el7_2.11 updates 66 kselinux-policy noarch 3.13.1-60.el7_2.7 updates 376 kselinux-policy-targeted noarch 3.13.1-60.el7_2.7 updates 3.9 Msystemd x86_64 219-19.el7_2.11 updates 5.1 Msystemd-libs x86_64 219-19.el7_2.11 updates 358 ksystemd-python x86_64 219-19.el7_2.11 updates 99 ksystemd-sysv x86_64 219-19.el7_2.11 updates 53 kTransaction Summary============================================================================================================================================ Install 1 Package (+ 5 Dependent packages)Upgrade 2 Packages (+14 Dependent packages)Total download size: 23 MIs this ok [y/d/N]: yDownloading packages:No Presto metadata available for baseupdates/7/x86_64/prestodelta | 603 kB 00:00:00warning: /var/cache/yum/x86_64/7/updates/packages/device-mapper-1.02.107-5.el7_2.5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPublic key for device-mapper-1.02.107-5.el7_2.5.x86_64.rpm is not installed(1/22): device-mapper-1.02.107-5.el7_2.5.x86_64.rpm | 252 kB 00:00:00(2/22): device-mapper-event-libs-1.02.107-5.el7_2.5.x86_64.rpm | 169 kB 00:00:00Public key for docker-forward-journald-1.10.3-44.el7.centos.x86_64.rpm is not installed ] 0.0 B/s | 1.2 MB --:--:-- ETA(3/22): docker-forward-journald-1.10.3-44.el7.centos.x86_64.rpm | 831 kB 00:00:00(4/22): docker-selinux-1.10.3-44.el7.centos.x86_64.rpm | 77 kB 00:00:00(5/22): docker-common-1.10.3-44.el7.centos.x86_64.rpm | 59 kB 00:00:00(6/22): dracut-033-360.el7_2.1.x86_64.rpm | 311 kB 00:00:00(7/22): dracut-network-033-360.el7_2.1.x86_64.rpm | 90 kB 00:00:00(8/22): device-mapper-event-1.02.107-5.el7_2.5.x86_64.rpm | 167 kB 00:00:01(9/22): initscripts-9.49.30-1.el7_2.2.x86_64.rpm | 429 kB 00:00:00Public key for kmod-20-5.el7.x86_64.rpm is not installed(10/22): kmod-20-5.el7.x86_64.rpm | 114 kB 00:00:00(11/22): libgudev1-219-19.el7_2.11.x86_64.rpm | 66 kB 00:00:00(12/22): oci-systemd-hook-1.10.3-44.el7.centos.x86_64.rpm | 96 kB 00:00:00(13/22): device-mapper-libs-1.02.107-5.el7_2.5.x86_64.rpm | 305 kB 00:00:01(14/22): selinux-policy-3.13.1-60.el7_2.7.noarch.rpm | 376 kB 00:00:00(15/22): dracut-config-rescue-033-360.el7_2.1.x86_64.rpm | 50 kB 00:00:00(16/22): systemd-libs-219-19.el7_2.11.x86_64.rpm | 358 kB 00:00:02(17/22): docker-1.10.3-44.el7.centos.x86_64.rpm | 8.6 MB 00:00:03(18/22): systemd-python-219-19.el7_2.11.x86_64.rpm | 99 kB 00:00:00(19/22): systemd-sysv-219-19.el7_2.11.x86_64.rpm | 53 kB 00:00:00(20/22): oci-register-machine-1.10.3-44.el7.centos.x86_64.rpm | 1.0 MB 00:00:03(21/22): selinux-policy-targeted-3.13.1-60.el7_2.7.noarch.rpm | 3.9 MB 00:00:03(22/22): systemd-219-19.el7_2.11.x86_64.rpm | 5.1 MB 00:00:05--------------------------------------------------------------------------------------------------------------------------------------------Total 3.1 MB/s | 23 MB 00:00:07Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5:Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@>"Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package : centos-release-7-0.1406.el7.centos.2.3.x86_64 (@anaconda)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Is this ok [y/N]: yRunning transaction checkRunning transaction testTransaction check error:file /usr/lib/systemd/system/blk-availability.service from install of device-mapper-7:1.02.107-5.el7_2.5.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64file /usr/sbin/blkdeactivate from install of device-mapper-7:1.02.107-5.el7_2.5.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64file /usr/share/man/man8/blkdeactivate.8.gz from install of device-mapper-7:1.02.107-5.el7_2.5.x86_64 conflicts with file from package lvm2-7:2.02.105-14.el7.x86_64Error Summary-------------解决⽅法yum install libdevmapper* -y[root@localhost run]# yum install libdevmapper* -yLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile* base: * extras: * updates: Resolving Dependencies--> Running transaction check---> Package device-mapper-event-libs.x86_64 7:1.02.84-14.el7 will be updated--> Processing Dependency: device-mapper-event-libs = 7:1.02.84-14.el7 for package: 7:device-mapper-event-1.02.84-14.el7.x86_64---> Package device-mapper-event-libs.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package device-mapper-libs.x86_64 7:1.02.84-14.el7 will be updated--> Processing Dependency: device-mapper-libs = 7:1.02.84-14.el7 for package: 7:device-mapper-1.02.84-14.el7.x86_64---> Package device-mapper-libs.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package lvm2-libs.x86_64 7:2.02.105-14.el7 will be updated--> Processing Dependency: lvm2-libs = 7:2.02.105-14.el7 for package: 7:lvm2-2.02.105-14.el7.x86_64---> Package lvm2-libs.x86_64 7:2.02.130-5.el7_2.5 will be an update--> Running transaction check---> Package device-mapper.x86_64 7:1.02.84-14.el7 will be updated---> Package device-mapper.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package device-mapper-event.x86_64 7:1.02.84-14.el7 will be updated---> Package device-mapper-event.x86_64 7:1.02.107-5.el7_2.5 will be an update---> Package lvm2.x86_64 7:2.02.105-14.el7 will be updated---> Package lvm2.x86_64 7:2.02.130-5.el7_2.5 will be an update--> Processing Dependency: device-mapper-persistent-data >= 0.5.5-1for package: 7:lvm2-2.02.130-5.el7_2.5.x86_64--> Running transaction check---> Package device-mapper-persistent-data.x86_64 0:0.3.2-1.el7 will be updated---> Package device-mapper-persistent-data.x86_64 0:0.5.5-1.el7 will be an update--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================ Updating:device-mapper-event-libs x86_64 7:1.02.107-5.el7_2.5 updates 169 kdevice-mapper-libs x86_64 7:1.02.107-5.el7_2.5 updates 305 klvm2-libs x86_64 7:2.02.130-5.el7_2.5 updates 873 kUpdating for dependencies:device-mapper x86_64 7:1.02.107-5.el7_2.5 updates 252 kdevice-mapper-event x86_64 7:1.02.107-5.el7_2.5 updates 167 kdevice-mapper-persistent-data x86_64 0.5.5-1.el7 base350 klvm2 x86_64 7:2.02.130-5.el7_2.5 updates 1.0 MTransaction Summary============================================================================================================================================ Upgrade 3 Packages (+4 Dependent packages)Total size: 3.0 MTotal download size: 2.2 MDownloading packages:No Presto metadata available for base(1/3): device-mapper-persistent-data-0.5.5-1.el7.x86_64.rpm | 350 kB 00:00:00(2/3): lvm2-2.02.130-5.el7_2.5.x86_64.rpm | 1.0 MB 00:00:00(3/3): lvm2-libs-2.02.130-5.el7_2.5.x86_64.rpm | 873 kB 00:00:11--------------------------------------------------------------------------------------------------------------------------------------------Total 195 kB/s | 2.2 MB 00:00:11Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating : 7:device-mapper-1.02.107-5.el7_2.5.x86_64 1/14Updating : 7:device-mapper-libs-1.02.107-5.el7_2.5.x86_64 2/14Updating : 7:device-mapper-event-libs-1.02.107-5.el7_2.5.x86_64 3/14Updating : 7:device-mapper-event-1.02.107-5.el7_2.5.x86_64 4/14Updating : 7:lvm2-libs-2.02.130-5.el7_2.5.x86_64 5/14Updating : device-mapper-persistent-data-0.5.5-1.el7.x86_64 6/14Updating : 7:lvm2-2.02.130-5.el7_2.5.x86_64 7/14ln -s '/usr/lib/systemd/system/lvm2-lvmetad.socket''/etc/systemd/system/sysinit.target.wants/lvm2-lvmetad.socket'ln -s '/usr/lib/systemd/system/lvm2-lvmpolld.socket''/etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket'Cleanup : 7:lvm2-2.02.105-14.el7.x86_64 8/14Cleanup : 7:lvm2-libs-2.02.105-14.el7.x86_64 9/14Cleanup : 7:device-mapper-event-1.02.84-14.el7.x86_64 10/14Cleanup : 7:device-mapper-event-libs-1.02.84-14.el7.x86_64 11/14Cleanup : 7:device-mapper-1.02.84-14.el7.x86_64 12/14Cleanup : 7:device-mapper-libs-1.02.84-14.el7.x86_64 13/14Cleanup : device-mapper-persistent-data-0.3.2-1.el7.x86_64 14/14Verifying : 7:device-mapper-libs-1.02.107-5.el7_2.5.x86_64 1/14Verifying : 7:device-mapper-1.02.107-5.el7_2.5.x86_64 2/14Verifying : 7:lvm2-2.02.130-5.el7_2.5.x86_64 3/14Verifying : device-mapper-persistent-data-0.5.5-1.el7.x86_64 4/14Verifying : 7:lvm2-libs-2.02.130-5.el7_2.5.x86_64 5/14Verifying : 7:device-mapper-event-libs-1.02.107-5.el7_2.5.x86_64 6/14Verifying : 7:device-mapper-event-1.02.107-5.el7_2.5.x86_64 7/14Verifying : 7:lvm2-2.02.105-14.el7.x86_64 8/14Verifying : device-mapper-persistent-data-0.3.2-1.el7.x86_64 9/14Verifying : 7:lvm2-libs-2.02.105-14.el7.x86_64 10/14Verifying : 7:device-mapper-event-libs-1.02.84-14.el7.x86_64 11/14Verifying : 7:device-mapper-libs-1.02.84-14.el7.x86_64 12/14Verifying : 7:device-mapper-event-1.02.84-14.el7.x86_64 13/14Verifying : 7:device-mapper-1.02.84-14.el7.x86_64 14/14Updated:device-mapper-event-libs.x86_64 7:1.02.107-5.el7_2.5 device-mapper-libs.x86_64 7:1.02.107-5.el7_2.5 lvm2-libs.x86_64 7:2.02.130-5.el7_2.5 Dependency Updated:device-mapper.x86_64 7:1.02.107-5.el7_2.5 device-mapper-event.x86_64 7:1.02.107-5.el7_2.5device-mapper-persistent-data.x86_64 0:0.5.5-1.el7 lvm2.x86_64 7:2.02.130-5.el7_2.5Complete!继续docker安装-> 成功[root@localhost run]# yum install dockerLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile* base: * extras: * updates: Resolving Dependencies--> Running transaction check---> Package docker.x86_64 0:1.10.3-44.el7.centos will be installed--> Processing Dependency: oci-systemd-hook = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: oci-register-machine = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-forward-journald = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-common = 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: selinux-policy >= 3.13.1-23for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: docker-selinux >= 1.10.3-44.el7.centos for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: docker-1.10.3-44.el7.centos.x86_64--> Processing Dependency: libsystemd.so.0()(64bit) for package: docker-1.10.3-44.el7.centos.x86_64--> Running transaction check---> Package docker-common.x86_64 0:1.10.3-44.el7.centos will be installed---> Package docker-forward-journald.x86_64 0:1.10.3-44.el7.centos will be installed---> Package docker-selinux.x86_64 0:1.10.3-44.el7.centos will be installed--> Processing Dependency: selinux-policy-targeted >= 3.13.1-23for package: docker-selinux-1.10.3-44.el7.centos.x86_64--> Processing Dependency: selinux-policy-base >= 3.13.1-23for package: docker-selinux-1.10.3-44.el7.centos.x86_64---> Package oci-register-machine.x86_64 0:1.10.3-44.el7.centos will be installed---> Package oci-systemd-hook.x86_64 0:1.10.3-44.el7.centos will be installed---> Package selinux-policy.noarch 0:3.12.1-153.el7 will be updated---> Package selinux-policy.noarch 0:3.13.1-60.el7_2.7 will be an update---> Package systemd-libs.x86_64 0:208-11.el7 will be updated--> Processing Dependency: systemd-libs = 208-11.el7 for package: systemd-208-11.el7.x86_64---> Package systemd-libs.x86_64 0:219-19.el7_2.11 will be an update--> Running transaction check---> Package selinux-policy-targeted.noarch 0:3.12.1-153.el7 will be updated---> Package selinux-policy-targeted.noarch 0:3.13.1-60.el7_2.7 will be an update---> Package systemd.x86_64 0:208-11.el7 will be updated--> Processing Dependency: systemd = 208-11.el7 for package: libgudev1-208-11.el7.x86_64--> Processing Dependency: systemd = 208-11.el7 for package: systemd-python-208-11.el7.x86_64--> Processing Dependency: systemd = 208-11.el7 for package: systemd-sysv-208-11.el7.x86_64---> Package systemd.x86_64 0:219-19.el7_2.11 will be an update--> Processing Dependency: kmod >= 18-4for package: systemd-219-19.el7_2.11.x86_64--> Running transaction check---> Package kmod.x86_64 0:14-9.el7 will be updated---> Package kmod.x86_64 0:20-5.el7 will be an update---> Package libgudev1.x86_64 0:208-11.el7 will be updated---> Package libgudev1.x86_64 0:219-19.el7_2.11 will be an update---> Package systemd-python.x86_64 0:208-11.el7 will be updated---> Package systemd-python.x86_64 0:219-19.el7_2.11 will be an update---> Package systemd-sysv.x86_64 0:208-11.el7 will be updated---> Package systemd-sysv.x86_64 0:219-19.el7_2.11 will be an update--> Processing Conflict: systemd-219-19.el7_2.11.x86_64 conflicts initscripts < 9.49.28-1--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package initscripts.x86_64 0:9.49.17-1.el7 will be updated---> Package initscripts.x86_64 0:9.49.30-1.el7_2.2 will be an update--> Processing Conflict: systemd-219-19.el7_2.11.x86_64 conflicts dracut < 033-243--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package dracut.x86_64 0:033-161.el7 will be updated--> Processing Dependency: dracut = 033-161.el7 for package: dracut-config-rescue-033-161.el7.x86_64--> Processing Dependency: dracut = 033-161.el7 for package: dracut-network-033-161.el7.x86_64---> Package dracut.x86_64 0:033-360.el7_2.1 will be an update--> Running transaction check---> Package dracut-config-rescue.x86_64 0:033-161.el7 will be updated---> Package dracut-config-rescue.x86_64 0:033-360.el7_2.1 will be an update---> Package dracut-network.x86_64 0:033-161.el7 will be updated---> Package dracut-network.x86_64 0:033-360.el7_2.1 will be an update--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================ Installing:docker x86_64 1.10.3-44.el7.centos extras 8.6 MUpdating:dracut x86_64 033-360.el7_2.1 updates 311 kinitscripts x86_64 9.49.30-1.el7_2.2 updates 429 kInstalling for dependencies:docker-common x86_64 1.10.3-44.el7.centos extras 59 kdocker-forward-journald x86_64 1.10.3-44.el7.centos extras 831 kdocker-selinux x86_64 1.10.3-44.el7.centos extras 77 koci-register-machine x86_64 1.10.3-44.el7.centos extras 1.0 Moci-systemd-hook x86_64 1.10.3-44.el7.centos extras 96 kUpdating for dependencies:dracut-config-rescue x86_64 033-360.el7_2.1 updates 50 kdracut-network x86_64 033-360.el7_2.1 updates 90 kkmod x86_64 20-5.el7 base114 klibgudev1 x86_64 219-19.el7_2.11 updates 66 kselinux-policy noarch 3.13.1-60.el7_2.7 updates 376 kselinux-policy-targeted noarch 3.13.1-60.el7_2.7 updates 3.9 Msystemd x86_64 219-19.el7_2.11 updates 5.1 Msystemd-libs x86_64 219-19.el7_2.11 updates 358 ksystemd-python x86_64 219-19.el7_2.11 updates 99 ksystemd-sysv x86_64 219-19.el7_2.11 updates 53 kTransaction Summary============================================================================================================================================ Install 1 Package (+ 5 Dependent packages)Upgrade 2 Packages (+10 Dependent packages)Total size: 22 MIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating : systemd-libs-219-19.el7_2.11.x86_64 1/30Updating : dracut-033-360.el7_2.1.x86_64 2/30Updating : kmod-20-5.el7.x86_64 3/30Updating : systemd-219-19.el7_2.11.x86_64 4/30Updating : selinux-policy-3.13.1-60.el7_2.7.noarch 5/30Updating : selinux-policy-targeted-3.13.1-60.el7_2.7.noarch 6/30140kInstalling : docker-selinux-1.10.3-44.el7.centos.x86_64 7/30Installing : oci-register-machine-1.10.3-44.el7.centos.x86_64 8/30Installing : docker-forward-journald-1.10.3-44.el7.centos.x86_64 9/30Installing : docker-common-1.10.3-44.el7.centos.x86_64 10/30Installing : oci-systemd-hook-1.10.3-44.el7.centos.x86_64 11/30Installing : docker-1.10.3-44.el7.centos.x86_64 12/30Updating : initscripts-9.49.30-1.el7_2.2.x86_64 13/30Updating : systemd-sysv-219-19.el7_2.11.x86_64 14/30Updating : systemd-python-219-19.el7_2.11.x86_64 15/30Updating : dracut-config-rescue-033-360.el7_2.1.x86_64 16/30Updating : dracut-network-033-360.el7_2.1.x86_64 17/30Updating : libgudev1-219-19.el7_2.11.x86_64 18/30Cleanup : selinux-policy-targeted-3.12.1-153.el7.noarch 19/30warning: file /etc/selinux/targeted/modules/active/modules/vbetool.pp: remove failed: No such file or directorywarning: file /etc/selinux/targeted/modules/active/modules/pkcsslotd.pp: remove failed: No such file or directoryCleanup : systemd-sysv-208-11.el7.x86_64 20/30Cleanup : dracut-network-033-161.el7.x86_64 21/30Cleanup : dracut-config-rescue-033-161.el7.x86_64 22/30Cleanup : dracut-033-161.el7.x86_64 23/30Cleanup : systemd-python-208-11.el7.x86_64 24/30Cleanup : libgudev1-208-11.el7.x86_64 25/30Cleanup : initscripts-9.49.17-1.el7.x86_64 26/30Cleanup : selinux-policy-3.12.1-153.el7.noarch 27/30Cleanup : systemd-208-11.el7.x86_64 28/30Cleanup : kmod-14-9.el7.x86_64 29/30Cleanup : systemd-libs-208-11.el7.x86_64 30/30Verifying : dracut-config-rescue-033-360.el7_2.1.x86_64 1/30Verifying : initscripts-9.49.30-1.el7_2.2.x86_64 2/30Verifying : dracut-network-033-360.el7_2.1.x86_64 3/30Verifying : oci-systemd-hook-1.10.3-44.el7.centos.x86_64 4/30Verifying : kmod-20-5.el7.x86_64 5/30Verifying : libgudev1-219-19.el7_2.11.x86_64 6/30Verifying : selinux-policy-3.13.1-60.el7_2.7.noarch 7/30Verifying : docker-selinux-1.10.3-44.el7.centos.x86_64 8/30Verifying : systemd-libs-219-19.el7_2.11.x86_64 9/30Verifying : dracut-033-360.el7_2.1.x86_64 10/30Verifying : systemd-219-19.el7_2.11.x86_64 11/30Verifying : docker-common-1.10.3-44.el7.centos.x86_64 12/30Verifying : docker-1.10.3-44.el7.centos.x86_64 13/30Verifying : systemd-sysv-219-19.el7_2.11.x86_64 14/30Verifying : docker-forward-journald-1.10.3-44.el7.centos.x86_64 15/30Verifying : systemd-python-219-19.el7_2.11.x86_64 16/30。
nginx502错误原因解决方法nginx502错误是指在使用nginx作为反向代理服务器时,后端服务器返回了一个502错误。
这种错误通常出现在nginx无法从后端服务器获取有效响应时。
那么,究竟是什么原因导致了nginx502错误呢?接下来,我们将详细介绍nginx502错误的常见原因,并提供解决方法。
1. 后端服务器故障。
后端服务器故障是导致nginx502错误的常见原因之一。
当后端服务器因为各种原因无法正常响应请求时,nginx就会收到502错误。
这种情况下,我们需要检查后端服务器的运行状态,确保服务器正常运行,并且能够正常响应请求。
解决方法,检查后端服务器的日志,查找可能的故障原因,并及时修复。
如果是服务器负载过高导致的故障,可以考虑增加服务器资源,或者优化后端服务程序。
2. 过载。
当nginx服务器本身负载过高时,也会导致502错误。
这种情况通常发生在nginx服务器处理大量并发请求时,或者配置不当导致资源占用过高。
解决方法,优化nginx服务器配置,增加服务器资源,或者考虑使用负载均衡来分担服务器负载。
3. 后端服务超时。
后端服务响应时间过长,超过了nginx设置的超时时间,也会导致502错误。
这种情况通常发生在后端服务处理复杂请求时,或者网络延迟较大时。
解决方法,增加后端服务的处理能力,优化服务程序,或者调整nginx的超时设置。
4. 网络问题。
网络问题也是导致nginx502错误的一个常见原因。
当nginx无法与后端服务器建立连接,或者连接断开时,就会返回502错误。
解决方法,检查网络连接,确保网络畅通。
如果是网络问题导致的502错误,需要及时排查并解决网络故障。
5. 配置错误。
配置错误也可能导致nginx502错误。
当nginx配置不当时,可能会导致无法正确转发请求到后端服务器,从而返回502错误。
解决方法,检查nginx配置文件,确保配置正确。
可以使用nginx的配置检查工具来检查配置文件的语法错误,及时修复配置问题。
上海纽斯达科技Nginx常见错误与解决方法上海纽斯达科技有限公司2014-10-25文档状态目的:在Nginx服务器出现故障时,能快速定位并解决相关错误。
保密:本文档仅供内部使用,请勿外传概述:Nginx常见错误与问题之解决方法技术指南。
安装环境:系统环境:redhat enterprise 6.5 64bit1、Nginx 常见启动错误有的时候初次安装nginx的时候会报这样的错误sbin/nginx -c conf/nginx.conf报错内容:sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory启动时如果报异常error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory 这说明我们的环境还不是和启动需要小小的配置一下解决方法(直接运行):32位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64位系统 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64然后执行ps -ef | grep nginx 查看nginx进程确认是否真的已经启动了,在进程列表里会有最起码两个, worker(nginx工作进程)和master(nginx主进程)root 4349 1 0 02:24 ? 00:00:00 nginx: master process sbin/nginx -cconf/nginx.confnginx 4350 4349 0 02:24 ? 00:00:00 nginx: worker processroot 4356 28335 0 02:30 pts/1 00:00:00 grep nginxNGINX 就 OK了2、400 bad request错误的原因和解决办法配置nginx.conf相关设置如下.client_header_buffer_size 16k;large_client_header_buffers 4 64k;根据具体情况调整,一般适当调整值就可以。
Linux系统常见的网络连接问题及解决方案详解在使用Linux系统过程中,我们经常会遇到各种网络连接问题。
本文将详细介绍几种常见的网络连接问题,并提供相应的解决方案。
一、无法连接到网络无法连接到网络是最常见的网络问题之一。
当我们无法连接到网络时,首先需要确认以下几点:1. 网络连接是否正常:检查网络连接是否已启用,确保网络线缆连接到正确的接口上。
2. IP地址是否配置正确:通过 ifconfig 命令检查当前网络接口的IP地址和子网掩码是否配置正确。
3. DNS解析是否正常:配置 DNS 服务器的地址,可通过编辑/etc/resolv.conf 文件来指定 DNS 服务器地址。
若以上检查都正常,而仍无法连接到网络,则可能有以下原因导致:1. 防火墙配置问题:检查防火墙是否阻止了网络连接。
可以使用iptables 命令来查看、修改防火墙规则。
2. 硬件问题:检查网卡是否正常工作,可以通过 lspci 命令查看系统中是否存在网卡设备。
3. 路由器配置问题:检查路由器的配置,确保网络设置正确。
二、网络延迟高网络延迟高会导致网络连接变慢或不稳定。
以下是一些降低网络延迟的解决方案:1. 检查网络带宽:使用网速测试工具(如speedtest-cli)检查当前网络带宽情况。
如果带宽使用率过高,可以考虑限制某些应用程序的带宽使用。
2. 优化网络设置:调整系统的TCP参数,可以使用 sysctl 命令来修改。
例如,通过增加tcp_fin_timeout 值来减少关闭连接时的等待时间。
3. 检查网络设备:检查路由器、交换机等网络设备是否正常工作。
可以尝试重新启动这些设备,或升级其固件。
三、无法解析域名无法解析域名是指无法通过域名获取相应的IP地址。
解决这个问题可以从以下几个方面入手:1. 检查DNS配置:查看 /etc/resolv.conf 文件,确认已正确配置DNS 服务器的地址。
也可以尝试更换为其他的DNS服务器地址,如Google DNS(8.8.8.8)。
nginx配置8081端⼝异常
1、为nginx配置8081端⼝,结果nginx报错。
(nginx配置8081端⼝监听,通过查看⽇志,出现nginx: [emerg] bind() to 0.0.0.0:8081 failed (13: permission denied)异常。
但是其它端⼝监听/访问正常。
)
截图如下:
2、关于nginx启动成功,但浏览器访问不了的⽅法:
(1)、对80端⼝进⾏防⽕墙配置
firewall-cmd --zone=public --add-port=80/tcp --permanent
(2)、重启防⽕墙服务
systemctl restart firewalld.service
(备注:此⽅法⽆效,是浏览器访问不了再⽤此⽅法)
有效的解决⽅案:
(1)、检查已开放端⼝
sudo semanage port -l | grep http_port_t
(2)、如果8081端⼝未出现在列表中,则执⾏:
sudo semanage port -a -t http_port_t -p tcp 8081
结果执⾏完出现以下报错:
ValueError: Port tcp/8081 already defined
3、所以我发现另⼀个服务具有TCP端⼝5000的已定义状态.
但是通过将-a选项替换为-m for modify,将tcp port 5000添加到http_port_t
所以有效的命令是:
semanage port -m -t http_port_t -p tcp 5000
执⾏后截图如下:
4、⾄此,问题解决。
nginx提示"permission denied"的解决方法如下:
1. 检查Nginx用户和组设置:首先,需要确保Nginx使用的用户和组设置正确。
打开Nginx
配置文件,查找"user"行,确保用户名是一个存在的用户,并且具备所需的权限。
如果该用户不存在,可以创建一个新用户,并将其添加到Nginx组中,或者选择其他合适的用户。
2.检查文件和目录权限:权限拒绝问题通常是由于Nginx没有足够的权限访问某些文件
或目录导致的。
可以通过"ls -l /path/to/file"命令来检查文件和目录的权限,确保Nginx 用户(例如"www-data")拥有对这些文件或目录的适当权限。
如果权限设置不正确,可以使用"chmod +r /path/to/file"、"chmod +x /path/to/file"、"chmod +r /path/to/directory"、"chmod +x /path/to/directory"命令来更改它们。
Nginx (“engine x”) 是一个高性能的 HTTP 和反向代理服务器,也是一个IMAP/POP3/SMTP 代理服务器。
Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的站点开发的,它已经在该站点运行超过两年半了。
Igor 将源代码以类BSD许可证的形式发布。
Nginx 超越 Apache 的高性能和稳定性。
Nginx+Tomcat是目前主流的Java web架构,很多公司在使用,Nginx+Tomcat通过简单的配置,可以实现高性能的负载均衡,通过本文学习,可以实现Nginx+Tomcat 负载均衡。
工具资源1、Java运行环境,JDK2、压缩版下载3、稳定版下载本文基于win10进行配置配置步骤1、JDK环境配置略2、Tomcat安装配置请参考:一台服务器安装运行多个Tomcat及注册服务本测试安装两个Tomcat,端口分别是8801和8802安装配置完成后请确保每一个Tomcat可以正常访问为了区分两个Tomcat,本文将第二个Tomcat的页面名称改为:Apache Tomcat/、Nginx配置v1.0 可编辑可修改1.解压Nginx到D盘根目录2.修改Nginx配置#user nobody;worker_processes 1; #工作进程的个数#error_log logs/;#error_log logs/ notice;#error_log logs/ info;#pid logs/;events {worker_connections 1024; #单个进程最大连接数}http {include ; #文件扩展名与文件类型映射表default_type application/octet-stream; #默认文件类型#access_log logs/ main;sendfile on; #开启高效文件传输模式#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65; #长连接超时时间,单位是秒#gzip on; #启用Gizp压缩#服务器的集群upstream tomcatColony { #服务器集群名字server weight=0;server weight=1;}server {listen 8080; #监听端口,默认是80,可以修改 server_name localhost; #当前服务的域名location / {proxy_pass ; #指定使用集群proxy_redirect default;}error_page 500 502 503 504 /;location = / {root html;}}注意:nginx在配置upstream时,有两个参数:ip_hash(同一IP一直使用同一台server服务)weight(server的使用权重,数值越大,nginx分发的请求越多)1.启动NginxNginx目录下:D:\,运行,即可启动。
解析阿⾥云centos7服务器nginx配置及常见问题解答前⾔:1.make[1]: *** [objs/Makefile:473: objs/src/core/ngx_murmurhash.o] Error 12.make[1]: *** [objs/Makefile:774: objs/src/os/unix/ngx_user.o] Error 13.make[1]: *** [objs/Makefile:769: objs/src/event/ngx_event_openssl.o] Error 1本⽂针对这些问题和⼀些其他问题的解决⽅案都进⾏了阐述和流程上的改良内容流程:0.前置说明,1.安装gcc环境,2.安装pcre库,3.安装ssl库,4.安装zlib库,5.安装nginx,附:nginx在make过程中可能出现的问题,6.nginx启动与使⽤,7.nginx启动后⽆法访问的问题解决具体内容:0.前置说明在centos系统中,yum源不直接提供nginx的安装,因此可以通过切换yum源的⽅法进⾏nginx的安装,也可以通过直接下载依赖库和nginx安装包的⽅法来实现,本⽂介绍的是后者。
⼀些必要的库和nginx的关系:nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库然后本⽂将选定/usr/local为安装⽬录,⼀些库的具体版本号各位可根据实际改变,但由于互相依赖,所以最新的可能存在⼀些问题,谨慎选择。
且以下命令均需在root权限下执⾏1.安装gcc gcc-c++(如新环境,未安装请先安装)$ yum install -y gcc gcc-c++2.安装pcre库$ cd /usr/local/$ wget https:///projects/pcre/files/pcre/8.36/pcre-8.36.tar.gz(注:pcre版本会实时更新,8.36版本同样是旧版本,如果需要最新版本⾃⾏搜索pcre即可,然后选择新版本,不过新版本可能会不太稳定,需要注意。
故障-nginx启动失败描述:在⽤saltstack给 minion 安装 nginx 服务时提⽰ nginx 服务下载成功,但是启动失败。
----------ID: nginx-systemctlFunction: service.runningName: nginxResult: FalseComment: Service nginx failed to startStarted: 09:32:48.221250Duration: 3317.741 msChanges:----------nginx:False然后就去minion 端查看了⼀下端⼝是否开启 netstat -lntup 发现没有nginx 进程也没有然后⼿动起了⼀下提⽰如下报错:[root@salt1-minion ~]# systemctl start nginxJob for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe"for details.意思就是Nginx服务起不来了,然后查看⼀下状态吧, systemctl status nginx[root@salt1-minion ~]# systemctl status nginx● nginx.service - The nginx HTTP and reverse proxy serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)Active: failed (Result: exit-code) since Wed 2018-11-2109:33:38 CST; 15s agoProcess: 1475 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)Process: 1472 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)Process: 1471 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)Nov 21 09:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)Nov 21 09:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)Nov 2109:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)Nov 2109:33:38 salt1-minion systemd[1]: nginx.service: control process exited, code=exited status=1Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] still could not bind()Nov 2109:33:38 salt1-minion systemd[1]: Failed to start The nginx HTTP and reverse proxy server.Nov 2109:33:38 salt1-minion systemd[1]: Unit nginx.service entered failed state.Nov 2109:33:38 salt1-minion systemd[1]: nginx.service failed.从报错信息中会看到,Address already in use ,意思就是地址已经被使⽤了。
Nginx报错connect()failed(110:Connectiontimedout。
转⾃背景在对应⽤服务进⾏压⼒测试时,Nginx在持续压测请求1min左右后开始报错,花了⼀些时间对报错的原因进⾏排查,并最终定位到问题,现将过程总结下。
压测⼯具这⾥压测使⽤的是siege, 其⾮常容易指定并发访问数以及并发时间,以及有⾮常清晰的结果反馈,成功访问数,失败数,吞吐率等性能结果。
压测指标单接⼝压测,并发100,持续1min。
压测⼯具报错The server is now under siege...[error] socket: unable to connect sock.c:249: Connection timed out[error] socket: unable to connect sock.c:249: Connection timed outNginx error.log 报错2018/11/21 17:31:23 [error] 15622#0: *24993920 connect() failed (110: Connection timed out) while connecting to upstream, client: 192.168.xx.xx, server: , request: "GET /guide/v1/activities/1107 HTTP/1.1", ups 2018/11/21 18:21:09 [error] 4469#0: *25079420 connect() failed (110: Connection timed out) while connecting to upstream, client: 192.168.xx.xx, server: , request: "GET /guide/v1/activities/1107 HTTP/1.1", upstr排查问题看到 timed out 第⼀感觉是,应⽤服务存在性能问题,导致并发请求时⽆法响应请求;通过排查应⽤服务的⽇志,发现其实应⽤服务并没有任何报错;观察应⽤服务的CPU负载(Docker 容器 docker state id) ,发现其在并发请求时CPU使⽤率升⾼,再⽆其他异常,属于正常情况。
linux编译安装时常见错误解决办法configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution复制代码代码如下:yum -y install libxslt-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.复制代码代码如下:yum -y install net-snmp-develconfigure: error: Please reinstall readline - I cannot find readline.h复制代码代码如下:yum -y install readline-develconfigure: error: Cannot find pspell复制代码代码如下:yum -y install aspell-develchecking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!复制代码代码如下:yum -y install unixODBC-develconfigure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.复制代码代码如下:yum -y install libicu-develconfigure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.复制代码代码如下:yum -y install libc-client-develconfigure: error: freetype.h not found.复制代码代码如下:yum -y install freetype-develconfigure: error: xpm.h not found.复制代码代码如下:yum -y install libXpm-develconfigure: error: png.h not found.复制代码代码如下:yum -y install libpng-develconfigure: error: vpx_codec.h not found.复制代码代码如下:yum -y install libvpx-develconfigure: error: Cannot find enchant复制代码代码如下:yum -y install enchant-develconfigure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/复制代码代码如下:yum -y install libcurl-develLAOGAO added 20140907:configure: error: mcrypt.h not found. Please reinstall libmcrypt.复制代码代码如下:wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gztar zxf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7./configuremake && make installadded 20141003:Cannot find imap复制代码代码如下:ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.soconfigure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.复制代码代码如下:yum -y install libc-client-develCannot find ldap.h复制代码代码如下:yum -y install openldapyum -y install openldap-develconfigure: error: Cannot find ldap libraries in /usr/lib复制代码代码如下:cp -frp /usr/lib64/libldap* /usr/lib/configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path复制代码代码如下:yum -y install postgresql-develconfigure: error: Please reinstall the lib curl distribution复制代码代码如下:yum -y install curl-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.复制代码代码如下:yum -y install net-snmp-develconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution复制代码代码如下:yum -y install libxslt-develchecking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution Fix:复制代码代码如下:yum -y install bzip2-develchecking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/Fix:复制代码代码如下:yum -y install curl-develchecking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).Fix:复制代码代码如下:yum -y install db4-develchecking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.Fix:复制代码代码如下:yum -y install libjpeg-develchecking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found. Fix:复制代码代码如下:yum -y install libpng-develchecking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=configure: error: freetype.h not found.Fix:复制代码代码如下:Reconfigure your PHP with the following option. --with-xpm-dir=/usrchecking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.Fix:复制代码代码如下:yum -y install libXpm-develchecking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.hFix:复制代码代码如下:yum -y install gmp-develchecking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.Fix:复制代码代码如下:yum -y install libc-client-develchecking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.hFix:复制代码代码如下:yum -y install openldap-develchecking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!Fix:复制代码代码如下:yum -y install unixODBC-develchecking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation pathFix:复制代码代码如下:yum -y install postgresql-develchecking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distributionFix:复制代码代码如下:yum -y install sqlite-develchecking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspellFix:复制代码代码如下:yum -y install aspell-develchecking whether to enable UCD SNMP hack… yes checking for default_store.h… nochecking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.Fix:复制代码代码如下:yum -y install net-snmp-develchecking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix:复制代码代码如下:yum -y install libxslt-develconfigure: error: xml2-config not found. Please check your libxml2 installation.Fix:复制代码代码如下:yum -y install libxml2-develchecking for PCRE headers location… configure: error: Could not find pcre.h in /usrFix:复制代码代码如下:yum -y install pcre-develconfigure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!Fix:复制代码代码如下:yum -y install mysql-develchecking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!Fix:复制代码代码如下:yum -y install unixODBC-develchecking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path Fix:复制代码代码如下:yum -y install postgresql-develconfigure: error: Cannot find pspellFix:复制代码代码如下:yum -y install pspell-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.Fix:复制代码代码如下:yum -y install net-snmp-develconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix:复制代码代码如下:yum -y install libxslt-develconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution复制代码代码如下:yum -y install libxslt-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.复制代码代码如下:yum -y install net-snmp-develconfigure: error: Please reinstall readline - I cannot find readline.h复制代码代码如下:yum -y install readline-develconfigure: error: Cannot find pspell复制代码代码如下:yum -y install aspell-develchecking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!复制代码代码如下:yum -y install unixODBC-develconfigure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.复制代码代码如下:yum -y install libicu-develconfigure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.复制代码代码如下:yum -y install libc-client-develconfigure: error: freetype.h not found.复制代码代码如下:yum -y install freetype-develconfigure: error: xpm.h not found.复制代码代码如下:yum -y install libXpm-develconfigure: error: png.h not found.复制代码代码如下:yum -y install libpng-develconfigure: error: vpx_codec.h not found.复制代码代码如下:yum -y install libvpx-develconfigure: error: Cannot find enchant复制代码代码如下:yum -y install enchant-develconfigure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/复制代码代码如下:yum -y install libcurl-develLAOGAO added 20140907:configure: error: mcrypt.h not found. Please reinstall libmcrypt.复制代码代码如下:wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gztar zxf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7./configuremake && make installadded 20141003:Cannot find imap复制代码代码如下:ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.soconfigure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.复制代码代码如下:yum -y install libc-client-develCannot find ldap.h复制代码代码如下:yum -y install openldapyum -y install openldap-develconfigure: error: Cannot find ldap libraries in /usr/lib复制代码代码如下:cp -frp /usr/lib64/libldap* /usr/lib/configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path复制代码代码如下:configure: error: Please reinstall the lib curl distribution复制代码代码如下:yum -y install curl-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.复制代码代码如下:yum -y install net-snmp-develconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution复制代码代码如下:yum -y install libxslt-develchecking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution Fix:复制代码代码如下:yum -y install bzip2-develchecking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/Fix:复制代码代码如下:yum -y install curl-develchecking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).Fix:复制代码代码如下:yum -y install db4-develchecking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.Fix:复制代码代码如下:yum -y install libjpeg-develchecking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.Fix:复制代码代码如下:yum -y install libpng-develchecking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=configure: error: freetype.h not found.Fix:复制代码代码如下:Reconfigure your PHP with the following option. --with-xpm-dir=/usrchecking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.Fix:复制代码代码如下:yum -y install libXpm-develchecking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.hFix:复制代码代码如下:yum -y install gmp-develchecking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.Fix:复制代码代码如下:checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.hFix:复制代码代码如下:yum -y install openldap-develchecking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!Fix:复制代码代码如下:yum -y install unixODBC-develchecking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation pathFix:复制代码代码如下:yum -y install postgresql-develchecking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distributionFix:复制代码代码如下:yum -y install sqlite-develchecking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspellFix:复制代码代码如下:yum -y install aspell-develchecking whether to enable UCD SNMP hack… yes checking for default_store.h… nochecking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.Fix:复制代码代码如下:yum -y install net-snmp-develchecking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix:复制代码代码如下:yum -y install libxslt-develconfigure: error: xml2-config not found. Please check your libxml2 installation.Fix:复制代码代码如下:yum -y install libxml2-develchecking for PCRE headers location… configure: error: Could not find pcre.h in /usrFix:复制代码代码如下:yum -y install pcre-develconfigure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!Fix:复制代码代码如下:yum -y install mysql-develchecking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!Fix:复制代码代码如下:yum -y install unixODBC-develchecking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path Fix:复制代码代码如下:yum -y install postgresql-develconfigure: error: Cannot find pspellFix:复制代码代码如下:yum -y install pspell-develconfigure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.Fix:复制代码代码如下:yum -y install net-snmp-develconfigure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix:复制代码代码如下:yum -y install libxslt-devel。
centos8⾃定义⽬录安装nginx(教程详解)1.安装⼯具和库# PCRE是⼀个Perl库,包括 perl 兼容的正则表达式库。
nginx 的 http 模块使⽤ pcre 来解析正则表达式# zlib库提供了很多种压缩和解压缩的⽅式, nginx 使⽤ zlib 对 http 包的内容进⾏ gzipyum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel2.⽬录结构源码⽬录:/home/werben/pkgsrc/nginx安装⽬录:/home/werben/application/nginx3.下载解压源码4.创建⽤户组和⽤户groupadd wwwuseradd -g www www5.编译源码./configure --user=www --group=www --prefix=/home/werben/application/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --w make && make install6.映射全局命令ln -s /home/werben/application/nginx/sbin/nginx /usr/local/bin/nginx7.启动,停⽌,重启nginx -s stopnginx -s quitngins -s reload8.检测配置⽂件nginx.conf正确性nginx -t9.开机⾃启动vim /lib/systemd/system/nginx.service[Unit]Description=nginxAfter=network.target[Service]Type=forkingExecStart=nginxExecReload=nginx reloadExecStop=nginx quitPrivateTmp=true[Install]WantedBy=multi-user.target#重新加载守护进程systemctl daemon-reload#启动nginx服务systemctl start nginx.service#停⽌nginx服务systemctl stop nginx.service#设置开机⾃启动systemctl enable nginx.service#停⽌开机⾃启动systemctl disable nginx.service#查看服务当前状态systemctl status nginx.service#重新启动服务systemctl restart nginx.service#查看所有已启动的服务systemctl list-units --type=service10.出现问题和解决⽅法#如果`systemctl start nginx.service`提⽰如下报错Job for nginx.service failed because the control process exited with error code.See "systemctl status nginx.service" and "journalctl -xe" for details.#执⾏systemctl status nginx.service#如果出现如下错误Process: 35783 ExecStart=...nginx/sbin/nginx(code=exitedstatus=203/EXEC)nginx.service: Control process exited, code=exited status=203systemd[1]: nginx.service: Failed with result 'exit-code'.localhost.localdomain systemd[1]: Failed to start nginx.journalctl -xe#如果看到如下信息If you believe that systemd should be allowed execute access on the>Then you should report this as a bug.You can generate a local policy module to allow this access.Do allow this access for now by executing:# ausearch -c '(nginx)' --raw | audit2allow -M my-nginx# semodule -X 300 -i my-nginx.pp#解决⽅法setenforce 0vim /etc/selinux/configSELINUX=disabledps:Nginx配置⽂件的结构说明所有Nginx配置⽂件都位于/etc/nginx/⽬录中。
1. 安装完成Nginx后无法站外访问?
刚安装好nginx一个常见的问题是无法站外访问,本机wget、telnet都正常。
而服务器之外,不管是局域网的其它主机还是互联网的主机都无法访问站点。
如果用telnet的话,提示:
正在连接到192.168.0.xxx...不能打开到主机的连接,在端口 80: 连接失败
如果用wget命令的话,提示:
Connecting to 192.168.0.100:80... failed: No route to host.
如果是以上的故障现象,很可能是被CentOS的防火墙把80端口拦住了,尝试执行以下命令,打开80端口:
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
然后用:
/etc/init.d/iptables status
查看当前的防火墙规则,如果发现有这样一条:
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
就说明防火墙规则已经添加成功了,再在站外访问就正常了。
2. 编译pcre错误(源码安装nginx必须先要装pcre)
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src/pcre-8.21'
make: *** [all] Error 2
解决办法:安装g++,别忘了重新configure
apt-get install g++
apt-get install build-essential
make clean
./configure
make
3. make出错
make: *** No rule to make target `build', needed by `default'. Stop. ./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option.
ubuntu下解决办法:
apt-get install openssl
apt-get install libssl-dev
centos下解决办法:
yum -y install openssl openssl-devel
4.依赖软件prce,ssl,zlib未安装错误
1)如果报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option. 需要安装pcre包
Pcre
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
make install
2)如果报错
./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.
需要安装openssl
tar zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config --prefix=/usr/local/ --openssldir=/usr/local/openssl -g3 shared zlib-dynamic enable-camellia
make
make install
测试是否安装成功:openssl version
3)如果报错
configure: error: zlib not found. 需要安装:gzip.tar.gz
tar zxvf gzip.tar.gz
./configure
make
make install。