PHP的这些环境在linux下也折腾过很多次了,每次重装都要重新去找这些文档,记性不好,还是自己整理下吧。
Nginx安装
# yum -y install gcc* pcre glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel lrzsz # groupadd www && useradd www -g www # wget http://nginx.org/download/nginx-1.6.1.tar.gz # tar zxvf nginx-1.6.1.tar.gz # cd nginx-1.6.1 # ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log # make && make install
机器为阿里云512MCentOS,刚初始化的机器发现没有make命令,通过yum安装即可。
# yum -y install make
常用操作
-- root软连接到nginx.conf # ln -s /usr/local/webserver/nginx/conf/nginx.conf /root/nginx.conf -- root目录下直接重启脚本 # echo -e '#!/bin/bash \n /usr/local/webserver/nginx/sbin/nginx -s reload ' >> /root/nginx_restart.sh -- 添加执行权限 # chmod +x /root/nginx_restart.sh -- 添加到自启动 # echo '/usr/local/webserver/nginx/sbin/nginx' >>/etc/rc.local 启动Nginx # /usr/local/webserver/nginx/sbin/nginx -- 检测是否配置文件是否正确 # /usr/local/webserver/nginx/sbin/nginx -t -- 重启nginx # /usr/local/webserver/nginx/sbin/nginx -s reload nginx.conf
配置示例,通过vhost来配置新站点,避免nginx.conf文件过长,不方便管理。
# more /root/nginx.conf user www www; worker_processes 1; error_log logs/error.log; pid logs/nginx.pid; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 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; include vhost/*.conf; }
添加80端口
server { listen 80; server_name localhost; index index.htm index.html index.php; root /data/www; access_log /data/logs/nginx/default.access.log; }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索文件
, nginx
, 配置
make
linux系统安装nginx、linux nginx 配置、linux nginx 配置文件、linux nginx php 配置、linux nginx 安装配置,以便于您获取更多的相关知识。
时间: 2024-11-02 03:37:52