当前位置:首页 » 操作系统 » 源码安装nginx

源码安装nginx

发布时间: 2022-01-18 19:12:48

编译安装nginx和yum安装nginx有什么区别

如果真的要说区别的话,源码编译安装可以在各个linux系统下使用,而yum安装只能在redhat或centos系统使用,其它系统例如ubuntu,freebsd是不可用的。另外yum安装的nginx版本偏低,而源码包是可以获取官方最新的发行版本的。

⑵ OpenSUSE linux 12 下如何安装nginx(源码安装方式,不是rpm包安装方式)

源码包里面有readme,自己看。

⑶ 如何在linux上安装nginx

#forcentos
yuminstall-yepel-release&&yumcleanall&&yummakecache
yuminstall-ynginx

如果编译安装的话需要很多依赖包。YUM安装是最简单的。

⑷ 编译安装nginx的配置文件的路径在哪

这个版本不同,位置还是不同的。
我的是nginx-1.9.9版本源码安装,配置文件在conf这个目录里面:
/usr/local/nginx/conf/nginx.conf
如果你找不见也可以搜索:
find / | grep nginx.conf

⑸ centos7怎么编译安装nginx

安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++

如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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.
解决方法:
yum install pcre-devel

如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, 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.
解决方法:
yum install openssl-devel

以上错误提示依次解决后:再一次的运行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_mole
#开启ssl支持
--with-http_ssl_mole
#开启GZIP功能
--with-http_gzip_static_mole

因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable xxx.service #开机运行服务
systemctl disable xxx.service #取消开机运行
systemctl start xxx.service #启动服务
systemctl stop xxx.service #停止服务
systemctl restart xxx.service #重启服务
systemctl reload xxx.service #重新加载服务配置文件
systemctl status xxx.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

因此,添加上面脚本后,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查询nginx是否开机启动
systemctl enable nginx.service #开机运行nginx
systemctl disable nginx.service #取消开机运行nginx
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl reload nginx.service #重新加载nginx配置文件
systemctl status nginx.service #查询nginx运行状态
systemctl --failed #显示启动失败的服务

⑹ 如何在云主机上利用源代码安装Nginx服务器

1这些设置可能会有所不同,你需要根据不同情况进行修改。 2安装Apache2 2.切换管理员身份 在Ubuntu中需要用root身份进行操作,所以用下面的命令确保以root身份登录: sudo su 3.开始安装Mysql5 apt-get install mysql-server mysql-client 你将被要求提供一个MySQL的root用户的密码,我们需要在红色区域设置密码。 New password for the MySQL "root" user: <-- yourrootsqlpassword Repeat password for the MySQL "root" user: <-- yourrootsqlpassword 4.安装Apache2 Apache2的是作为一个Ubuntu的软件包,因此我们可以直接用下面命令安装它: apt-get install apache2 5.安装php5 我们可以直接安装PHP5和Apache的PHP5的模块,如下: apt-get install php5 libapache2-mod-php5 安装完需要重启 /etc/init.d/apache2 restart 6.测试的PHP5并获取PHP5安装的详细信息: 默认网站的文件根目录是在/var/www下中。现在我们将在该目录中创建一个小型PHP文件(info.php的)在浏览器中调用它。该文件将显示很多关于我们的PHP安装,如安装的PHP版本和有用的一些细节。 7.PHP5获得MySOL的支持 让PHP在MySQL中获得支持,我们可以安装的php-mysql软件包。安装一些其他的PHP5模块,以及您可能需要的应用程序,这是一个好主意: apt-cache search php5 还安装需要安装的 apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl 现在重新启动Apache2的: /etc/init.d/apache2 restart 8.安装phpMyAdmin phpMyAdmin是一个网络接口,通过它可以管理你的MySQL数据库。 apt-get install phpmyadmin 你会看到以下问题: Web server to reconfigure automatically: <-- apache2 Configure database for phpmyadmin with dbconfig-common? <-- No

⑺ 求大神指导Centos7 源码编译安装Nginx+PHP 配置动静分离

这个是我的服务的实际 将配置Nginx实现动静分离,对php页面的请求转发给LAMP处理,而静态页面交给Nginx,以实现动静分离。客户请求静态数据给Nginx,Nginx直接应答客户端,当请求动态数据到Nginx时,Nginx让客户端去找LAMP,通过代理的方式,LAMP就和客户端连接了。分别配置动态分离和静态分离

(1)架设并调试后端LAMP架构,指定的域名,IP地址为xxxx,创建动态页面test.php。

(2)配置Nginx(xxxx)处理动态页面请求,并把域名改为 chaodiquan.com 在server{};段中加入以下代码,检测语法后,重启Nginx

(3)客户端输入xxxx/test.php 成功后动态分离就实现了,接下来再配置静态分离

(4)配置Nginx处理静态页面请求,在server{};中加入以下代码,检测语法后,重启Nginx

location ~ .*.(gif|jpg|jpeg|bmp|swf)$ { #这段代码意思是任意网址以这5种格式为结尾就到Nginx根目录下的html文件夹寻找资源

root html;
expires 1d; #缓存一天}

(5)在nginx的html目录中,放入图片aa.jpg,然后在apache的动态测试页test.php中添加

<html>
<body>
<img src="aaaa/aa.jpg">
</body>
</html>

(6)客户端输入xxxx/test.php测试,由于test.php是动态页面,因此客户端会找到LAMP架构中的Apache,然后调取图片aa.jpg是静态数据,所以从Nginx提取,最后反馈给客户端。这个是

⑻ 源码安装nginx需要安装哪些东西

nginx配置里面配置一个server段,然后把网站的目录,域名,别名等配置好就可以了。想要好管理配置,用include加个文单花厕拘丿饺搽邪敞矛件,里面专门配置server段

⑼ 如何重新编译安装一下nginx,让它支持 sub

nginx编译配置

最后的--add-mole就是引入的subs_filter模块。
编译并安装nginx
在/etc/nginx/nginx.config中配置subs_filter

热点内容
单片机android 发布:2024-09-20 09:07:24 浏览:765
如何提高三星a7安卓版本 发布:2024-09-20 08:42:35 浏览:664
如何更换服务器网站 发布:2024-09-20 08:42:34 浏览:311
子弹算法 发布:2024-09-20 08:41:55 浏览:289
手机版网易我的世界服务器推荐 发布:2024-09-20 08:41:52 浏览:817
安卓x7怎么边打游戏边看视频 发布:2024-09-20 08:41:52 浏览:162
sql数据库安全 发布:2024-09-20 08:31:32 浏览:94
苹果连接id服务器出错是怎么回事 发布:2024-09-20 08:01:07 浏览:507
编程键是什么 发布:2024-09-20 07:52:47 浏览:658
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:481