web服务器
- Apache
- Nginx:安装配置简洁(官网:http://nginx.org)
LNMP之nginx服务器编译安装
yum install -y wget gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel
cd /usr/local/src
wget "http://nginx.org/download/nginx-1.9.9.tar.gz"
tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure --prefix=/usr/local/nginx
make && make install
手动启动和关闭nginx
- 环境变量:
echo "export PATH=\$PATH:/usr/local/nginx/sbin" >>/etc/profile && source /etc/profile
- 检查nginx配置:nginx -t
- 启动nginx:nginx
- 关闭nginx:nginx -s stop
验证nginx安装是否成功
- 查看进程
- 查看监控端口
- 浏览器访问
使用systemctl管理nginx
cat >/usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
[Install]
WantedBy=multi-user.target
EOF