云服务器建站步骤(在服务器上搭建网站教程)

刚买了阿里云ECS云服务器,想搭建自己网站

前提 centos服务管理

systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。

systemctl is-enabled iptables.service

systemctl is-enabled servicename.service #查询服务是否开机启动

systemctl enable *.service #开机运行服务

systemctl disable *.service #取消开机运行

systemctl start *.service #启动服务

systemctl stop *.service #停止服务

systemctl restart *.service #重启服务

systemctl reload *.service #重新加载服务配置文件

systemctl status *.service #查询服务运行状态

systemctl –failed #显示启动失败的服务

注:*代表某个服务的名字,如http的服务名为httpd

例如在CentOS 7 上安装http

[root@CentOS7 ~]# yum -y install httpd

启动服务(等同于service httpd start)

systemctl start httpd.service

停止服务(等同于service httpd stop)

systemctl stop httpd.service

重启服务(等同于service httpd restart)

systemctl restart httpd.service

查看服务是否运行(等同于service httpd status)

systemctl status httpd.service

开机自启动服务(等同于chkconfig httpd on)

systemctl enable httpd.service

开机时禁用服务(等同于chkconfig httpd on)

systemctl disable httpd.service

查看服务是否开机启动 (等同于chkconfig –list)

一 搭建LNMP环境

使用了阿里云这篇文档

https://help.aliyun.com/document_detail/97251.html?spm=a2c4g.11186623.6.1154.45217e89won5pW

手动部署LNMP环境

  • 步骤一:准备编译环境
  • 步骤二:安装Nginx
  • 步骤三:安装MySQL
  • 步骤四:安装PHP
  • 步骤五:配置Nginx
  • 步骤六:配置MySQL
  • 步骤七:配置PHP
  • 步骤八:测试访问LNMP平台

我照着文档,但是到最后测试LNMP时,却失败了,

问题0 默认网站路径

配置路径

vim /etc/nginx/nginx.conf

云服务器建站步骤(在服务器上搭建网站教程)

问题1: nginx启动不了

netstat -nltp

发现启动了httpd服务 这可能是之前操作lamp环境时开的,

这两个服务不能同时开,需要关闭一个

停止http服务 systemctl stop httpd

然后再执行 systemctl start nginx

而且还需要取消开机启动httpd 服务

systemctl disable httpd.service

列出网络连接

netstat -nltp

云服务器建站步骤(在服务器上搭建网站教程)

问题2:

在地址栏输入http://<ECS实例公网IP地址>/phpinfo.php后,打不开网页

原因,在安全组添加规则

云服务器建站步骤(在服务器上搭建网站教程)

具体:

云服务器建站步骤(在服务器上搭建网站教程)

云服务器建站步骤(在服务器上搭建网站教程)

问题3:

云服务器建站步骤(在服务器上搭建网站教程)

解决:

云服务器安全组

参考这篇文章

workbench远程连接到linux实例

(0)
小多多的头像小多多创始人

相关推荐

发表回复

登录后才能评论