CentOS 7 一步一步搭建LAMP
发表于:2024-10-24 作者:千家信息网编辑
千家信息网最后更新 2024年10月24日,一、准备环境1、系统版本[root@Webserver01 ~]# cat /proc/versionLinux version 3.10.0-514.16.1.el7.x86_642、关防火墙[ro
千家信息网最后更新 2024年10月24日CentOS 7 一步一步搭建LAMP
一、准备环境
1、系统版本
[root@Webserver01 ~]# cat /proc/version
Linux version 3.10.0-514.16.1.el7.x86_64
2、关防火墙
[root@Webserver01 ~]# systemctl disable firewalld
3、准备yum源
[root@Webserver01 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
或
[root@Webserver01 ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
4、安装基础工具
[root@Webserver01 ~]# yum install -y net-tools vim lrzsz tree screen lsof tcpdump nc nmap
5、关掉SELINUX
[root@Webserver01 ~]# vim /etc/sysconfig/selinux SELINUX=disabled
6、更新并重启
[root@Webserver01 ~]# yum update -y && reboot
二、开始安装LAMP组建
LAMP至少需要以下组建:
httpd (提供 Apache 主程序)
mysql (MySQL 客戶端程序)
mysql-server (MySQL 服务器程序)
php (PHP 主程序含给 apache 使用的模块)
php-devel (PHP 的开发工具,这个与PHP 外挂的加速软件有关)
php-mysql (提供给PHP 程序读取 MySQL 资料库的模块)
可以用以下命令一次安装;
[root@Webserver01 ~]# yum install httpd mysql mysql-server php php-mysql
为了看的更详细,我们一个一个安装
1、利用yum命令安装Apache
[root@Webserver01 ~]# yum -y install httpd
启动httpd并且设置为开机启动
[root@Webserver01 ~]# systemctl start httpd.service[root@Webserver01 ~]# systemctl enable httpd.service
输入网址,查看测试页
2、安装Mariadb
利用yum命令进行安装,并且配置开机启动同样还是利用yum命令进行安装,并且配置开机启动
[root@Webserver01 ~]# yum -y install mariadb-server mariadb[root@Webserver01 ~]# systemctl start mariadb.service[root@Webserver01 ~]# systemctl enable mariadb.service
配置root密码
[root@Webserver01 ~]# mysql_secure_installation安装过程中会有几个选项,大家根据自己的需要进行配置就好了Enter current password for root (enter for none):(输入原始root密码,若无enter)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] (是否设置root密码)New password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success!Remove anonymous users? [Y/n] (是否移除匿名用户) ... Success!Disallow root login remotely? [Y/n] (是否禁止远程root登陆) ... skipping.Remove test database and access to it? [Y/n] (是否删除测试数据库)Reload privilege tables now? [Y/n] (重新载入) ... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
登录数据库测试一下
[root@Webserver01 ~]# mysql -u root -pEnter password: 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)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+3 rows in set (0.00 sec)MariaDB [(none)]> exitBye
3、安装PHP
[root@Webserver01 ~]# yum -y install php
安装所需组件
[root@Webserver01 ~]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
启动服务并设置开机自动启动
[root@Webserver01 ~]# systemctl start httpd.service[root@Webserver01 ~]# systemctl enable httpd.service
查看80端口和3306端口是否处于监听状态:
[root@Webserver01 ~]# netstat -ntlp
测试php是否正常工作
编辑/etc/httpd/conf/httpd.conf文件,在DirectoryIndex后面填写index.php,定义默认主页为index.php
[root@Webserver01 ~]# vim /etc/httpd/conf/httpd.conf
重载httpd配置文件
[root@Webserver01 ~]# systemctl reload httpd.service
[root@Webserver01 ~]# vim /var/www/html/index.php
制作默认主页/var/www/html/index.php,编写如下内容
This is new Web !
重启httpd服务
[root@Webserver01 ~]# systemctl restart httpd.service
好了,该验证最后是否成功了
打开网址 http://x.x.x.x/info.php 进行查看
看到这个页面,我们就可以收工了,LAMP环境搭建结束!
配置
命令
测试
密码
程序
服务
主程序
主页
工具
数据
数据库
文件
模块
环境
端口
网址
准备
输入
原始
成功
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全你我他 朗诵
网络安全的公司还值得做吗
怎么下载王牌战争服务器
服务器装哪个浏览器
Nat映射服务器
服务器异常请检查驱动器
数据库的字段名学生性别
什么是数据库分类管理平台
vps服务器恒创
北海招软件开发工程师
军区面试数据库
数据库有图标
网贷公司对接那个大数据库
网络安全狭义包括
提升网络安全的软件
备份数据库的日志尾部.
邢台市软件开发培训
苹果的数据库是甲骨文提供的
移动app网络安全
上海威派格软件开发面试
java操作数据库的包
软件开发外包平台哪些比较好
赢贝互联网科技
益盟操盘手 服务器
上汽网络安全
有关加强网络安全工作的报道
CF目前有几个服务器
缺少网络技术专业人员
怎么做数据库压力测试
数据库后台管理系统搭建