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

centos6.5安装lnmp环境

[复制链接]

尚未签到

发表于 2015-8-21 12:18:38 | 显示全部楼层 |阅读模式
  1.安装nignx的源,默认cenots6没有的。



rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  如果全部软件想要最新的那么就改yum的源吧

centos6.5适用的国内yum源:网易、搜狐


赵荣涛 2014-08-03 1510 阅读

linux  本人安装的操作系统是centos 6.5,默认的yum源是centos官网的,速度慢是不用说了。所以使用yum安装东西之前需要把yum源改为国内的。现贴上国内网易和搜狐的yum源。
  参考 http://mirrors.163.com/.help/centos.html 和 http://mirrors.sohu.com/help/centos.html 中的介绍。
  设置方法如下:
  1,进入yum源配置目录
cd /etc/yum.repos.d
  2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bak
  下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
  更改文件名
  mv CentOS6-Base-163.repo CentOS-Base.repo
  3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
  yum clean all
yum makecache
  4,除了网易之外,国内还有其他不错的yum源,比如搜狐的
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  但是搜狐的好像截止到笔者发布此文章时,还没有centos6的yum源。
  中科大的
  wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
  1、安装nginx
  [iyunv@localhost ~]# yum -y install nginx        安装nginx软件
[iyunv@localhost ~]# service nginx start         启动
[iyunv@localhost ~]# chkconfig nginx on         设置开机启动
[iyunv@localhost ~]# /etc/init.d/nginx restart         重启nginx服务
[iyunv@localhost ~]# rm -rf /usr/share/nginx/html/*        删除nginx默认页面
  2、安装mysql
  [iyunv@localhost ~]# yum install mysql mysql-server -y        安装mysql
[iyunv@localhost ~]# /etc/init.d/mysqld start        启动mysql
[iyunv@localhost ~]# chkconfig mysqld on        设置开机启动
[iyunv@localhost ~]# cp /usr/share/mysql/my-medium.cnf  /etc/my.cnf        拷贝配置文件,直接覆盖原有的
[iyunv@localhost ~]# reboot        重启系统
[iyunv@localhost ~]# mysql_secure_installation        为root设置密码
[iyunv@localhost ~]# /etc/init.d/mysqld stop         启动mysql
[iyunv@localhost ~]# /etc/init.d/mysqld start         停止mysql
[iyunv@localhost ~]# service mysqld restart        重启mysql
  3、安装php
  [iyunv@localhost ~]# yum install php -y
[iyunv@localhost ~]# yum -y install php-mysql phpgd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm
[iyunv@localhost ~]# /etc/init.d/mysqld restart        重启mysql服务
[iyunv@localhost ~]# /etc/init.d/nginx restart         重启nginx服务
[iyunv@localhost ~]# /etc/rc.d/init.d/php-fpm start     启动php-fpm服务
[iyunv@localhost ~]# chkconfig php-fpm on        设置开机启动
  配制
  1、配置nginx支持PHP
  [iyunv@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[iyunv@localhost ~]# vim /etc/nginx/nginx.conf
     user     nginx   nginx;   #修改 nginx 运行账号为:nginx 组的 nginx 用 户!
[iyunv@localhost ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
[iyunv@localhost ~]# vim /etc/nginx/conf.d/default.conf
        index  index.php index.html index.htm;
        location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PHP_VALUE "open_basedir=$document_root:/tmp/";                 添加的这行  防止跨站   
        include        fastcgi_params;
    }
#取消 FastCGI server 部分location 的注释,并要注意 fastcgi_param 行的参数, 改为$document_root$fastcgi_script_name,或者使用绝对路径
  2、php配置
  [iyunv@localhost ~]# vim /etc/php.ini
        date.timezone = PRC
        expose_php = Off
        #;open_basedir = .:/tmp/        注释掉这行
  3、配置php-fpm
  [iyunv@localhost ~]# vim /etc/php-fpm.d/www.conf        编辑
        user = nginx        编辑用户为nginx
        group = nginx        修改组为nginx
[iyunv@localhost ~]# /etc/init.d/mysqld restart    重启mysql
[iyunv@localhost ~]# /etc/init.d/nginx restart        启动nginx
[iyunv@localhost ~]# /etc/rc.d/init.d/php-fpm restart        重启Php-fpm
  测试篇
  [iyunv@localhost ~]# cd /usr/share/nginx/html/        进入nginx默认网站根目录
[iyunv@localhost html]# cat index.php         新建index.php文件
        <?
            phpinfo()
        ?>
[iyunv@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R         设置是目录所有者
[iyunv@localhost html]# chmod 700 /usr/share/nginx/html/ -R        设置目录权限
  备注
  [iyunv@localhost ~]# cd /usr/share/nginx/html/        nginx默认的程序目录
[iyunv@localhost ~]# chown nginx.nginx /usr/share/nginx/html/ -R        权限设置
[iyunv@localhost ~]# cd /var/lib/mysql/        数据库目录是
[iyunv@localhost ~]# chown mysql.mysql -R /var/lib/mysql/        权限设置
[iyunv@localhost html]# tail -n20 /var/log/nginx/error.log        查看nginx的日志
  软件版本
  [iyunv@localhost html]# nginx -v
nginx version: nginx/1.6.2
[iyunv@localhost html]# php -v
PHP 5.4.36 (cli) (built: Dec 22 2014 16:06:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[iyunv@localhost html]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.41-cll-lve MySQL Community Server (GPL) by Atomicorp

运维网声明 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-102174-1-1.html 上篇帖子: PHP5.3下加速器ZendGuardLoader安装 (LNMP/lnmpa) 下篇帖子: Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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