标签:新建 scripts http 监听 not found targe ram rgs http请求
(1)安装nginx
1.下载地址: http://nginx.org/en/download.html ,选择下载相应版本,并解压到目录下
2.安装依赖包 yum -y install pcre* yum -y install openssl*
如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库
./configure: error: C compiler cc is not found
#yum install gcc gcc-c++ ncurses-devel perl
3. a、执行 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
b、编译 make
c、安装 make install (如果是非root用户 make 和sudo make install 分开 同理,其他的安装包也是这样)
location / { root /home/www; #根目录,可指定目录 index index.php index.html index.htm; #增加index.php 默认支持php } ……
#打开支持php location ~ \.php$ { # root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #将/scripts 改为 root 指定目录地址 #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /home/www$fastcgi_script_name; include fastcgi_params; } ……
#在配置未见末尾加入 include vhost/*.conf; 建立虚拟主机配置目录
# mkdir vhost
# vim ./nginx.conf (在最后大括号前添加一行并保存退出: include vhost/*.conf; )
6. 可在vhost目录内新建虚拟主机配置文件,以.conf结尾。
server { listen 80;#监听80端口,接收http请求 server_name www.lblog.com;#域名 root /home/www/blog;#准备存放代码工程的路径 index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php$is_args$args; #去除 index.php } location ~ \.php$ { #fastcgi_pass unix:/run/php/php7.0-fpm.sock; #fastcgi_split_path_info ^(.+\.php)(/.+)\$; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #include fastcgi_params; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf;#加载nginx的fastcgi模块 } }
标签:新建 scripts http 监听 not found targe ram rgs http请求
原文地址:http://www.cnblogs.com/aajonas/p/6681404.html