Part1:Install nginx
#为了源码能正常的编译运行先安装开发工具
yum group install “Development Tools”
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar xvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make
make install
wget http://nginx.org/download/nginx-1.6.3.tar.gz
tar xvf nginx-1.6.3.tar.gz
cd nginx-1.6.3
[root@instance-1 nginx-1.6.3]# ./configure –prefix=/usr/local/nginx
#检查系统环境:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib= option.
yum install -wget http://jp2.php.net/distributions/php-7.0.12.tar.gzy zlib-devel
make
make install
[root@instance-1 nginx-1.6.3]# cd /usr/local/nginx/
[root@instance-1 nginx]# ls
conf html logs sbin
[root@instance-1 vhost]# cd conf
[root@instance-1 vhost]# cat -n www.test.com.conf
1 server{
2 listen 104.199.224.159:80;
3 server_name www.test.com;
4
5 access_log /data/logs/www.test.com.log main;
6 error_log /data/logs/www.test.com.error.log;
7
8 location /{
9 root /data/www.test.com;
10 index index.html index.htm;
11 }
12 }
#把虚拟主机配置文件包含进主文件
[root@instance-1 vhost]# vim ../nginx.conf
把 log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
前面的#去掉
并在结尾加上 include vhost/*.conf;
保存并退出
[root@instance-1 vhost]# mkdir -p /data/logs
[root@instance-1 vhost]# vim ../nginx.conf
[root@instance-1 vhost]# touch /data/logs/www.test.com.log
[root@instance-1 vhost]# touch /data/logs/www.test.com.errot.log
[root@instance-1 vhost]# touch /data/logs/www.test.com.error.log
[root@instance-1 vhost]# cd ../../sbin
[root@instance-1 sbin]# vim /usr/local/nginx/conf/nginx.conf
[root@instance-1 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@instance-1 sbin]# cd ..
[root@instance-1 nginx]# cd conf/vhost/
[root@instance-1 vhost]# ls
www.test.com.conf
[root@instance-1 vhost]# mkdir -p /data/www.test.com
[root@instance-1 vhost]# echo “www.test.com.index”>/data/www.test.com/index.html
[root@instance-1 vhost]# curl www.test.com
www.test.com.index
Part2:Install PHP
wget http://jp2.php.net/distributions/php-7.0.12.tar.gz
tar xvf php-7.0.12.tar.gz
cd php-7.0.12
./configure –prefix=/usr/local/php
make
make install
Mistakes:
cd /usr/local/nginx
没有那个目录
检查发现./configure –prefix==/usr/local/nginx多了一个等于
[root@instance-1 sbin]# ./nginx -t
nginx: [emerg] unexpected “}” in /usr/local/nginx/conf/nginx.conf:117
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
忘记加;