centos7废除了许多以前版本的命令,虽然现在依然向上兼容(最小化安装除外),但是不排除下几个版本彻底废除的事实。
在本次安装php7与php-fpm的过程中发生许多源冲突等错误,所以后面附上可用的源(无冲突)。
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险, 因此社区采用分支的方式来避开这个风险。
vi /etc/selinux/config
#SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加:wq
使用firewalld代替了原来的iptables。下面记录如何使用firewalld开放Linux端口: 开启端口 firewall-cmd –zone=public –add-port=80/tcp –permanent 命令含义: –zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议 –permanent #永久生效,没有此参数重启后失效 重启防火墙 firewall-cmd –reload
1.安装EPEL源
yum -y install epel-release.noarch
2.手动进行系统更新
yum -y update
3.设置系统为香港时区并检查时区设置
timedatectl set-timezone Asia/Hong_Kong timedatectl
4.删除之前的php版本
yum remove php* php-common
5.安装php7相关的源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
6.安装php7及php-fpm
yum -y install php70w php70w-opcache php70w-fpm php70w-mysql php70w-pdo php70w-pgsql php70w-xml php70w-mbstring php70w-mcrypt php70w-gd
7.配置php-fpm
vi /etc/php-fpm.d/www.conf #编辑 user = nginx #修改用户为nginx group = nginx #修改组为nginx :wq #保存退出
8.设置php-fpm开机自启
systemctl enable php-fpm.service
1.安装nginx
yum install nginx
2.配置nginx与php7
vi /etc/nginx/nginx.conf
user nginx; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid 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"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /var/www/html; index index.html index.htm index.php; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } # #choolsearch }:wq #保存退出
1.安装MariaDB
yum -y install mariadb mariadb-server net-tools
2.启动mariadb并设为开机自启
systemctl start mariadb.service systemctl enable mariadb.service
3.安全性设置
mysql_secure_installation
运行后首先会提示输入root密码直接回车(密码为空);然后提示修改root密码直接回车(默认为yes)输入两遍新密码;之后出现的提示选择都是回车(默认为yes)
4.设置远程访问并管理数据库
grant all privileges on . to ‘root’@’%’ identified by ‘zdj123456’;
systemctl restart nginx.service systemctl restart php-fpm.service systemctl restart mysql.service
cd /etc/sysconfig/network-scripts ls vi ifcfg-eno45643132 把ONBOOT=no改为yes service network restart (重启network) 记住ifcfg-eno45643132(数字一人一个样子) 注:最小化安装的centos7不支持ifconfig 代替为ip addr命令