首页 Linux网维 CentOS 6.5服务器yum安装配置lnmp环境

CentOS 6.5服务器yum安装配置lnmp环境

准备篇 1、配置防火墙,开启80 和3306端口 [root@localhost ~]# vim /etc/sysconfig/iptables -A INPUT -m state…

准备篇 1、配置防火墙,开启80 和3306端口 [root@localhost ~]# vim /etc/sysconfig/iptables -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 [root@localhost ~]# /etc/init.d/iptables restart 重启防火墙使配置生效 2、关闭SELINUX [root@localhost ~]# vim /etc/selinux/config SELINUX=disabled [root@localhost ~]# reboot 3、配置centos第三方yum源(centos默认的标准源里没有nginx的包) [root@localhost ~]# yum -y install wget 安装下载wget工具 [root@localhost ~]# wget http://www.atomicorp.com/installers/atomic 下载atomic yum源 [root@localhost ~]# sh ./atomic 安装 [root@localhost ~]# yum check-update 更新yum软件包 安装篇 1、安装nginx [root@localhost ~]# yum -y install nginx 安装nginx软件 [root@localhost ~]# service nginx start 启动 [root@localhost ~]# chkconfig nginx on 设置开机启动 [root@localhost ~]# /etc/init.d/nginx restart 重启nginx服务 [root@localhost ~]# rm -rf /usr/share/nginx/html/* 删除nginx默认页面 2、安装mysql [root@localhost ~]# yum install mysql mysql-server -y 安装mysql [root@localhost ~]# /etc/init.d/mysqld start 启动mysql [root@localhost ~]# chkconfig mysqld on 设置开机启动 [root@localhost ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf 拷贝配置文件,直接覆盖原有的 [root@localhost ~]# reboot 重启系统 [root@localhost ~]# mysql_secure_installation 为root设置密码 [root@localhost ~]# /etc/init.d/mysqld stop 启动mysql [root@localhost ~]# /etc/init.d/mysqld start 停止mysql [root@localhost ~]# service mysqld restart 重启mysql 3、安装php [root@localhost ~]# yum install php -y [root@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 [root@localhost ~]# /etc/init.d/mysqld restart 重启mysql服务 [root@localhost ~]# /etc/init.d/nginx restart 重启nginx服务 [root@localhost ~]# /etc/rc.d/init.d/php-fpm start 启动php-fpm服务 [root@localhost ~]# chkconfig php-fpm on 设置开机启动 配制篇 1、配置nginx支持PHP [root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak [root@localhost ~]# vim /etc/nginx/nginx.conf user nginx nginx; #修改 nginx 运行账号为:nginx 组的 nginx 用 户! [root@localhost ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak [root@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配置 [root@localhost ~]# vim /etc/php.ini date.timezone = PRC expose_php = Off #;open_basedir = .:/tmp/ 注释掉这行 3、配置php-fpm [root@localhost ~]# vim /etc/php-fpm.d/www.conf 编辑 user = nginx 编辑用户为nginx group = nginx 修改组为nginx [root@localhost ~]# /etc/init.d/mysqld restart 重启mysql [root@localhost ~]# /etc/init.d/nginx restart 启动nginx [root@localhost ~]# /etc/rc.d/init.d/php-fpm restart 重启Php-fpm 测试篇 [root@localhost ~]# cd /usr/share/nginx/html/ 进入nginx默认网站根目录 [root@localhost html]# cat index.php 新建index.php文件 [root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R 设置是目录所有者 [root@localhost html]# chmod 700 /usr/share/nginx/html/ -R 设置目录权限 备注 [root@localhost ~]# cd /usr/share/nginx/html/ nginx默认的程序目录 [root@localhost ~]# chown nginx.nginx /usr/share/nginx/html/ -R 权限设置 [root@localhost ~]# cd /var/lib/mysql/ 数据库目录是 [root@localhost ~]# chown mysql.mysql -R /var/lib/mysql/ 权限设置 [root@localhost html]# tail -n20 /var/log/nginx/error.log 查看nginx的日志 软件版本 [root@localhost html]# nginx -v nginx version: nginx/1.6.2 [root@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 [root@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

免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

作者: 3182235786a

为您推荐

linux文件命令

linux文件命令

在 Linux 中,我们可以使用 `with open()` 语句和 `write()` 函数来写入文件。以下是一个简单...
linux的命令

linux的命令

以下是一个简单的 Linux 命令示例,该命令将显示当前日期和时间: “`c #include <st...
linux 命令

linux 命令

由于 Linux 命令是由 C 语言编写的,因此下面是一个简单的用中文编写的 Linux 命令示例,它将输出“Hello...
linux命令tar

linux命令tar

这个问题看起来有些模糊,我不确定您是想了解如何在 Linux 系统中使用 tar 命令,还是如何编写一个名为 tar 的...
linux压缩命令

linux压缩命令

Linux压缩命令:高效管理文件和目录 Linux操作系统提供了一系列强大的压缩命令,使您能够高效地管理文件和目录。无论...

发表回复

返回顶部