Centos7-1611 安装LAMP

4 篇文章 0 订阅

1.确定自己的IP地址(测试机为192.168.172.134)

[root@php ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:40:f8:4c brd ff:ff:ff:ff:ff:ff
192.168.172.134/24 d 192.1**brd 192.168.172.255 scope global dynamic ens33

2.确认可用的yum源

[root@php ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
repo id                                         repo name                                          status
base/7/x86_64                                CentOS-7 - Base                                    9,363
extras/7/x86_64                              CentOS-7 - Extras                                    450
updates/7/x86_64                            CentOS-7 - Updates                                 2,146
repolist: 11,959

3.装包:

     Apache的:
   `yum -y install httpd `                                    
   PHP的:      
   `yum -y install php php-mysql`                             
   Mysql(Mariadb取代了):                      
    `yum -y install mariadb mariadb-server`           
   PHP的扩展包:           
     `yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath`             

4.配置

     Apache和PHP无需任何配置
      Mariadb(选自Linux就该这么学)

http://www.linuxprobe.com/chapter-18.html

[root@linuxprobe ~]# mysql_secure_installation 

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none): 当前数据库密码为空,直接敲击回车。

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y

New password: 输入要为root用户设置的数据库密码。

Re-enter new password: 重复再输入一次密码。

Password updated successfully!

Reloading privilege tables..

 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y(删除匿名帐号)

 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y(禁止root用户从远程登录)

 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y(删除test数据库并取消对其的访问权限)

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y(刷新授权表,让初始化后的设定立即生效)

 ... Success!

Cleaning up...

All done!  If you've completedallation should now be secure.

Thanks for using MariaDB!

5.启动服务:

5.1 配置防火墙
[root@php ~]# firewall-cmd --permanent --add-service=http --add-service=mysql
[root@php ~]# firewall-cmd --reload
5.2 启动服务:
systemctl start httpd;systemctl enable httpd
systemctl start mariadb;systemctl enable mariadb

6.测试:

1.查看端口:
[root@php ~]# netstat -ntulp | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      38791/mysqld
[root@php ~]# netstat -ntulp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      39364/httpd   
2. 测试Apache
[root@php ~]# firefox localhost

出来TSET123…. 等等就正常了

3.测试php
[root@php ~]# vim /var/www/html/info.php
写:
<?php
    phpinfo();
?>
然后wq
[root@php ~]# firefox localhost/info.php
显示出PHP信息就正常了
4.测试mariadb
[root@php ~]# mysql -uroot -p
Enter password: 

输入mariadb管理员账户的密码

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

数据库正常









LAMP安装完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值