linux yum lamp环境,centos7用yum搭建LAMP环境

用yum快速搭建LAMP平台

实验环境:

136735841_1_20180625043600363.gif

[root@nmserver-7 html]# cat /etc/redhat-release CentOS release7.3.1611(AltArch) [root@nmserver-7 html]# uname -aLinux nmserver-7.test.com 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux

136735841_1_20180625043600363.gif

1、安装apache

1.1 安装apache

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# yum install httpd httpd-devel

136735841_1_20180625043600363.gif

1.2 启动apache服务

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# systemctl start httpd

136735841_1_20180625043600363.gif

1.3 设置httpd服务开机启动

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# systemctl enable httpd

Created symlink from/etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

136735841_1_20180625043600363.gif

1.4 查看服务状态

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# systemctl status httpd

httpd.service-The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 五2017-07-21 17:21:37CST; 6min ago Docs:man:httpd(8)man:apachectl(8) Main PID:2449(httpd) Status:'Total requests: 11; Current requests/sec: 0; Current traffic: 0 B/sec'CGroup:/system.slice/httpd.service ├─2449 /usr/sbin/httpd -DFOREGROUND ├─2450 /usr/sbin/httpd -DFOREGROUND ├─2451 /usr/sbin/httpd -DFOREGROUND ├─2452 /usr/sbin/httpd -DFOREGROUND ├─2453 /usr/sbin/httpd -DFOREGROUND ├─2454 /usr/sbin/httpd -DFOREGROUND ├─2493 /usr/sbin/httpd -DFOREGROUND ├─2494 /usr/sbin/httpd -DFOREGROUND └─2495 /usr/sbin/httpd -DFOREGROUND7月21 17:21:35 nmserver-7.test.com systemd[1]: Starting The Apache HTTP Server...7月21 17:21:36 nmserver-7.test.com httpd[2449]: AH00558: httpd: Could not reliably determine the server's fully q...ssage7月 21 17:21:37 nmserver-7.test.com systemd[1]: Started The Apache HTTP Server.Hint: Some lines were ellipsized, use-l to show in full.

136735841_1_20180625043600363.gif

1.5 防火墙设置开启80端口

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=httpsuccess

[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=httpssuccess

[root@nmserver-7 ~]# firewall-cmd --reloadsuccess

136735841_1_20180625043600363.gif

1.6确认80端口监听中

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# netstat -tulp

Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd tcp0 0 localhost:smtp 0.0.0.0:* LISTEN 1486/master tcp60 0 [::]:ssh [::]:* LISTEN 1084/sshd tcp60 0 localhost:smtp [::]:* LISTEN 1486/master tcp60 0 [::]:http [::]:* LISTEN 2449/httpd udp0 0 localhost:323 0.0.0.0:* 592/chronyd udp60 0 localhost:323 [::]:* 592/chronyd

136735841_1_20180625043600363.gif

1.8 查服务器IP

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# ip addr

1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet127.0.0.1/8scope host lo valid_lft forever preferred_lft forever inet6 ::1/128scope host valid_lft forever preferred_lft forever2: ens33: mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:0c:29:56:bc:cf brd ff:ff:ff:ff:ff:ff inet192.168.8.9/24 brd 192.168.8.255scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe56:bccf/64scope link valid_lft forever preferred_lft forever3: bridge0: mtu 1500 qdisc noqueue state DOWN qlen 1000link/ether ea:89:d5:c7:32:73 brd ff:ff:ff:ff:ff:ff

136735841_1_20180625043600363.gif

1.9 浏览器登陆

136735841_2_20180625043600551.jpg

2、安装mysql

2.1安装mysql

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel

136735841_1_20180625043600363.gif

136735841_1_20180625043600363.gif

root@nmserver-7 ~]# rpm -qa |grepmariamariadb-libs-5.5.52-1.el7.i686mariadb-5.5.52-1.el7.i686mariadb-server-5.5.52-1.el7.i686mariadb-devel-5.5.52-1.el7.i686

136735841_1_20180625043600363.gif

2.2 开启mysql服务,并设置开机启动,检查mysql状态

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# systemctl start mariadb

[root@nmserver-7 ~]# systemctl enable mariadb

Created symlink from/etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.[root@nmserver-7 ~]# systemctl status mariadb ● mariadb.service-MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since 六2017-07-22 21:19:20CST; 21s ago Main PID:9603(mysqld_safe) CGroup:/system.slice/mariadb.service ├─9603 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─9760 /usr/libexec/mysqld --basedir=/usr --datadir=/v...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...7月22 21:19:16 nmserver-7.test.com mysqld_safe[9603]: 170722 21...7月22 21:19:16 nmserver-7.test.com mysqld_safe[9603]: 170722 21...7月22 21:19:20 nmserver-7.test.com systemd[1]: Started MariaDB ...

136735841_1_20180625043600363.gif

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# netstat -tulp

Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd tcp0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld tcp60 0 [::]:ssh [::]:* LISTEN 1084/sshd tcp60 0 [::]:http [::]:* LISTEN 2449/httpd udp0 0 localhost:323 0.0.0.0:* 592/chronyd udp60 0 localhost:323 [::]:* 592/chronyd

136735841_1_20180625043600363.gif

2.3 数据库安全设置

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# mysql_secure_installation

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 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 passwordfor root (enter fornone): 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: 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 createdforthem. This is intended onlyfor testing, and to makethe 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 rootlogin remotely? [Y/n] n ... skipping.By default, MariaDB comes with a database named'test'that anyone canaccess. This is also intended onlyfortesting, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y-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...Alldone! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanksfor using MariaDB!

136735841_1_20180625043600363.gif

2.4 登陆数据库测试

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# mysql -uroot -p

Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connectionid is 11Server 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 clearthe current input statement.MariaDB [(none)]>show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+3 rows in set (0.02sec)MariaDB [(none)]>

136735841_1_20180625043600363.gif

3、安装PHP

3.1 安装php

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# yum -y install php

136735841_1_20180625043600363.gif

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# rpm -ql php/etc/httpd/conf.d/php.conf/etc/httpd/conf.modules.d/10-php.conf/usr/lib/httpd/modules/libphp5.so/usr/share/httpd/icons/php.gif/var/lib/php/session

136735841_1_20180625043600363.gif

3.2 将php与mysql关联起来

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# yum install php-mysql

[root@nmserver-7 ~]# rpm -ql php-mysql/etc/php.d/mysql.ini/etc/php.d/mysqli.ini/etc/php.d/pdo_mysql.ini/usr/lib/php/modules/mysql.so/usr/lib/php/modules/mysqli.so/usr/lib/php/modules/pdo_mysql.so

136735841_1_20180625043600363.gif

3.3 安装常用PHP模块

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# 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

136735841_1_20180625043600363.gif

3.4 测试PHP

136735841_1_20180625043600363.gif

[root@nmserver-7 ~]# cd  /var/www/html/

[root@nmserver-7 html]# ls

[root@nmserver-7 html]# pwd

/var/www/html

[root@nmserver-7 html]# vi info.php

phpinfo();

?>

~

~

~

~

~

~

~

~        :wq

136735841_1_20180625043600363.gif

3.5重启apache服务器

136735841_1_20180625043600363.gif

[root@nmserver-7 html]# systemctl restart http

136735841_1_20180625043600363.gif

3.6测试PHP

在自己电脑浏览器输入 192.168.8.9/info.php,你可以看到已经安装的模块;

136735841_3_2018062504360198.jpg

至此,CentOS7下LAMP环境搭建好了!下一步可以安装zabbix了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值