LANP

解压安装ngnix

1、编译参数

2、./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

3、查看版本

4、/usr/local/nginx/sbin/nginx -v

5、添加运行使用用户

6、/usr/sbin/groupadd nginx

7、/usr/sbin/useradd -g nginx nginx

8、查看配置文件

9、cat /usr/local/nginx/conf/nginx.conf

user www www;

worker_processes 2; #设置值和CPU核心数一致

error_log /usr/local/nginx/logs/nginx_error.log crit; #日志位置和日志级别

pid /usr/local/nginx/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 65535;

events

{

  use epoll;

  worker_connections 65535;

}

http

{

  include mime.types;

  default_type application/octet-stream;

  log_format main  '$remote_addr - $remote_user [$time_local] "$request" '

              '$status $body_bytes_sent "$http_referer" '

              '"$http_user_agent" $http_x_forwarded_for';


#charset gb2312;


  server_names_hash_bucket_size 128;

  client_header_buffer_size 32k;

  large_client_header_buffers 4 32k;

  client_max_body_size 8m;


  sendfile on;

  tcp_nopush on;

  keepalive_timeout 60;

  tcp_nodelay on;

  fastcgi_connect_timeout 300;

  fastcgi_send_timeout 300;

  fastcgi_read_timeout 300;

  fastcgi_buffer_size 64k;

  fastcgi_buffers 4 64k;

  fastcgi_busy_buffers_size 128k;

  fastcgi_temp_file_write_size 128k;

  gzip on;

  gzip_min_length 1k;

  gzip_buffers 4 16k;

  gzip_http_version 1.0;

  gzip_comp_level 2;

  gzip_types text/plain application/x-javascript text/css application/xml;

  gzip_vary on;

  #limit_zone crawler $binary_remote_addr 10m;

#下面是server虚拟主机的配置

server

  {

    listen 80;#监听端口

    server_name localhost;#域名

    index index.html index.htm index.php;

    root /usr/local/nginx/www;#站点目录

      location ~ .*\.(php)?$

    {

      #fastcgi_pass unix:/tmp/php-cgi.sock;

      fastcgi_pass 127.0.0.1:9000;

      fastcgi_index index.php;

      include fastcgi.conf;

    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$

    {

      expires 30d;

  # access_log off;

    }

    location ~ .*\.(js|css)?$

    {

      expires 15d;

  # access_log off;

    }

    access_log off;

  }

}

检查配置文件nginx.conf的正确性命令:

/usr/local/nginx/sbin/nginx -t

Nginx 启动命令如下:

/usr/local/nginx/sbin/nginx

/usr/local/nginx/sbin/nginx -s reopen

测试一下是否有错:/usr/local/nginx/sbin/nginx -t

平滑重启:/usr/local/nginx/sbin/nginx -s reload

加入系统服务  官方文档 https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/

#!/bin/bash

#

# 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: /usr/local/nginx/conf/nginx.conf

# pidfile: /usr/local/nginx/logs/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 改变而进行修改

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)  ## 获取nginx 名称

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {

      [ -x $nginx ] || exit 5

      [ -f $NGINX_CONF_FILE ] || exit 6

      echo -n $"Starting $prog: "

      daemon $nginx -c $NGINX_CONF_FILE

      retval=$?

      echo

      [ $retval -eq 0 ] && touch $lockfile

      return $retval

}

stop() {

      echo -n $"Stopping $prog: "

      killproc $prog -QUIT

      retval=$?

      echo

      [ $retval -eq 0 ] && rm -f $lockfile

      return $retval

}

restart() {

      configtest || return $?

      stop

      start

}

reload() {

      configtest || return $?

      echo -n $"Reloading $prog: "

      killproc $nginx -HUP

      RETVAL=$?

      echo

}

force_reload() {

      restart

}

configtest() {

      $nginx -t -c $NGINX_CONF_FILE

}

rh_status() {

      status $prog

}

rh_status_q() {

      rh_status >/dev/null 2>&1

}

case "$1" in

      start)

      rh_status_q && exit 0

      start

      ;;

      stop)

      rh_status_q || exit 0

      stop

      ;;

      restart|configtest)

      restart

      ;;

      reload)

      rh_status_q || exit 7

      reload

      ;;

      force-reload)

      force_reload

      ;;

      status)

      rh_status

      ;;

      condrestart|try-restart)

      rh_status_q || exit 0

      ;;

      *)

      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"

      exit 2

      ;;

esac

第三步# 设置执行权限chmod +x /etc/init.d/nginx

第四步## 设置中的模式开机启动/sbin/chkconfig nginx on

检查一下## 显示开机启动自动列表是否存在nginxchkconfig --list # 显示开机自动启动的服务sudo chkconfig --list nginx

nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off

完成!

之后,就可以使用以下命令了

service nginx start

service nginx stop

service nginx restart

service nginx reload

service nginx status


将nginx 加入系统变量

修改/etc/profile 文件

  vim /etc/profile

1

添加PATH

如果已经存在PATH 也只需要在下面添加更多的PATH 两者之间不冲突

#  在文件中添加nginx 的执行文件。

export PATH=$PATH:/usr/local/nginx/sbin

1

2

使立即生效

保存文件后PATH 不会立即生效需要执行 source /etc/profile

source /etc/profile




加入执行权限  chmod +x nginx

先将nginx服务加入chkconfig管理列表:

chkconfig –add /etc/init.d/nginx

加完这个之后,就可以使用service对nginx进行启动,重启等操作了。

service nginx start

service nginx stop

加自启服务:https://www.dazhuanlan.com/2019/09/25/5d8ad8a3bb3a7/

解压安装php

/mnt/php

./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg9/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/  --with-gd  --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets  --with-pdo-mysql=/usr/local/mysql --without-pear --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-bcmath

make && make install


2.修改fpm配置php-fpm.conf.default文件名称

mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

3.复制php.ini配置文件

cp php.ini-production /usr/local/php/etc/php.ini

4.复制php-fpm启动脚本到init.d

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

5.赋予执行权限

chmod +x /etc/init.d/php-fpm

6.添加为启动项

chkconfig --add php-fpm

7.设置开机启动

chkconfig php-fpm on

8.按照标准,给php-fpm创建一个指定的用户和组

创建群组:groupadd www

创建一个用户,不允许登陆和不创主目录 :useradd -s /sbin/nologin -g www -M www

9.立即启动php-fpm

service php-fpm start

#或者

/etc/init.d/php-fpm start

WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf

解决办法

# cd /usr/local/php/etc/php-fpm.d/

# cp www.conf.default www.conf

# /usr/local/php/sbin/php-fpm -t

[12-Oct-2017 08:33:29] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

[root@localhost php-fpm.d]# service php-fpm start

Starting php-fpm  done

zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/42.3/oss  openSUSE-42.3-Update-Oss

zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/42.3/non-oss/ openSUSE-42.3-Update-Non-Oss

zypper addrepo -f http://mirrors.aliyun.com/packman/openSUSE_Leap_42.3/ aliyun-packman

#zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/oss/ openSUSE-42.3-Oss

#zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/non-oss/  openSUSE-42.3-Non-Oss

然后更新一下源信息

zypper update

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,386评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,142评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,704评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,702评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,716评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,573评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,314评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,230评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,680评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,873评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,991评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,706评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,329评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,910评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,038评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,158评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,941评论 2 355

推荐阅读更多精彩内容