1、关闭selinux、配置防火墙,开启80、3306端口

[root@localhost ~]# cp /etc/sysconfig/iptables /etc/sysconfig/iptablesbak
[root@localhost ~]# vim /etc/sysconfig/iptables
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
[root@localhost ~]# /etc/init.d/iptables restart
[root@localhost ~]# cp /etc/sysconfig/selinux /etc/sysconfig/selinuxbak
[root@localhost ~]# cat /etc/sysconfig/selinux|grep -v "#"
SELINUX=disabled
SELINUXTYPE=targeted
[root@localhost ~]#

2、安装nginx

[root@localhost ~]# rpm -e --nodeps `rpm -qa|egrep -i "httpd|php"`  #删除系统自带的软件包
[root@localhost ~]# wget   #下载、安装第三方yum源
[root@localhost ~]# sh ./atomic   #安装
Do you agree to these terms? (yes/no) [Default: yes] yes
Configuring the [atomic] yum archive for this system
Installing the Atomic GPG keys: OK
OK
Enable repo by default? (yes/no) [Default: yes]:
The Atomic Rocket Turtle archive has now been installed and configured for your system
The following channels are available:
[root@localhost ~]# yum check-update   #更新yum源
[root@localhost ~]# yum -y install nginx
[root@localhost ~]# service nginx start
Starting nginx:                                            [  OK  ]
[root@localhost ~]#

3、安装MySQL

[root@localhost ~]# yum install mysql mysql-server -y
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# /etc/init.d/mysqld start
[root@localhost ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@localhost ~]# mysql_secure_installation   #为root账户设置密码
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!Remove anonymous users? [Y/n] Y  ... Success!Disallow root login remotely? [Y/n] Y... Success!Remove test database and access to it? [Y/n] Y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reload privilege tables now? [Y/n] Y... Success!Thanks for using MySQL![root@localhost ~]# service mysqld restart

4、安装PHP5

[root@localhost ~]# yum install php php-fpm -y
[root@localhost ~]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt  php-bcmath php-mhash libmcrypt -y  #安装PHP组件,使 PHP5 支持 MySQL
[root@localhost ~]# chkconfig php-fpm on
[root@localhost ~]# /etc/init.d/php-fpm start
Starting php-fpm:                                          [  OK  ]
[root@localhost ~]#

5、配置nginx支持php

[root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
[root@localhost ~]# vim /etc/nginx/nginx.conf
user              nginx nginx;    #修改nginx运行账号为:nginx组的nginx用户
worker_processes  1;
[root@localhost ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
[root@localhost ~]# vim /etc/nginx/conf.d/default.conflocation / {root   /usr/share/nginx/html;index  index.php index.html index.htm;   #增加index.php# example#ModSecurityEnabled on;#ModSecurityConfig /etc/nginx/modsecurity.conf;}location ~ \.php$ {    #取location的注释,并将fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径root           html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include        fastcgi_params;}   [root@localhost ~]# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]
[root@localhost ~]#

6、php配置

[root@localhost ~]# cp /etc/php.ini /etc/php.inibak
[root@localhost ~]# vim /etc/php.ini878 date.timezone = PRC314 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,in     i_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapesh     ellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_c     termid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_ge     tgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwna     m,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_se     tegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_     ttyname,posix_uname   #PHP禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。375 expose_php = Off    #禁止显示php版本的信息211 short_open_tag = ON   #支持php短标签308 open_basedir = .:/tmp/  #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php***跨站,如果改了之后安装程序有问题(例如:nginx可能网站根目录下的文件会提示Access Denied),可以注销此行,或者直接写上程序的目录open_basedir = /usr/share/nginx/html/:/tmp/[root@localhost ~]#

7、配置php-fpm

[root@localhost ~]# cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
[root@localhost ~]# vim /etc/php-fpm.d/www.conf
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[root@localhost ~]#

8、测试

[root@localhost ~]# cd /usr/share/nginx/html/
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
~
[root@localhost html]# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]
[root@localhost html]# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]
[root@localhost html]#

在客户端浏览器输入服务器IP地址,可以看到相关的配置信息(无法查看可以将php.ini中expose_php设置为on、open_basedir注释掉,或者直接写上程序的目录)! 说明lnmp配置成功!

转载于:https://blog.51cto.com/ityunwei2017/1733287

LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL)相关推荐

  1. zabbix安装配置(nginx php mysql zabbix)

    环境信息: 系统:rhel6.2 一.Nginx安装: 下载:http://nginx.org/en/download.html [root@primary apps]# yum install pc ...

  2. Mac M1 配置初始化 Nginx+PHP+MySQL环境

    环境 Homebrew

  3. LNMP(Linux、Nginx、MySQL、PHP)安装部署

    LNMP是Linux.Nginx.MySQL.PHP的缩写,是指在Linux环境下由Nginx.MySQL.PHP构建的Web后台运行环境,是一种流行先进.便捷轻便.高性能的一后台环境. 我们今天介绍 ...

  4. lnmp基于fastcgi实现nginx_php_mysql的分离_LNMP基于FastCGI实现Nginx,PHP,MySQL的分离

    LNMP基于FastCGI实现Nginx,PHP,MySQL的分离 [日期:2012-11-12] 来源:Linux社区 作者:laoguang [字体:大 中 小] 平时安装LNMP是把它们安装到同 ...

  5. linux的lnmp环境,Ubuntu 16.04 LTS下LNMP环境配置简述

    Ubuntu 16.04 LTS下LNMP环境配置简述 1.安装mysql sudo aptinstall mysql-server 安装过程会提示密码 2.安装nginx和php #添加nginx和 ...

  6. CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)

    以下全部转载于  http://blog.csdn.net/lane_l/article/details/20235909 本人于今晚按照该文章使用centos 6.7 64bit安装成功,做个备份, ...

  7. CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)

    准备篇: 1.配置防火墙,开启80端口.3306端口       vi /etc/sysconfig/iptables       -A INPUT -m state --state NEW -m t ...

  8. centos7二进制安装php,Centos7下编译安装配置Nginx+PHP+MySql环境

    序言 这次玩次狠得.除了编译器使用yum安装,其他全部手动编译.哼~ 看似就Nginx.PHP.MySql三个东东,但是它们太尼玛依赖别人了. 没办法,想用它们就得老老实实给它们提供想要的东西. 首先 ...

  9. LNMP(nginx防盗链,访问控制,解析php相关配置,Nginx代理,常见502问题)

    一.nginx防盗链 nginx防盗链: [root@lnmp ~]# vim /usr/local/nginx/conf/vhost/test.com.conf   添加以下内容 location ...

最新文章

  1. 做了6年的Java,java视频教程传智播客
  2. 洛谷 P2590 [ZJOI2008]树的统计
  3. spring+mybatis实现读写分离
  4. 每天自动给自己发天气预报的脚本
  5. linux3.0-内核自带led驱动移植
  6. python3 抽象基类 abc.abstractmethod
  7. OPencv_边缘检测算法
  8. Apache(httpd) 报错You don't have permission to access /on this server.
  9. CountdownLatchTest
  10. 绕过PDF阅读编辑要VIP才能无水印保存的方法
  11. PPT一般使用技巧总结
  12. 开源免费跨平台且超级傻瓜的视频分割的软件VidCutter(附CSDN下载)
  13. 网络营销-渠道、公关
  14. 我的网关、子网掩码、DNS1、DNS2是什么
  15. 银行数字化转型导师坚鹏:苏州银行数字化运营之认知篇培训结束
  16. 梦之光芒Monyer (全关解析)
  17. Ubuntu16.04中python升级到3.6版本后Terminal打不开的解决方法
  18. 畜禽养殖智能环境监控系统
  19. 在linux环境中安装jieba模块
  20. 5个自学网络安全的网站,全是技术干货!

热门文章

  1. IBM连续两年大数据市场占有率全球第一
  2. 拉美光伏新兴市场热潮将至
  3. 【九章算法免费讲座第一期】转专业找CS工作的“打狗棒法”
  4. Java 网络编程1
  5. JFinal整合CKFinder
  6. 下午去银行办理按揭手续,不得已调休半天
  7. java dateutil 获取时间戳_java DateUtil工具类时间戳类型转换详解
  8. sublime python配置运行
  9. spring boot拦截器中获取request post请求中的参数(转)
  10. Linux常用开发环境软件-Redis安装(docker环境下)