问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何在 centos 7 中编译安装 nginx1.7.8

发布网友 发布时间:2022-04-10 13:02

我来回答

2个回答

懂视网 时间:2022-04-10 17:23


  yum源:wget -c http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repo.d/CentOS7-Base-163.repo

下载软件包:
  wget -c https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.3.9/source/mariadb-10.3.9.tar.gz
  wget -c http://nginx.org/download/nginx-1.15.3.tar.gz
  wget -c http://cn2.php.net/distributions/php-7.2.10.tar.gz

安装nginx依赖包:
  yum update -y 
  yum -y groupinstall "Development tools"
  yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel cmake

新建nginx用户和用户组:
  groupadd nginx
  useradd -g nginx -s /sbin/nologin nginx

安装nginx1.15.3 

  tar -xvf nginx-1.15.3.tar.gz
  cd nginx-1.15.3
  ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --user=nginx --group=nginx --with-pcre --with-http_v2_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-threads --with-stream --with-stream_ssl_module 
  make
  make install
  mkdir -pv /var/tmp/nginx/client


新建nginx启动脚本
  vim /etc/init.d/nginx

 1 #!/bin/sh 
 2 # 
 3 # nginx - this script starts and stops the nginx daemon 
 4 # 
 5 # chkconfig: - 85 15 
 6 # description: Nginx is an HTTP(S) server, HTTP(S) reverse  
 7 #  proxy and IMAP/POP3 proxy server 
 8 # processname: nginx 
 9 # config: /etc/nginx/nginx.conf 
10 # config: /etc/sysconfig/nginx 
11 # pidfile: /var/run/nginx.pid 
12 # Source function library. 
13 . /etc/rc.d/init.d/functions
14 # Source networking configuration. 
15 . /etc/sysconfig/network
16 # Check that networking is up. 
17 [ "$NETWORKING" = "no" ] && exit 0
18 nginx="/usr/sbin/nginx"
19 prog=$(basename $nginx)
20 NGINX_CONF_FILE="/etc/nginx/nginx.conf"
21 [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
22 lockfile=/var/lock/subsys/nginx
23 start() {
24 [ -x $nginx ] || exit 5
25 [ -f $NGINX_CONF_FILE ] || exit 6
26 echo -n $"Starting $prog: " 
27 daemon $nginx -c $NGINX_CONF_FILE
28 retval=$?
29 echo 
30 [ $retval -eq 0 ] && touch $lockfile
31  return $retval
32 }
33 stop() {
34 echo -n $"Stopping $prog: " 
35 killproc $prog -QUIT
36 retval=$?
37 echo 
38 [ $retval -eq 0 ] && rm -f $lockfile
39  return $retval
40 killall -9 nginx
41 }
42 restart() {
43 configtest || return $?
44  stop
45 sleep 1
46  start
47 }
48 reload() {
49 configtest || return $?
50 echo -n $"Reloading $prog: " 
51 killproc $nginx -HUP
52 RETVAL=$?
53 echo 
54 }
55 force_reload() {
56  restart
57 }
58 configtest() {
59 $nginx -t -c $NGINX_CONF_FILE
60 }
61 rh_status() {
62  status $prog
63 }
64 rh_status_q() {
65 rh_status >/dev/null 2>&1
66 }
67 case "$1" in
68  start)
69  rh_status_q && exit 0
70 $1
71  ;;
72  stop)
73  rh_status_q || exit 0
74  $1
75  ;;
76 restart|configtest)
77  $1
78  ;;
79  reload)
80  rh_status_q || exit 7
81  $1
82  ;;
83 force-reload)
84  force_reload
85  ;;
86  status)
87  rh_status
88  ;;
89 condrestart|try-restart)
90  rh_status_q || exit 0
91   ;;
92 *)
93 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 
94  exit 2
95 esac

  chmod u+x /etc/init.d/nginx
  chkconfig --add nginx
  chkconfig nginx on
  service nginx start

安装MariaDB依赖包
  yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel cmake ncurses-devel bison

新建mysql用户及用户组
  groupadd mysql
  useradd -g mysql -s /sbin/nologin mysql
  mkdir -pv /var/mysql/data
  chown -R mysql.mysql /var/mysql
  mv /etc/my.cnf /etc/my.cnf.bak

安装MariaDB10.3.9
  tar -xvf mariadb-10.3.9.tar.gz
  cd mariadb-10.3.9
  cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/mysql/data -DSYSCONFDIR=/etc  -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_TCP_PORT=3306  -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysql.sock
  make
  make install
  chown -R mysql:mysql /usr/local/mysql/

新建MariaDB启动脚本
  cp  /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
  chmod u+x /etc/init.d/mysqld
  chkconfig --add mysqld
  chkconfig mysqld on

初始化MariaDB
  /usr/local/mysql/scripts/mysql_install_db  --user=mysql --datadir=/var/mysql/data/ --basedir=/usr/local/mysql
  vim /etc/my.cnf

 1 [mysqld]
 2 datadir=/var/mysql/data
 3 basedir=/usr/local/mysql
 4 socket=/tmp/mysql.sock
 5 log_bin=/var/mysql/logbin
 6 user=mysql
 7 port=3306
 8 # Disabling symbolic-links is recommended to prevent assorted security risks
 9 symbolic-links=0
10 # Settings user and group are ignored when systemd is used.
11 # If you need to run mysqld under a different user or group,
12 # customize your systemd unit file for mariadb according to the
13 # instructions in http://fedoraproject.org/wiki/Systemd
14 
15 [mysqld_safe]
16 log-error=/var/log/mariadb/mariadb.log
17 pid-file=/var/lib/mysql/mysql.pid
18 #
19 # include all files from the config directory
20 #
21 !includedir /etc/my.cnf.d

  service mysqld start
  /usr/local/mysql/bin/mysql_secure_installation #设置MairiaDB密码

添加mysql至环境变量

  echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
  source /etc/profile

安装php依赖包
  yum install epel-release -y
  yum install libmcrypt libmcrypt-devel mhash mhash-devel libxml2 libxml2-devel bzip2 bzip2-devel libpng-devel libjpeg-devel  freetype-devel  libtidy-devel libtidy  libcurl-devel  gmp-devel libicu-devel openldap openldap-devel   libsmbclient ImageMagick-devel readline-devel libc-client-devel  zlib1g-dev -y 
  ln -s /usr/lib64/libc-client.so /usr/lib/
  ln -s /usr/lib64/libssl.so /usr/lib/
  ln -s /usr/lib64/libldap.so /usr/lib/
  cp -frp /usr/lib64/libldap* /usr/lib/

安装php-7.2

  tar -xvf php-7.2.10.tar.gz
  cd php-7.2.10
  ./configure --prefix=/usr/local/php  --with-config-file-path=/usr/local/php/etc  --with-fpm-user=nginx  --with-fpm-group=nginx --enable-fpm --with-mhash --with-openssl --enable-bcmath --enable-mbstring --enable-calendar  --enable-json --enable-ftp  --enable-sockets --enable-session --enable-soap --with-gmp --with-kerberos --with-imap --with-imap-ssl --with-mysqli --with-pdo-mysql --enable-inline-optimization  --with-mhash  --with-gd --with-jpeg-dir --with-png-dir --with-pcre-dir  --with-freetype-dir --with-curl --with-gettext --with-bz2   --enable-mysqlnd   --with-gettext  --enable-bcmath   --with-iconv-dir  --without-pear
  make
  make install 
  mkdir -p /var/lib/php/session
  chown nginx:nginx -R /var/lib/php/session/

创建php启动脚本

  cp /root/php-7.2.10/php.ini-production /usr/local/php/etc/php.ini
  cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
  ln -s /usr/local/php/etc/php.ini /usr/local/etc/
  ln -s /usr/local/php/etc/php-fpm.conf /usr/local/etc/
  ln -s /usr/local/php/etc/php-fpm.d/www.conf /usr/local/etc/
  cp /root/php-7.2.10/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  chmod u+x /etc/init.d/php-fpm
  chkconfig --add php-fpm
  chkconfig php-fpm on
  service php-fpm start

添加php至环境变量
  echo "export PATH=$PATH:/usr/local/php/bin" >>/etc/profile
  source /etc/profile

nginx支持php
  vim /etc/nginx.nginx.conf
  

 1 #user nobody;
 2 worker_processes 1;
 3 
 4 #error_log logs/error.log;
 5 #error_log logs/error.log notice;
 6 #error_log logs/error.log info;
 7 
 8 #pid logs/nginx.pid;
 9 
 10 
 11 events {
 12 worker_connections 1024;
 13 }
 14 
 15 
 16 http {
 17  include mime.types;
 18 default_type application/octet-stream;
 19 
 20 #log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
 21 #   ‘$status $body_bytes_sent "$http_referer" ‘
 22 #   ‘"$http_user_agent" "$http_x_forwarded_for"‘;
 23 
 24 #access_log logs/access.log main;
 25 
 26  sendfile on;
 27  #tcp_nopush on;
 28 
 29 #keepalive_timeout 0;
 30 keepalive_timeout 65;
 31 
 32 #gzip on;
 33 
 34  server {
 35  listen 80;
 36  server_name localhost;
 37 
 38  #charset koi8-r;
 39 
 40  #access_log logs/host.access.log main;
 41 
 42  location / {
 43  root /usr/local/nginx/html;
 44   index index.php index.html index.htm;
 45  }
 46 
 47  #error_page 404  /404.html;
 48 
 49  # redirect server error pages to the static page /50x.html
 50  #
 51  error_page 500 502 503 504 /50x.html;
 52  location = /50x.html {
 53  root /usr/local/nginx/html;
 54  }
 55 
 56  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 57  #
 58  #location ~ .php$ {
 59  # proxy_pass http://127.0.0.1;
 60  #}
 61 
 62  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 63  #
 64  location ~ .php$ {
 65  root  /usr/local/nginx/html;
 66  fastcgi_pass 127.0.0.1:9000;
 67   fastcgi_index index.php;
 68  fastcgi_param SCRIPT_FILENAME usr/local/nginx/html/$fastcgi_script_name;
 69   include fastcgi_params;
 70  }
 71 
 72  # deny access to .htaccess files, if Apache‘s document root
 73  # concurs with nginx‘s one
 74  #
 75  #location ~ /.ht {
 76  # deny all;
 77  #}
 78  }
 79 
 80 
 81 # another virtual host using mix of IP-, name-, and port-based configuration
 82  #
 83  #server {
 84 # listen 8000;
 85 # listen somename:8080;
 86  # server_name somename alias another.alias;
 87 
 88 # location / {
 89  # root html;
 90  # index index.html index.htm;
 91  # }
 92  #}
 93 
 94 
 95  # HTTPS server
 96  #
 97  #server {
 98 # listen 443 ssl;
 99  # server_name localhost;
100 
101  # ssl_certificate cert.pem;
102  # ssl_certificate_key cert.key;
103 
104  # ssl_session_cache shared:SSL:1m;
105  # ssl_session_timeout 5m;
106 
107 # ssl_ciphers HIGH:!aNULL:!MD5;
108  # ssl_prefer_server_ciphers on;
109 
110 # location / {
111  # root html;
112  # index index.html index.htm;
113  # }
114  #}
115 
116 }

添加测试页面

  vim /usr/local/nginx/html/index.php

<?php
$conn=mysqli_connect(‘127.0.0.1‘,‘root‘,‘yh984664‘);
if ($conn){
echo "LNMP platform connect to mysql is successful!";
}else{
echo "LNMP platform connect to mysql is failed!";
}
phpinfo();
?>

 

  

Centos7编译安装nginx1.15+MariaDB10.3+php-7.2

标签:htaccess   roo   kconfig   安装nginx   proc   oba   utf8   gcc-c++   clu   

热心网友 时间:2022-04-10 14:31

1.先从nginx官网下载最新的版本 http://nginx.org/download/nginx-1.7.8.tar.gz
2.解压nginx-1.7.8.tar.gz,然后执行下面操作即可

./configure --prefix=/usr/local/nginx
make
make install
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
人类如何才能悬浮在空中? - 知乎 人体悬浮术是真的存在吗 人体怎样才能真正的在空中悬浮 小孩c蛋白反应高是什么原因 (2014?南海区二模)如图所示,物重G为2000N,小红用800N的拉力花2s的时间... 苹果13系列升级iOS15.5好吗? 出生2o12年11月20日2点姓石光字辈取名 求龙凤胎名字:2012年6月21日(农历5月初3)凌晨0点40分出生,大的为龙,小... by和take有什么区别 takeby后面跟交通工具的区别 公路试验检测工作前景如何? 血糖24点是意味着什么 公路试验员和房建试验员有什么区别 考哪个证可以两样都能做 血糖24点是意味着什么? 公路工程试验检测师怎么样 我的血糖24点,严重吗 在公路工程中的第三方检测做试验员工作平时主要做什么、待遇怎么样啊有前途么?跪求相关人士解答 万分感激 血糖是24.6严重吗 公路工程试验检测员考试一定要有工作经验吗? 我的 血糖24点,严重吗 考公路试验检测员需要看哪些书? 炒大虾的做法,上海青菜炒大虾怎么做好吃 公路试验员的特点 什么酒店管理系统最好 建设部和交通部的 公路试验检测员 证书有什么区别啊 捷信达酒店管理系统门锁卡维护能注销校时卡吗 公路试验人员岗位职责? 选什么酒店管理系统合适 公路试验检测员的职能? 市场上有哪些连锁酒店管理系统,中软、西软、华仪、住哲、捷信达?如何选择? 24点7796 血糖24点多,怎么办 紧急!!!血糖检测高达24点,有专家帮回答下?拜谢! 我妈妈今年56岁 现在糖尿病的血糖是24点几,应该怎么办 梦见办酒席剩下好多鱼啥意思&#39;都是吃剩下的 我父亲有糖尿病 血糖24点多 尿糖四个加 我该怎么办啊 急!急!急!急啊!!! 血糖最高多少? 梦见好多人在一起吃饭端上来好长一条鱼 糖尿病的血糖达到27点多是达到严重程度不? 梦见盛饭电饭锅里盛到一条鱼 身后一排人都在排队盛盛饭 血糖22.1mmol/L有多严重 血糖20.8严重吗? 梦见有很多鱼一转眼就剩下一条鱼了 日本成年男性平均身高是多少? 梦到鱼代表什么梦到鱼代表什么 大概早上四五点的时候梦到的 一家人在一起吃饭 做了一条鱼个挺大的 看的像 血糖值27了,是不是很严重了 日本成年男性达的到1米76吗? 日本平均身高是多少? 现在的日本男性身高平均是多少? 00后男生平均身高多少?