先安装gcc 等
yum -y install gcc gcc-c++ wget
然后装一些库
yum -y install gcc wget automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel
进入默认的软件目录
cd /usr/local/src/
下载 nginx软件
wget http://nginx.org/download/nginx-1.9.5.tar.gz
如果这个下载太慢可以在这里下载http://nginx.org/download/nginx-1.9.5.tar.gz 下载完后yum -y intall lrzsz 装好上传工具
然后用rz上传到服务器
然后解压文件.
tar zxvf nginx-1.9.5.tar.gz
进入 nginx1.9.5的源码 如果想改版本号 可以进入源码目录src/core/nginx.h更改
cd nginx-1.9.5/
创建一个nginx目录用来存放运行的临时文件夹
mkdir -p /var/cache/nginx
开始configure
./configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_temp \ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ --user=nobody \ --group=nobody \ --with-pcre \ --with-http_v2_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-http_auth_request_module \ --with-mail \ --with-mail_ssl_module \ --with-file-aio \ --with-ipv6 \ --with-http_v2_module \ --with-threads \ --with-stream \ --with-stream_ssl_module
接着 编译
make
安装
make install
启动nginx
/usr/sbin/nginx
用ps aux来查看nginx是否启动
ps aux|grep nginx
然后配置服务
vim /usr/lib/systemd/system/nginx.service
按i输入以下内容
[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/var/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
编辑好后保存
然后开启开机启动
systemctl enable nginx.service
用命令关掉nginx
pkill -9 nginx
后面可以用systemctl来操作nginx.service
systemctl start nginx.service
然后php装好后更改配置 编辑/etc/nginx/nginx.conf
如果能正确的开启php-fpm,就完事大吉了:
https://www.cnblogs.com/fps2tao/p/7699766.html (最下面有讲php-fpm)
设置开机启动图形界面ntsysv
转:http://bbs.qcloud.com/thread-10429-1-1.html