IT袋

当前位置:主页 > 经验教程 > 系统教程 >

Linux常用命令全集及用法

Linux常用命令全集及用法 linux操作系统常用命令全集(10)

更新:2023-08-08 08:48:08 来源:IT袋 作者:马勇
导读:Linux常用命令全集及用法,4、编译并安装 make make install 11.6.2 如果已经安装过nginx 1、 进入nginx目录: cd /usr/local/项目名/nginx-1.10.0/ 2、 配置FastDFS 模块 ./configure --prefix=/opt/nginx --sbin

Linux常用命令全集及用法

4、编译并安装

make && make install
11.6.2 如果已经安装过nginx
1、 进入nginx目录:

cd /usr/local/项目名/nginx-1.10.0/
2、 配置FastDFS 模块

./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=/usr/local/项目名/fastdfs-nginx-module/src
注意:这次配置时,要添加fastdfs-nginx-moudle模块

3、编译,注意,这次不要安装(install)

make
4、替换nginx二进制文件:

备份:

mv /usr/bin/nginx /usr/bin/nginx-bak
用新编译的nginx启动文件替代原来的:

cp objs/nginx /usr/bin/
11.6.3 启动nginx
配置nginx整合fastdfs-module模块

我们需要修改nginx配置文件,在/opt/nginx/config/nginx.conf文件中:

vim /opt/nginx/conf/nginx.conf
将文件中,原来的server 80{ ...} 部分代码替换为如下代码:

server {
listen 80;
server_name image.项目名.com;
# 监听域名中带有group的,交给FastDFS模块处理
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
启动nginx:

nginx # 启动nginx

nginx -s stop # 停止nginx

nginx -s reload # 重新载入配置文件
# 可通过ps -ef | grep nginx查看nginx是否已启动成功

11.6.4 设置nginx开机启动
创建一个开机启动的脚本:

vim /etc/init.d/nginx
添加以下内容:

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/bin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -n "$user" ]; then
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`

相关阅读