首页 > 代码库 > 5分钟搭建 nginx +php --------------(LNMP)新手专用
5分钟搭建 nginx +php --------------(LNMP)新手专用
先把php 和php-fpm编译安装吧 请看http://heilinux.blog.51cto.com/6123663/1575582
1 | cd php-5.6.2 |
cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default.conf php-fpm.conf
/usr/local/php/sbin/php-fpm -t
cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod 755 /etc/init.d/php-fpm service php-fpm start
chkconfig php-fpm on
ps aux |grep php-fpm
netstat -ant |grep 9000
安装nginx
1 2 | wget http: //nginx .org /download/nginx-1 .6.2. tar .gz // 最新稳定版哦 |
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2 ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
make
make install
1 2 | ln -sf /usr/local/nginx/sbin/nginx /usr/sbin |
1 | nginx -t 测试一下吧,成功了吧,是不是很有成就感,别着急 咱们继续! |
> /usr/local/nginx/conf/nginx.conf
vim /usr/local/nginx/conf/nginx.conf
user nobody nobody; worker_processes 2; error_log /usr/local/nginx/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 6000; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format combined_realip ‘$remote_addr $http_x_forwarded_for [$time_local]‘ ‘$host "$request_uri" $status‘ ‘"$http_referer" "$http_user_agent"‘; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; server { listen 80; server_name localhost; index index.html index.htm index.php; root /usr/local/nginx/html; location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; } } }
测试是否解析php文件
vim /usr/local/nginx/html/2.php
<?php echo "测试php是否解析"; ?>
curl localhost/2.php
欢迎大家访问我的个人网站 萌萌的IT人
5分钟搭建 nginx +php --------------(LNMP)新手专用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。