1. yum update #yum的安装
yum安装nginx,安装nginx最新源
1. yum localinstall
2. rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
3. yum repolist enabled | grep "nginx*"
安装nginx
1. yum -y install nginx
启动nginx
1. service nginx start或者systemctl start nginx.service 开启nginx服务
设置nginx服务器开机自启动
1. systemctl enable nginx.service
检查开机自动是否设置成功
1. systemctl list-dependencies | grep nginx
浏览器中输入公网ip,检测是否安装成功(输入ip地址)
1.http://00.00.00.00/(阿里云公网IP地址复制粘贴回车看到Welcome Nginx即为成功)
使用yum安装mysql5.7 安装mysql源
1. yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2. yum repolist enabled | grep "mysql.*-community.*"
安装mysql
1. yum -y install mysql-community-server install mysql-community-devel
启动mysql
1. service mysqld start
检查mysql启动是否正常
1. service mysqld status 或者 ps -ef | grep mysql
设置mysqld服务开机自启动
1. systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功
1. systemctl list-dependencies | grep mysqld
mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码
查看mysql的随机密码
1.grep 'temporary password' /var/log/mysqld.log
使用查询得到的随机密码(输入上一条命令会出现一串字符串 例如:&s#r2q2XkiXfi,这串字符串就是随机的密码)
重新进入mysql
1. mysql -u root -p
更改密码复制下面一条命令(mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位 例如:Qwe@1234)
2.ALTER USER 'root'@'localhost' IDENTIFIED BY '你要修改的密码例如:Qwe@1234';
3. exit; #退出
退出mysql客户端,用刚才修改的密码登录确保密码修改成功
(重新进入mysql输入新密码确认然后复制下面的命令开启远程权限)
1.mysql -u root -p
2.输入新密码
3.mysql>
4.mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '自己8位新密码' WITH GRANT OPTION; ##开启mysql远程数据库访问权限
5.mysql>flush privileges; ##刷新权限
6.mysql>exit; ##退出
安装php7.1 安装php源
1. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
检查源是否安装成功
1.yum repolist enabled | grep "webtatic*"
安装php扩展源
1. yum -y install php71w php71w-fpm
2. yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
3. yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
4. yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
验证php7.1.x和扩展是否安装成功 验证php是否安装成功
1. php -v
验证对应的扩展是否安装成功
1. php -m #可以查看里面已近安装好的软件
设置php-fpm并检测php-fpm的运行状态 启动php-fpm
1. service php-fpm star
检查启动是否成功
1. service php-fpm status
设置开机自启动
1. systemctl enable php-fpm.service
检查开机自启动是否设置成功
1. systemctl list-dependencies | grep php-fpm
2. ps -ef | grep php-fpm
上面安装最基本的扩展包如果还想使用其他扩展包自己手动安装扩展命令
1. yum search php71w #查看所有包命令
输入安装命令:yum install php71w 空格自己想要安装的包 php71w-pdo #就能安装自己想要的包
完整命令:
2. yum install php71w php71w-pdo
nginx配置如下:vim /etc/nginx/conf.d/default.conf
server{
listen 80;
server_name youserver;
index index.html index.php;
root /home/public;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
root /home/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/public$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
不懂Nginx配置的可以百度自己搭配!
Nginx里面基本操作命令
① systemctl status firewalld.service ##查看防火墙状态
② systemctl stop firewalld.service ##停止防火墙
③ systemctl disable firewalld.service ##防火墙设置开机自启服务
④ systemctl start firewalld.service ##防火墙开启服务器
⑤ systemctl restart firewalld.service ##重启防火墙服务
以上例子换成其它命令操作可以启动不同服务如:
nginx
php-fpm
mysqld