准备工作
自行下载安装centos7 mini
注意
cenos7 默认安装mariadb而不是mysql
先开启网络!!
安装步骤
安装mariadb
通过yum在线安装:
1、yum -y install mariadb-server mariadb mariadb-devel
或yum install mariadb mariadb-server
2、systemctl start mariadb启动
3、systemctl enable mariadb 开机自启动
4、mysql_secure_installation 设置 root密码等相关
5、firewall-cmd --permanent --add-service mysql 防火墙加入mysql
6、systemctl restart firewalld.service 重启防火墙
7、iptables -L -n|grep 3306 查看防火墙又没开放3306
8、msyql -uroot -p 连接mysql
9、show databases; 查看数据库
设置数据库远程访问
1、mysql -uroot -p;链接数据库
2、use mysql; 选择数据库
3、grant all privileges on *.* to ‘root’@'%' identified by 'root';
4、flush privileges; 刷新权限
安装nginx
1、 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-
7-0.el7.ngx.noarch.rpm
2、 yum install nginx
3、systemctl start nginx.service
4、systemctl enable nginx.service
5、防火墙开启80端口firewall-cmd --zone=public --add-port=80/tcp --permanent
6、systemctl restart firewalld.service重启防火墙
7、systemctl start nginx.service
配置nginx
1、cp nginx.conf nginx.conf.origin
2、vim /etc/nginx/nginx.conf:
user nginx;
worker_processes 1;
sendfile on;
tcp_nopush on;
//keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
index index.php index.html index.htm;
3、cd /etc/nginx/conf.d
4、cp default.conf default.conf.origin
5、vim default.conf:
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
6、systemctl start php-fpm.service
7、systemctl enable php-fpm.service
8、systemctl restart nginx.service
9、cd /usr/share/nginx/html/
10、vim index.php:
<?php
…………;
?>
安装php
1、rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
2、http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
3、yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
4、yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
5、php -v 显示版本
配置php
1、vi /etc/php.ini #编辑
2、date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
3、expose_php = Off #禁止显示php版本的信息
4、short_open_tag = ON #支持php短标签
5、open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
6、:wq! #保存退出
7、systemctl restart mariadb.service #重启MariaDB
8、systemctl restart httpd.service #重启