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

你可能感兴趣的:(LANP)