配置centos基础系统服务,网络服务,nginx,php,mysql 先收藏留着以后用
感谢海哥总结的教学文档以及相关资料的作者们,为我们提供便捷的学习资料及经验总结
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.
访问这个:
http://www.178linux.com/72697
https://blog.csdn.net/mrqiang9001/article/details/78308830
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
如果有这样的问题
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
nginx配置文件,参考本身之前的配置文件
如果错误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密码:test2019!