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

linux yum 安装 lnmp(linux+php+mysql)

[复制链接]

尚未签到

发表于 2015-8-21 10:45:32 | 显示全部楼层 |阅读模式
yum搭建lnmp环境(CentOS6)
  1.关闭防火墙
[iyunv@CentOS ~]# chkconfig iptables off
  2.关闭selinux
vi /etc/sysconfig/selinux
//将SELINUX=enforcing修改为disabled然后重启生效
  3、配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)
[iyunv@CentOS ~]# yum install wget
//下载wget工具
[iyunv@CentOS ~]# wget http://www.atomicorp.com/installers/atomic
//下载atomic yum源
[iyunv@CentOS ~]# sh ./atomic
//安装提示输入时输yes
[iyunv@CentOS ~]# yum check-update
//更新yum软件包
  4.安装开发包和库文件
[iyunv@CentOS ~]# yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
  5.卸载已安装的apache、mysql、php
[iyunv@CentOS ~]# yum remove httpd
[iyunv@CentOS ~]# yum remove mysql
[iyunv@CentOS ~]# yum remove php
  6.安装nginx
[iyunv@CentOS ~]# yum install nginx
[iyunv@CentOS ~]# service nginx start
[iyunv@CentOS ~]# chkconfig --levels 235 nginx on
//设2、3、5级别开机启动
  7.安装mysql
[iyunv@CentOS ~]# yum install mysql mysql-server mysql-devel
[iyunv@CentOS ~]# service mysqld start
[iyunv@CentOS ~]# chkconfig --levels 235 mysqld on
[iyunv@CentOS ~]# mysqladmin -u root password "123456"
//为root用户设置密码
[iyunv@CentOS ~]# service mysqld restart
//重启mysql
  8.安装php
[iyunv@CentOS ~]# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap
php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap
php-tidy php-common php-devel php-fpm
//安装php和所需组件使PHP支持MySQL、FastCGI模式
[iyunv@CentOS ~]# service php-fpm start
[iyunv@CentOS ~]# chkconfig --levels 235 php-fpm on
  9.配置nginx支持php
[iyunv@CentOS ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
//将配置文件改为备份文件
[iyunv@CentOS ~]# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件
//修改nginx配置文件,添加fastcgi支持
[iyunv@CentOS ~]# vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
//将以上代码注释去掉,并修改成nginx默认路径
  10.配置php
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
[iyunv@CentOS ~]# vi /etc/php.ini
  11.重启nginx php-fpm
[iyunv@CentOS ~]# service nginx restart
[iyunv@CentOS ~]# service php-fpm restart
  12.建立info.php文件
[iyunv@CentOS ~]# vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
  13.由于我的网段是  172的所有 浏览器中 敲入  172.16.10.12 查看php 是否配置成功
  ###########################
  14.个人总结
  nginx 的配置文件目录  /etc/nginx/nginx.conf
  /etc/nginx/conf.d/default.conf
  php.ini 目录
  
  [iyunv@root nginx]# whereis php.ini
php: /usr/bin/php /etc/php.ini /etc/php.d /usr/lib64/php /usr/include/php /usr/share/php /usr/share/man/man1/php.1.gz
  验证mysql  
  [iyunv@root nginx]# mysql -uroot -p
Enter password:          [回车]
  mysql> show databases;   走到这里说明 mysql 已经安装成功
  #################
  
  nginx.conf 中的配置
  http {
  include mime.types;
  default_type application/octet-stream;
  log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for"';
  access_log /var/www/log/nginx/access.log main;
  sendfile on;
  #tcp_nopush on;
  #keepalive_timeout 0;
  keepalive_timeout 65;
  #gzip on;
  # Load config files from the /etc/nginx/conf.d directory
  include /etc/nginx/conf.d/*.conf;
  server {
    listen 80;
    server_name localhost;
  #charset koi8-r;
  #access_log logs/host.access.log main;
  location / {
      root /var/www/;
      index index.php index.html index.htm;
    }
  error_page 404 /404.html;
    location = /404.html {
      root /usr/share/nginx/html;
    }
  # redirect server error pages to the static page /50x.html
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
      root /usr/share/nginx/html;
    }
  }
}
  
  在 conf.d 目录下 新建 default.conf配置文件
  vim default.conf
  server {
listen 80;
server_name _;
root /var/www/;
  location /{
index index.php index.html index.htm;
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
root /var/www/;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
  
  

运维网声明 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-102110-1-1.html 上篇帖子: centos安装LNMP环境 下篇帖子: LNMP 常见问题(FAQ)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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