centos 切換nginx跟apache環境


啟動nginx的啟動

nginx -c /etc/nginx/nginx.conf

停止nginx的方法切換到apache、

pkill -9 nginx

直接殺死運行中的程序,關閉nginx service httpd start啟動apache
Centos下安裝Lamp和vsftpd、redis

yum安裝httpd和php、mysql服務

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

 
        

查看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  ]

用瀏覽器訪問試試:

 
        

 

 
        


[root@asg11 httpd]#

 
        

Apache的重要配置文件httpd.conf的位置在/etc/httpd/conf/httpd.conf

 
        

[root@asg11 conf]# pwd
/etc/httpd/conf
[root@asg11 conf]# ls
httpd.conf  magic
[root@asg11 conf]#




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM