(四)CentOS 7安装Nginx(编译安装)
来源:互联网 发布:帝霸传奇手游源码 编辑:程序博客网 时间:2024/06/05 19:32
CentOS 7安装Nginx(编译安装)
1、下载
wget http://219.238.7.69/files/1010000009FBF5E7/nginx.org/download/nginx-1.11.13.tar.gz
2、解压
tar -zxvf nginx-1.11.13.tar.gzcd nginx-1.11.13
3、
在安装之前首先检查一下是否已安装nginx的一些模块依赖的lib库,诸如g++、gcc、pcre-devel、openssl-devel和zlib-devel。所以下面这些命令最好挨个跑一遍,已安装的会提示不用安装,未安装或需要更新的则会执行安装及更新:
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel --setopt=protected_multilib=false
4、
安装完依赖后下面就可以放心开始安装nginx了,输入安装命令并指定安装路径:
./configure --prefix=/usr/local/nginx
看到如下提示信息就说明没有问题:
5、
最后通过make以及make install进行编译安装:
make && make install
6、
安装完成后启动一下,输入启动命令
/usr/local/nginx/sbin/nginx
之后访问80端口看看是否安装成功
7、设置为系统服务
vim /lib/systemd/system/nginx.service 创建文件
[Unit] Description=The nginx HTTP and reverse proxy server After=syslog.target 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 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
chmod 745 nginx.service【 chmod 745 /lib/systemd/system/nginx.service】systemctl enable nginx.service
完后就可以使用以下命令管理tengine服务器了:
service nginx startservice nginx stopservice nginx restartsystemctl enable nginx.service【开机自启动】
8、让Tengine可以处理PHP:nginx.conf
#隐藏服务器版本号server_tokens off;server { listen 80; server_name localhost; root /var/www; location / { index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; }}
9、开启80端口(其他端口类似,只针对firewall防火墙)
service firewalld start(启动防火墙)firewall-cmd --zone=public --add-port=80/tcp --permanent(开放端口)
命令含义:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
重启防火墙
firewall-cmd --reload【service firewalld restart(重新启动防火墙)】
0 0
- (四)CentOS 7安装Nginx(编译安装)
- CentOS 7 编译安装Nginx
- CentOS 7 编译安装Nginx
- centos 编译安装nginx
- Centos编译安装nginx
- CentOS 7 编译安装 Nginx 1.9.7
- CentOS源码编译安装Nginx
- Centos下编译安装nginx
- CentOS 7.1编译安装nginx
- CentOS 编译安装 php7 + nginx
- centos下nginx编译安装
- CentOS 下编译安装 Nginx
- 【Nginx】CentOS下编译安装nginx
- CentOS 7 安装 nginx
- [CentOS 7] 安装nginx
- CentOS 7安装Nginx
- CentOS 7 安装 nginx
- Centos 7 安装Nginx
- CUDA+VS2013+Windows7环境配置
- 论文中图片格式的微调使得满页
- 微信小程序源码汇总
- HTML+CSS:圆形和圆角图片格式
- task_struct结构注释
- (四)CentOS 7安装Nginx(编译安装)
- (不推荐使用)springMVC基本配置+继承MultiActionController来实现根据参数名指定要请求的方法
- WebView·开车指南
- 浅谈智能指针shared_ptr
- Android实战_限制EditText 文本输入
- 用Delphi创建服务程序
- linux 静态库的链接 undefined reference
- 理解CSS3弹性盒子模型
- mql数据类型