第一篇:centos7基础系统服务+网络服务+nginx+php+mysql安装配置大汇总

6 篇文章 0 订阅
4 篇文章 0 订阅

**

配置centos基础系统服务,网络服务,nginx,php,mysql

**
让我们一起站在巨人的肩膀上前行!(感谢我们的技术大牛海哥提供最强帮助!)

都是一些安装过程中必现的问题,很实用,为了让大家都能成功,亲自安装了两边,很完美!

CentOS 7.6
CentOS-7-x86_64-DVD-1810.iso

0.很多命令
https://blog.csdn.net/sinat_15955423/article/details/81567468

1.可以忽略:配置网卡
https://blog.csdn.net/qq_34924407/article/details/79967650
本机访问ping的时候,要看下vm的网络管理器中的ip地址是多少,进行ping操作

1.1可以忽略:安装net工具,比如使用netstat

sudo yum install -y net-tools
yum -y install wget

1.2可以忽略:开始ssh
https://blog.csdn.net/u010085423/article/details/78157091/
https://blog.csdn.net/tuntun1120/article/details/65443757
https://www.linuxidc.com/Linux/2015-02/113625.htm
选择桥接,然后查看虚拟机ip,然后就可以连接了

1.3可以忽略,改变ssh的端口号
https://blog.csdn.net/binger14000/article/details/81869353
如果出现问题:
Job for sshd.service failed because the control process exited with error code.
See “systemctl status sshd.service” and “journalctl -xe” for details.

访问这个:
https://blog.csdn.net/mrqiang9001/article/details/78308830
http://www.178linux.com/72697

yum install policycoreutils-python
yum provides semanage

以上可以忽略部分是因为阿里服务器都有了,所以不需要安装,自行建立虚拟机的需要配置

2.关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl is-enabled firewalld.service

https://www.cnblogs.com/moxiaoan/p/5683743.html

https://www.cnblogs.com/kaid/p/7640723.html

3.安装nginx
https://blog.csdn.net/qq_27755287/article/details/80247561

如果重启后,出现

open() “/var/run/nginx/nginx.pid” failed (2: No such file or directory)

则看这个文章:
https://www.cnblogs.com/yufeng218/p/8215421.html

pid /usr/local/nginx/logs/nginx.pid;

如果有这样的问题
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

ps aux|grep nginx
kill 号码

重启nginx服务:

cd /sbin 
./nginx -s reload

4.安装php
https://www.cnblogs.com/EasonJim/p/9614577.html

`chkconfig php-fpm on`  添加到开机启动

配置php上传文件时间及大小

https://www.cnblogs.com/farwish/p/3961819.html

重启nginx就可以,有时候mysql数量不变,其实是可以上传的

5.配置nginx和php

nginx配置文件,参考本身之前的配置文件

##############仅供参考nginx.conf(可直接复制替换自己的配置文件)####################

#user  nobody;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        /usr/sbin/nginx/nginx.pid;
pid /usr/local/nginx/logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;

    keepalive_timeout  65;

    server {
        server_name  localhost;
        
        root /var/www/html/自己的域名/public;
        index index.php index.html ;
    
        charset  utf-8;
    
        client_max_body_size 200m;
    
        access_log  /var/log/nginx/自己的域名.log  main;
        error_log /var/log/nginx/自己的域名-err.log;
    
        
        location /h5 {
            rewrite ^/h5(.+)$ /h5/app/webroot$1 break;
            try_files $uri $uri/  /h5/app/webroot/index.php?$args;
             fastcgi_connect_timeout 150;  
             fastcgi_read_timeout 600;   
             fastcgi_send_timeout 600; 
        }
        
        
        location ~ \.php$ {
            fastcgi_pass   unix:/dev/shm/php-fpm.sock;
            fastcgi_index  index.php;
    
             fastcgi_connect_timeout 150;  
             fastcgi_read_timeout 600;   
             fastcgi_send_timeout 600;   
            fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }


}

##################################

如果之后遇到php文件访问报502错误,可以查看自己的log文件

错误error_log报错:
*19 connect() to unix:/dev/shm/php-fpm.sock failed
upstream: "fastcgi://unix:/dev/shm/php-fpm.sock:

whereis php-fpm.conf
/etc/php-fpm.conf(不用修改)
/etc/php-fpm.d/www.conf

修改:

;listen = 127.0.0.1:9000
 listen = /dev/shm/php-fpm.sock
 listen.owner = nginx
 listen.group = nginx
 listen.mode = 0666



 cd /dev/shm
 touch php-fpm.sock
 chown nginx:nginx php-fpm.sock

重启服务

systemctl restart php-fpm
nginx -s reload

6.安装mysql
https://www.cnblogs.com/freely/p/8087885.html
root密码:自己的密码(尽量复杂点,不让不通过)

mysql建立用户
http://www.cnblogs.com/xujishou/p/6306765.html

如果以上没有问题了,恭喜你,走通了第一步,
那么接下来你可以尝试重启一下虚拟机,
发现一切又都不行了,那么就继续我们的第二篇文章和更多的技术探讨,如有问题请留言!

后续我们将继续第二篇:centos开机启动自动运行服务,memcache,redis,负载配置,会话保持,数据库主从,socket,nginx虚拟机,443ssl配置,压力测试

最后我要感谢上述提及的文章中各位大牛作者的贡献,我只是一个站在居然肩膀上前进的小白,我只是把大家各个分支做了汇总,提及文章的版权均为各位作者所有!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值