centos 切换nginx跟apache环境
启动nginx的启动
1 | nginx -c /etc/nginx/nginx.conf |
停止nginx的方法切换到apache、
pkill -9 nginx
1 2 | 直接杀死运行中的程序,关闭nginx service httpd start启动apacheCentos下安装Lamp和vsftpd、redis |
yum安装httpd和php、mysql服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1: yum search httpd // 搜索httpd开头的软件包 2: yum install httpd.x86_64 // 找到apache 对应的软件包名 Apache HTTP Server,安装 3: yum -y install mysql-server mysql php php-mysql php-xml php-gd php-mbstring // 安装 mysql php 及其扩展 4: service mysqld restart // 启动mysql mysql -uroot -p 空 show databases; 查看数据表 5: iptables -F // 清空防火墙 6: service iptables save // 保存防火墙规则 7: service iptables stop // 关闭防火墙 8: apachectl restart // 这时候会报错 9: vi /etc/httpd/conf/httpd .conf // 配置httpd 10:: set nu // 显示行号 11: : /ServerName // 查找ServerName 12: :1 回到最顶行 13: 去掉 ServerName www.example.com:80 前面的 # 保存 14: serveice httpd restart 重启 apache 15: 访问ip 查看apache启动情况 16: cd /var/www/html // 进入php默认目录 17: vi index.php // 创建PHP文件 保存 刷新查看信息 18:service mysqld start 启动mysql |
有时想知道nigix是否在正常运行,需要用linux命令查看nginx运行情况
执行命令:
ps -A | grep nginx
如果返回结果的话,说明有nginx在运行,服务已经启动。
如果不怕nginx关闭的话。也可以执行:
service nginx restart
把nginx服务重启,在重启时,也可以看到具体有没有什么地方出错。
路径启动,默认在/usr/local/nginx/sbin/nginx
启动:/usr/local/nginx/sbin/nginx
平滑重启:/usr/local/nginx/sbin/nginx -s reload
停止:/usr/local/nginx/sbin/nginx -s stop
重启:/usr/local/nginx/sbin/nginx -s restart
重启nginx
# service nginx restart
1 |
查看Apache是否被安装:
[root@asg11 ~]# find / -name 'httpd'
/etc/sysconfig/httpd
/etc/httpd
/etc/logrotate.d/httpd
/etc/rc.d/init.d/httpd
/var/run/httpd
/var/log/httpd
/var/lock/subsys/httpd
/usr/sbin/httpd
/usr/lib64/httpd
由此确定Apache被安装的地方是/etc/httpd
查看Apache版本
首先进入httpd所在目录
[root@asg11 ~]# cd /etc/httpd
进而查看版本
[root@asg11 httpd]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Aug 13 2013 17:29:28
停止httpd
[root@asg11 httpd]# service httpd stop
Stopping httpd: [ OK ]
启动httpd
[root@asg11 httpd]# service httpd start
Starting httpd: [ OK ]
用浏览器访问试试:
1 |
1 |
[root@asg11 httpd]#
1 |
Apache的重要配置文件httpd.conf的位置在/etc/httpd/conf/httpd.conf
1 |
[root@asg11 conf]# pwd
/etc/httpd/conf
[root@asg11 conf]# ls
httpd.conf magic
[root@asg11 conf]#
1 |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步