crx349 发表于 2023-6-2 23:14:18

Alibaba Cloud Linux 手动编译Nginx+php+mysql 记录

先安装基础包
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel makecmake bison-devel ncurses-devel libpng-devel libjpeg-devel curl-devel bzip2 bzip2-devel libxml2-devel freetype-devel openldap openldap-devel libxslt-devel
1.安装nginx
wget http://nginx.org/download/nginx-1.24.0.tar.gz

wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar -zvxf pcre-8.35.tar.gz
cd pcre-8.35/
./configure
make && make install

tar zvxf nginx-1.24.0.tar.gz
cd nginx-1.24.0/
./configure --prefix=/server/nginx --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-pcre=/home/xmspace.net/pcre-8.35
make
make install
groupadd www
useradd -g www www
vi /server/nginx/conf/nginx.conf


内容:

userwww www;
worker_processes1;

error_log/server/log/nginx/error.log crit;
pid      /server/nginx/logs/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_typeapplication/octet-stream;

      #charsetgb2312;

      server_names_hash_bucket_size 128;
      client_header_buffer_size 32k;
      large_client_header_buffers 4 32k;
      client_max_body_size 50m;

      sendfile on;
      tcp_nopush   on;

      keepalive_timeout 600;

      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_length1k;
      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_zonecrawler$binary_remote_addr10m;
      log_format '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
      include /server/nginx/conf/vhosts/*.conf;
      include /server/nginx/conf/vhosts/website/*.conf;
      
}


自启动:
vi /etc/init.d/nginx

内容:
# nginx Startup script for the Nginx HTTP Server
# chkconfig: - 85 15
# this script create it by crx349. at 2023.06.02
# xmspace.net

nginxd=/server/nginx/sbin/nginx
nginx_config=/server/nginx/conf/nginx.conf
nginx_pid=/server/nginx/logs/nginx.pid

RETVAL=0
prog="nginx"

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.
start() {
   
    if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
      echo "nginx already running...."
      exit 1
    fi
      
    echo -n $"Starting $prog!"
    $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/nginx
    return $RETVAL
}


# Stop nginx daemons functions.
stop() {
    echo -n $"Stopping $prog!"
    $nginxd -s stop
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/nginx
}


# reload nginx service functions.
reload() {

    echo -n $"Reloading $prog!"
    #kill -HUP `cat ${nginx_pid}`
    $nginxd -s reload
    RETVAL=$?
    echo

}

# See how we were called.
case "$1" in
start)
      start
      ;;

stop)
      stop
      ;;

reload)
      reload
      ;;

restart)
      stop
      start
      ;;

*)
      echo $"Usage: $prog {start|stop|restart|reload|help}"
      exit 1
esac

exit $RETVAL


执行权限:
chmod +x /etc/init.d/nginx
chkconfig--add nginx
chkconfig nginx on
service nginx start #启动
/server/nginx/sbin/nginx -t

正常:
nginx: the configuration file /server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /server/nginx/conf/nginx.conf test is successful

2.安装php 7.2.34
**** Hidden Message *****
页: [1]
查看完整版本: Alibaba Cloud Linux 手动编译Nginx+php+mysql 记录