当前位置: 首页 > Linux

nginx安装到公司需要的

时间:2023-04-06 22:13:26 Linux

指定目录,不同位置的两个nginx需要安装在同一台机器上。什么!我以前直接安装在/user/local/下,或者用yuminstallnginx安装在/etc/nginx下。经过一番查找,终于看到了一些靠谱的答案。./configure\--prefix=你要安装的目录\--sbin-path=/你要安装的目录/nginx\--conf-path=/你要安装的目录/nginx.conf\--pid-path=/你要安装的目录/nginx.pid\--with-http_ssl_module\--with-pcre=/usr/local/pcre-8.38\--with-zlib=/usr/local/zlib-1.2.11\--with-openssl=/usr/local/openssl-1.0.1tmake&&makeinstalltest-d我的理解是从源码编译安装ngixn。./configure这一步是为nginx设置一些常量。而--prefix是设置nginx编译后各处执行文件的地址。网上虽然有一些教程,但是很多都比较老了,有些包也找不到了。然后我会分享我的安装步骤。nginx安装到自定义位置,首先安装pcre。cd/usr/local/#下载wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz#解压tar-zxvfpcre-8.38.tar.gzcdpcre-8.38./configure#编译make&&makeinstall#记住这个安装目录后面会用到#/usr/local/pcre-8.38后面跟着zlibcd/usr/local/#下载wgethttp://www.zlib.net/zlib-1.2.11.tar.gz#解压tar-zxvfzlib-1.2.11.tar.gzcdzlib-1.2.11./configure#编译make&&makeinstall#记住这个安装目录后面会用到#/usr/local/zlib-1.2.11ssl这个不用编译,直接cd/usr/local/wgethttps://www.openssl.org/source/openssl-1.0.1t.tar.gztar-zxvfopenssl-1.0.1t.tar.gz#记住这个安装目录后面会用到#/usr/local/openssl-1.0.1t现在安装Nginxcd/usr/local#下载并解压wgethttp://nginx.org/download/nginx-1.4.2.tar.gztar-zxvfnginx-1.4.2.tar.gz#注意:这只是源代码cdnginx-1.4.2#设置常量./configure\--prefix=/自定义位置/\--sbin-path=/自定义位置/nginx\--conf-path=/customlocation/nginx.conf\--pid-path=/customlocation/nginx.pid\--with-http_ssl_module\--with-pcre=/usr/local/pcre-8.38\#刚刚安装的pcre的位置--with-zlib=/usr/local/zlib-1.2.11\#刚刚安装的zlib的位置--with-openssl=/usr/local/openssl-1.0.1t#Justnow安装openssl的位置#编译make&&makeinstall#重要:如果不执行,则不会创建真正的nginx文件test-d