这次玩次狠得。除了编译器使用yum安装,其他全部手动编译。哼~
看似就Nginx、PHP、MySql三个东东,但是它们太尼玛依赖别人了。
没办法,想用它们就得老老实实给它们提供想要的东西。
首先的一些模块依赖一些lib库,
如果你是懒人,就顺着下面的命令分别输入就行了。然后直接看配置篇。(不过这样安装的可不是最新版本的哟)
一、准备工作
1.1 更新系统安装包列表
没啥,就他喵想用个最新的。
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># apt update</pre>
1.2 必须软件包
下面都是编译nginx必须的,提前安装好。
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># apt install gcc make
apt install libpcre3 libpcre3-dev //【正则表达式库】 官网http://www.pcre.org/
apt install openssl libssl-dev //【openssl库】 官网https://www.openssl.org/
apt install zlib1g-dev</pre>
1.3 创建需要使用的目录
创建目录source和web,分别用来放源码和编译后的文件。
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># mkdir /source/
mkdir /web/</pre>
二、安装nginx
2.1 安装nginx
[官方网站] http://nginx.org/
命令流程:
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># cd /source/
wget http://nginx.org/download/nginx-1.13.5.tar.gz
tar -zxf nginx-1.13.5.tar.gz
cd nginx-1.13.5 # ./configure --prefix=/web/nginx --with-http_ssl_module
make && make install</pre>
--with-http_ssl_module //打开https
三、配置nginx
****3.1 打开nginx.conf****
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">vim nginx.conf</pre>
****3.2 支持php。在server里加入****
[](javascript:void(0); "复制代码")
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 #
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}</pre>
](javascript:void(0); "复制代码")
3.3 支持asp.net。在server里加入
[](javascript:void(0); "复制代码")
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}</pre>
](javascript:void(0); "复制代码")
3.4 防火墙添加80、443端口(可选,需要外网访问的)
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># firewall-cmd --zone=public --add-port=80/tcp --permanent //--permanent永久生效,没有此参数重启后失效
firewall-cmd --reload //重新载入</pre>
附、常用命令
nginx常用命令
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># ln -s /web/nginx/sbin/nginx /usr/local/bin //快捷方式