准备工作
《深入理解Nginx》中说明的预备安装包:
gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
Debian实际安装:
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev openssl libssl-dev libperl-dev
安装Nginx
安装Nginx的步骤:
源码下载:http://nginx.org/en/download.html
解压
./configure
make
sudo make install
查看安装:
ls /usr/local/nginx
启动与停止
启动Nginx:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
查看Nginx进程:
ps -ef | grep nginx
kill掉进程
killall -9 nginx
验证安装
通过浏览器查看localhost页面,可以看到如下的内容:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
即证明安装成功。
问题与解决
403 Forbidden
遇到 403 Forbidden
时,可能是权限问题,在nginx.conf头部加入一行:
user root;
然后重启nginx即可。