Linux安装nginx步骤及发布项目方式
------- 安装Nginx ------
1.上传安装包
2.解压安装包
3.进入Nginx目录
4.安装依赖环境
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
yum -y install gcc
5.安装Nginx
./configure
make
make install
安装后在/usr/local下就会有一个nginx目录
6.启动Nginx
cd /usr/local/nginx/sbin
启动
./nginx
停止
./nginx -s stop
重启
./nginx -s reload
7.查看服务状态
ps -ef | grep nginx
8.测试Nginx服务是否成功启动
http://ip地址:80
------- 发布项目 ------
1.创建一个toutiao目录
cd /home
mkdir toutiao
2.将项目上传到toutiao目录
3.解压项目
unzip web.zip
4.编辑Nginx配置文件nginx-1.17.5/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/toutiao;
index index.html index.htm;
}
5.关闭nginx服务
./nginx -s stop
6.启动服务并加载配置文件
/usr/local/nginx/sbin/nginx -c /home/nginx-1.17.5/conf/nginx.conf
7.浏览器打开网址
http://192.168.203.138
1.将安装包放到usr/local文件夹下
3.进入 nginx目录
cd nginx-1.17.5
4.安装依赖环境 yum -y install pcre pcre-devel yum -y install zlib zlib-devel yum -y install openssl openssl-devel yum -y install gcc
5.安装Nginx ./configure make make install 安装后在/usr/local下就会有一个nginx目录
./configure #执行这一步的时候可能会报错:error C compliler cc is not found #解决:yum -y install gcc gcc-c++ autoconf automake make
6.启动Nginx cd /usr/local/nginx/sbin 启动 ./nginx 停止 ./nginx -s stop 重启 ./nginx -s reload
7.查看服务状态 ps -ef | grep nginx
发布项目 方式
1.在home下新建项目文件夹头条
2..将项目上传到新建的项目文件夹目录头条下
3.解压该项目
unzip 项目名
4.编辑配置文件
vim /nginx带版本号的位置/conf/nginx.conf
5.编辑80端口的root路径
root /项目位置
6.关闭nginx服务
./nginx -s stop
7.启动并加载配置
/nginx的路径/sbin/nginx -c /nginx-1.17.5的路径/conf/nginx.conf
8.测试