安装Apache&Nginx
升级一下yum源(非必须)
Apache安装与配置
Apache下载安装
1 | yum list |grep httpd //查看有哪些Apache可以安装 |
2 | yum install -y httpd //安装Apache指令 |
3 | http -v //安装完成后查看Apache版本指令 |
4 | 显示内容如下 |
5 | Server version: Apache/2.4.6 (CentOS) |
6 | Server built: Apr 12 2017 21:03:28 |
关闭防火墙
1 | [root@localhost /] |
2 | [root@localhost /] |
3 | [root@localhost /] |
如果不想关闭防火墙,那我们可以在防火墙上允许访问80端口(这是Apache默认的端口)
防火墙上开启80端口
1 | [root@localhost /] |
2 | success |
3 | [root@localhost /] |
4 | success |
5 | [root@localhost /] |
6 | ● firewalld.service - firewalld - dynamic firewall daemon |
7 | Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) |
8 | Active: active (running) since Sun 2017-06-11 13:08:10 CST; 8s ago //防火墙的状体是开启的 |
Ngixn安装与配置
Ngixn安装
1 | [root@localhost /] |
2 | [root@localhost /] |
3 | Loaded plugins: fastestmirror |
4 | Loading mirror speeds from cached hostfile |
5 | * base: mirrors.tuna.tsinghua.edu.cn |
6 | * extras: mirrors.tuna.tsinghua.edu.cn |
7 | * updates: mirrors.tuna.tsinghua.edu.cn |
8 | No package nginx available. //还是没有nginx的安装包 |
9 | //将nginx放到yum repro库中 |
10 | [root@localhost /] |
11 | [root@localhost /] |
12 | ======================================================== N/S matched: nginx ========================================================= |
13 | nginx-debug.x86_64 : debug version of nginx |
14 | nginx-debuginfo.x86_64 : Debug information for package nginx |
15 | nginx-module-geoip.x86_64 : nginx GeoIP dynamic modules |
16 | nginx-module-geoip-debuginfo.x86_64 : Debug information for package nginx-module-geoip |
17 | nginx-module-image-filter.x86_64 : nginx image filter dynamic module |
18 | nginx-module-image-filter-debuginfo.x86_64 : Debug information for package nginx-module-image-filter |
19 | nginx-module-njs.x86_64 : nginx nginScript dynamic modules |
20 | nginx-module-njs-debuginfo.x86_64 : Debug information for package nginx-module-njs |
21 | nginx-module-perl.x86_64 : nginx Perl dynamic module |
22 | nginx-module-perl-debuginfo.x86_64 : Debug information for package nginx-module-perl |
23 | nginx-module-xslt.x86_64 : nginx xslt dynamic module |
24 | nginx-module-xslt-debuginfo.x86_64 : Debug information for package nginx-module-xslt |
25 | nginx-nr-agent.noarch : New Relic agent for NGINX and NGINX Plus |
26 | nginx-release-centos.noarch : nginx repo configuration and pgp public keys |
27 | pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx Webserver |
28 | nginx.x86_64 : High performance web server //是存在nginx安装包的 |
29 | [root@localhost /] |
30 | [root@localhost /] |
31 | nginx version: nginx/1.12.0 |
32 | [root@localhost /] |
我希望通过80端口访问的是Apach服务器,通过8080端口访问的是nginx服务器,这么做?
1 | [root@localhost /] |
2 | success |
3 | [root@localhost /] |
4 | success |
5 | [root@localhost /] |
6 | 80/tcp 8080/tcp //80,8080已经打开 |
7 | [root@localhost /] |
8 | [root@localhost conf.d] |
9 | [root@localhost conf.d] |
MySql安装与配置
Mysql安装
CetOS7已使用了MariaDB替代了默认的MySQL ,所以我们想使用MySQL还得多做点事情
1 | [root@localhost /] |
2 | [root@localhost /] |
3 | [root@localhost /] |
4 | [root@localhost /] |
5 | [root@localhost /] |
6 | [root@localhost /] |
7 | 2017-06-11T06:18:16.057811Z 1 [Note] A temporary password is generated for root@localhost: uvrpXRuul6/h |
8 | [root@localhost /] |
9 | mysql> set password for 'root'@'localhost'=password('Aa@123456'); //重新为数据库设置密码 |
10 | Query OK, 0 rows affected, 1 warning (0.01 sec) |
11 | //将MySQL设置为开机启动项 |
12 | [root@localhost /] |
13 | [root@localhost /] |
14 | //设置数据的默认字符集(非必须的) |
15 | [root@localhost ~] |
16 | //将下面两行配置代码加入到my.cnf最后面 |
17 | character_set_server=utf8 |
18 | init_connect='SET NAMES utf8' |
19 | [root@localhost ~] |
20 | //进入MySQL数据库 |
21 | mysql> select version(); |
22 | +-----------+ |
23 | | version() | |
24 | +-----------+ |
25 | | 5.7.18 | |
26 | +-----------+ |
27 | 1 row in set (0.00 sec) |
28 | mysql> show variables like '%character%'; |
29 | +--------------------------+----------------------------+ |
30 | | Variable_name | Value | |
31 | +--------------------------+----------------------------+ |
32 | | character_set_client | utf8 | |
33 | | character_set_connection | utf8 | |
34 | | character_set_database | utf8 | |
35 | | character_set_filesystem | binary | |
36 | | character_set_results | utf8 | |
37 | | character_set_server | utf8 | |
38 | | character_set_system | utf8 | |
39 | | character_sets_dir | /usr/share/mysql/charsets/ | |
40 | +--------------------------+----------------------------+ |
41 | 8 rows in set (0.01 sec) |
Mysql修改默认密码
如果想使用简单密码则需要修改mysql密码验证机制
1 | [root@localhost /] |
2 | [root@localhost /] |
3 | mysql> set global validate_password_policy=0; //只验证长度 |
4 |
|
5 | mysql> set global validate_password_length=6; //修改密码长度,默认值是8个字符 |
6 |
|
7 | mysql> alter user user()identified by"123456"; //修改登陆密码为123456 |
安装PHP7
1 | //安装依赖文件 |
2 | [root@localhost ~] |
3 | //安装php组新版本rpm |
4 | [root@localhost ~] |
5 | Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm |
6 | warning: /var/tmp/rpm-tmp.F1aZTS: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY |
7 | Preparing... |
8 | Updating / installing... |
9 | 1:epel-release-7-5 |
10 | [root@localhost ~] |
11 | Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm |
12 | warning: /var/tmp/rpm-tmp.rnxYY3: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY |
13 | Preparing... |
14 | Updating / installing... |
15 | 1:webtatic-release-7-3 |
16 | [root@localhost ~] |
17 | [root@localhost ~] |
18 | [root@localhost ~] |
19 | PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS ) |
20 | Copyright (c) 1997-2017 The PHP Group |
21 | Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies |
22 | [root@localhost ~] |