设为首页 收藏本站
查看: 1274|回复: 0

[经验分享] ubuntu/redhat/centOS下源码安装nginx+php+mysql

[复制链接]

尚未签到

发表于 2018-12-24 10:58:03 | 显示全部楼层 |阅读模式
  
  ubuntu
  安装相关的软件包
  sudo apt-get install libpcre3 libpcre3-dev build-essential libssl-dev
  下载nginx及nginx_upstream_hash补丁包
  wget http://nginx.org/download/nginx-1.2.8.tar.gz
  wget http://wiki.nginx.org/images/1/11/Nginx_upstream_hash-0.3.1.tar.gz
  解压及打补丁
  tar zxvf nginx-1.2.8.tar.gz
  tar zxvf Nginx_upstream_hash-0.3.1.tar.gz
  cd nginx-1.2.8/
  patch -p0 < ../nginx_upstream_hash-0.3.1/nginx.patch
  配置
  ./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --pid-path=/var/run/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=www-data \
  --group=www-data \
  --with-http_gzip_static_module \
  --with-http_realip_module \
  --with-http_stub_status_module \
  --with-http_ssl_module \
  --http-log-path=/var/log/nginx/access.log \
  --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/ \
  --add-module=../nginx_upstream_hash-0.3.1/
  编译与安装
  make && sudo make install
  创建/var/tmp/nginx/client/
  sudo mkdir -p /var/tmp/nginx/client/
  vim /etc/init.d/nginx

  #! /bin/sh
  

  ### BEGIN INIT INFO
  # Provides:          nginx
  # Required-Start:    $local_fs $remote_fs $network $syslog
  # Required-Stop:     $local_fs $remote_fs $network $syslog
  # Default-Start:     2 3 4 5
  # Default-Stop:      0 1 6
  # Short-Description: starts the nginx web server
  # Description:       starts nginx using start-stop-daemon
  ### END INIT INFO
  

  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  DAEMON=/usr/sbin/nginx
  NAME=nginx
  DESC=nginx
  

  test -x $DAEMON || exit 0
  

  # Include nginx defaults if available
  if [ -f /etc/default/nginx ] ; then
  . /etc/default/nginx
  fi
  

  set -e
  

  . /lib/lsb/init-functions
  

  test_nginx_config() {
  if nginx -t $DAEMON_OPTS
  then
  return 0
  else
  return $?
  fi
  }
  

  case &quot;$1&quot; in
  start)
  echo -n &quot;Starting $DESC: &quot;
  test_nginx_config
  start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  --exec $DAEMON -- $DAEMON_OPTS || true
  echo &quot;$NAME.&quot;
  ;;
  stop)
  echo -n &quot;Stopping $DESC: &quot;
  start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
  --exec $DAEMON || true
  echo &quot;$NAME.&quot;
  ;;
  restart|force-reload)
  echo -n &quot;Restarting $DESC: &quot;
  start-stop-daemon --stop --quiet --pidfile \
  /var/run/$NAME.pid --exec $DAEMON || true
  sleep 1
  test_nginx_config
  start-stop-daemon --start --quiet --pidfile \
  /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
  echo &quot;$NAME.&quot;
  ;;
  reload)
  echo -n &quot;Reloading $DESC configuration: &quot;
  test_nginx_config
  start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
  --exec $DAEMON || true
  echo &quot;$NAME.&quot;
  ;;
  configtest)
  echo -n &quot;Testing $DESC configuration: &quot;
  if test_nginx_config
  then
  echo &quot;$NAME.&quot;
  else
  exit $?
  fi
  ;;
  status)
  status_of_proc -p /var/run/$NAME.pid &quot;$DAEMON&quot; nginx && exit 0 || exit $?
  ;;
  *)
  echo &quot;Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}&quot; >&2
  exit 1
  ;;
  esac
  

  exit 0
  添加执行权限
  chmod
  设置开机启动
  sudo update-rc.d nginx defaults
  安装php+mysql
  http://wiki.ubuntu.org.cn/Nginx官方文档详细安装步骤
  Redhat/centOS
  yum install pcre pcre-devel openssl-devel openssl
  yum groupinstall &quot;Development Tools&quot;(类似ubuntu的build-essential)
  其他的同ubuntu步骤一样
  chkconfig nginx on
  安装start-stop-daemon支持/etc/init.d/nginx脚本
  wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
  tar-xzf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
  cd ~/src/apps/sys-utils/start-stop-daemon-IR1_9_18-2
  gcc start-stop-daemon.c -o start-stop-daemon
  cp start-stop-daemon /usr/local/sbin/
  chmod +x /usr/local/sbin/start-stop-daemon
  php官网下载最新稳定版
  http://cn2.php.net/get/php-5.4.15.tar.gz/from/a/mirror
  安装一些相关软件包
  yum install libxml2-devel libcurl-devel
  解压与配置
  tar xvf php-5.4.15.tar.gz
  ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --enable-sockets --enable-zip
  编译与安装
  make && make install
  编译php-fpm配置文件
  cp php-fpm.conf.default php-fpm.conf
  启动php-fpm
  /usr/local/php/sbin/php-fpm
  编译配置nginx.conf或者其他需要配置php支持的站点中
  在需要的站点中添加以下区块
  location \.php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  include        fastcgi_params;
  }
  /etc/init.d/nginx configtest
  /etc/init.d/nginx reload
  elinks http://www.test.com
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-655223-1-1.html 上篇帖子: memcache+php扩展模块的安装 下篇帖子: PHP发布webService和调用webService
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表