CentOS使用yum源中自带的rpm包安装LAMP环境
CentOS使用yum源中自带的rpm包安装LAMP环境。这是Linux下安装LAMP的环境一种最基本最简便的方式。新手可以从容安装使用。
1. 安装基础包(可选安装)
yum install -y wget zip unzip gzip
yum install -y python ruby perl
yum install -y gc gcc gcc-c++
2. 安装php及其相关组件
yum install -y php php-gd
yum install -y php-mbstring php-mcrypt php-mysql php-pdo
3. 启动httpd服务器
service httpd start
chkconfig httpd on 设置开机自动启动
服务器www目录地址/var/www/html/
4. 安装mysql
yum install -y mysql mysql-server
[root@localhost html]# service mysqld start
5. 配置mysql
根据提示运行
/usr/bin/mysql_secure_installation
按照提示对mysql进行配置,包括root密码设置等等。
chkconfig mysqld on 设置开机自动启动
6. 安装phpmyadmin
下载phpmyadmin相应版本 https://www.phpmyadmin.net/files/
将zip包copy到/var/www/html/目录,并解压缩重命名为phpmyadmin
例如:
wget https://files.phpmyadmin.net/phpMyAdmin/3.5.8.2/phpMyAdmin-3.5.8.2-all-languages.zip
unzip phpMyAdmin-3.5.8.2-all-languages.zip -d /var/www/html/
mv /var/www/html/phpMyAdmin-3.5.8.2-all-languages /var/www/html/phpmyadmin
访问 http://youripaddress/phpmyadmin/ 就可以根据 5. 配置mysql 中设置的root密码登录
7. 防火墙问题
购买的服务器一般镜像安装后都会默认开启22,80等常用端口。
自己安装centos到特定机器或vmware虚拟机安装的时候可能出现iptables没有配置导致80端口无法访问的问题。
临时禁用iptables的方法(重启机器后失效),使用命令 service iptables stop
千万不要在生产环境中这么做!
---------------------------------------------------
初次运行 service mysqld start 会有下面的提示,此处做好记录以备以后查看,
对数据库问题修复有至关重要的作用!!
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具