设为首页 收藏本站
查看: 847|回复: 0

Centos下搭建php环境,安装lamp环境

[复制链接]

尚未签到

发表于 2015-8-19 08:21:15 | 显示全部楼层 |阅读模式
  首先使用yum命令安装或者升级所需的程序库
  copy以下命令到命令行回车即可。
  yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-server krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
  一、安装apache
  [iyunv@AY12122501352213a7156 ~]# yum install httpd httpd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* centosplus: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
  ........................
  中途提示是否下载,输入y,回车,没有什么意外的话等待安装完成。
  安装完成后,用/etc/init.d/httpd start  启动apache
您也可以设为开机启动:chkconfig httpd on 。
  二、安装mysql
  1、安装
  [iyunv@AY12122501352213a7156 ~]# yum install mysql mysql-server mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* centosplus: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
  .................
  中途可能会出现问题如下:
  --> Finished Dependency Resolution
mysql-devel-5.0.95-1.el5_7.1.i386 from updates has depsolving problems
  --> Missing Dependency: mysql = 5.0.95-1.el5_7.1 is needed by package mysql-devel-5.0.95-1.el5_7.1.i386 (updates)
Error: Missing Dependency: mysql = 5.0.95-1.el5_7.1 is needed by package mysql-devel-5.0.95-1.el5_7.1.i386 (updates)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
  说有个包mysql = 5.0.95-1.el5_7.1依赖mysql-devel-5.0.95-1.el5_7.1.i386,需要更新,我们这里不需要,直接重新安装,跳过这个问题即可。
  [iyunv@AY12122501352213a7156 ~]# yum install mysql mysql-server mysql-devel --skip-broken
  中途提示是否下载,输入y,回车,没有什么意外的话等待安装完成。
  完成后,用/etc/init.d/mysqld start 启动mysql  ,或者使用 service mysqld start  启动mysql 。
  当然你也可以设置开机启动,命令为:chkconfig mysqld on
  2、设置初始密码,没有密码,直接输入mysql命令即可
  [iyunv@AY12122501352213a7156 ~]# mysql
  Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.58 MySQL Community Server (GPL) by Utter Ramblings
  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql>USE mysql; #使用mysql数据库
mysql>UPDATE user SET Password=PASSWORD('新密码') WHERE user='root';   #更改数据库密码
mysql>FLUSH PRIVILEGES; #刷新刚才的操作,否则刚才的操作无效。
  3、允许mysql远程登录
  [iyunv@AY12122501352213a7156 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; #给‘用户名’授予所有权限,并且设置密码为‘密码’
完成后就能用SQL-Front软件远程管理mysql了。
  注意:为了防止sql出错,命令行失效,你可以在输入sql的结尾最好加上“;”,
  三、安装php
  1、安装
  [iyunv@AY12122501352213a7156 ~]# yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
  这样也可能会报mysql类似错误,那就跳过吧
  [iyunv@AY12122501352213a7156 ~]# yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml  --skip-broken
  完成后重新启动apache:/etc/init.d/httpd start。
  2、测试
  在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。
<?
phpinfo();
?>
  输入地址试试:http://serverip/test.php,good,可以显示说明可以成功。
  但是有些时候80端口被占用,或者防火墙原因,无法访问,你可以继续往下看。
  3.防火墙配置 或者关闭80端口
  3.1、80端口被占用
  查看一下80端口:关于端口问题可以参考我前面的文章:http://www.iyunv.com/wanghaosoft/archive/2013/01/11/find80.html
  [iyunv@AY12122501352213a7156 lsof_4.76_src]# netstat -apn |grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      25794/httpd        
unix  2      [ ]         DGRAM                    3580   1303/klogd
  如果80端口被占,则结束所占80端口进程,然后重新启动apache服务。如上,我的80端口是apache 的服务占用,25794/httpd ,前面是进程号,后面进程名称。
  [iyunv@AY12122501352213a7156 lsof_4.76_src]# kill -9 25794
  3.2、防火墙不允许
通过/etc/init.d/iptables status 查看防火墙状态。如果没有可通过两种方式处理:
a、修改vi /etc/sysconfig/iptables命令添加使防火墙开放80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
b、关闭防火墙
#/etc/init.d/iptables stop
#/etc/init.d/iptables start 开启
#/etc/init.d/iptables restart 重启
永久性关闭防火墙chkconfig --level 35 iptables off
  至此,lamp环境搭建完成。
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-100883-1-1.html 上篇帖子: ubuntu10.04 安装lamp 下篇帖子: LAMP架构搭建+Discuz论坛搭建【weber出品必属精品】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表