仓库
为了可以使用 CentOS 系统的包管理工具去安装更多的东西,我们需要单独安装一些额外的软件仓库。
EPEL
sudo yum install epel-release -y
IUS
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm -y
IUS 仓库里面有我们需要的一些新的软件包,比如 PHP 7。注意我们安装的是为 CentOS 7 这个系统准备的 IUS 仓库,如果你的系统是 CentOS 6,你需要到 IUS 网站上去查找适合的仓库的下载地址。
安装 NGINX
NGINX 这个软件包已经包装在 EPEL 仓库里了,之前我们已经安装了这个仓库,所以可以直接使用包管理工具去安装 NGINX。
sudo yum install nginx -y
启动
sudo systemctl start nginx
开启自启动
sudo systemctl enable nginx
服务启动以后,你就可以在浏览器上使用服务器的 IP 地址,或者指向这个地址的域名访问服务器指定的目录了。你会看到类似下面的这些文字。
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.