Centos7-1611 安装LAMP

来源:互联网 发布:mysql数据定义语言 编辑:程序博客网 时间:2024/05/18 20:10

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

[root@php ~]# ip a1: 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 forever2: 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:ff192.168.172.134/24 d 192.1**brd 192.168.172.255 scope global dynamic ens33

2.确认可用的yum源

[root@php ~]# yum repolistLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirror.bit.edu.cn * extras: mirror.bit.edu.cn * updates: mirrors.tuna.tsinghua.edu.cnrepo id                                         repo name                                          statusbase/7/x86_64                                CentOS-7 - Base                                    9,363extras/7/x86_64                              CentOS-7 - Extras                                    450updates/7/x86_64                            CentOS-7 - Updates                                 2,146repolist: 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 foundNOTE: 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 currentpassword for the root user.  If you've just installed MariaDB, andyou 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password: 输入要为root用户设置的数据库密码。Re-enter new password: 重复再输入一次密码。Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y(删除匿名帐号) ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures 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 canaccess.  This is also intended only for testing, and should be removedbefore 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 farwill 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 httpdsystemctl start mariadb;systemctl enable mariadb

6.测试:

1.查看端口:

[root@php ~]# netstat -ntulp | grep 3306tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      38791/mysqld[root@php ~]# netstat -ntulp | grep 80tcp6       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 -pEnter password: 

输入mariadb管理员账户的密码

Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 13Server version: 5.5.52-MariaDB MariaDB ServerCopyright (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安装完毕

原创粉丝点击