CentOS 6.4安装配置LNMP服务器搭建Wordpress
时间:2015-01-10 15:40 来源: Linux公社 作者: Linux公社
准备:
1.配置防火墙,开启80端口、3306端口
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-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
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
~
二、部署
安装
一.安装nginx
yum remove httpd* php* #删除系统自带的软件包
yum install nginx -y #安装nginx
LNMP
chkconfig nginx on #设置nginx 开机启动
service nginx start #启动nginx
二.安装MySql
1.安装MySQL
yum install mysql mysql-server -y #yum 安装mysql 直到完成
LNMP
/etc/init.d/mysqld start #启动MySQL
LNMP
chkconfig mysqld on #设为开机启动
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:如果 /etc目录下面默认有一个my.cnf 直接覆盖即可)
2.为root账户设置密码
mysql_secure_installation
#回车,根据提示输入Y ,输入2次密码,回车,根据提示依次输入Y,最后出现Thabjs for using Mysql!
LNMP
LNMP
Mysql 密码设置完成,重新启动 MySQL:
/etc/init.d/mysqld restart #重启
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动
三.安装PHP5
1.安装PHP5
yum install php php-fpm -y #安装php直至完成
LNMP
2.安装PHP组件,是PHP5支持MYSQL
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回车
LNMP
chkconfig php-fpm on #设置php-fpm 开机启动
/etc/init.d/php-fpm start #启动php-fpm
配置篇:
一.配置nginx 支持php
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak #备份原有的配置文件
vim /etc/nginx/nginx.conf #编辑配置文件
user nginx nginx; #修改nginx 运行账号为;nginx组的nginx用户
:wq #保存退出
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #备份原有的配置文件
vim /etc/nginx/conf.d/default.conf #编辑配置文件
index index.php index.html index.htm;#添加index.php 如图(大概在14行左右):
LNMP
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
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;
}
LNMP
#取消FastCGI server 部分location 的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name 或者使用绝对路径
service nginx restart #重启nginx
本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2014-08/105128p3.htm
二.PHP 配置
vim /etc/php.ini #编辑
date.timezone = PRC #在878行左右 把前面的分号去掉,改为date.timezone = PRC
LNMP
expose_php = off #在375行左右禁止显示PHP版本信息
LNMP
short_open_tag = ON #在211行支持PHP短标签
LNMP
:wq #保存退出
三.配置php-fpm
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak #备份原有配置文件
vim /etc/php-fpm.d/www.conf #编辑
user = nginx # 修改用户为nginx
group = nginx #修改组为nginx
:wq #保存退出
LNMP
测试篇
cd /usr/share/nginx/html
vim index.php #添加一下代码
phpinfo();
?>
:wq #保存退出
chown nginx.nginx /usr/share/nginx/html -R #设置权限
service nginx restart #重启nginx
service php-fpm restart #重启php-fpm
LNMP
在客户端浏览器中输入服务器ip地址,可以看到相关的配置信息
说明lnmp配置成功
到此,CentOS6.4 安装配置LNMP(nginx+php+mysql)完成,
1.下载 wordpress网站代码
http://cn.wordpress.org/ 在官方网站上下载中文的wordpress网站源码
并解压
2.删除 /usr/share/nginx/html 下面的文件,并将刚刚解压的wordpress 源码复制到此目录下 (注意:是复制wordpress里面的文件全部复制进去,不是复制wordpress这个文件夹)
LNMP
3.创建wordpress数据库
mysql -u root -p #以root用户登录 mysql 输入密码
LNMP
mysql> create database zrq; #创建名为zrq的数据库
LNMP
mysql> use zrq; #按回车键出现Database changed 时说明操作成功!)
4.安装wordpress
在客户端打开浏览器输入服务器的ip地址:
LNMP
点击创建配置文件:
LNMP
点击“现在就开始”
LNMP
在提交之前,修改/usr/share/nginx/html 的权限
chmod 777 -R /usr/share/nginx/html
修改完之后点击提交:
LNMP
点击进行安装,并输入相关的网站信息:
LNMP
点击安装 wordpress ,出现一下画面说明博客搭建成功。
LNMP
LNMP
登录之后的界面
恭喜你网站搭建成功!
(责任编辑:IT)
准备: # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -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 -A FORWARD -j REJECT –reject-with icmp-host-prohibited COMMIT ~ 二、部署 安装 一.安装nginx yum remove httpd* php* #删除系统自带的软件包 yum install nginx -y #安装nginx LNMP chkconfig nginx on #设置nginx 开机启动 service nginx start #启动nginx 二.安装MySql 1.安装MySQL yum install mysql mysql-server -y #yum 安装mysql 直到完成 LNMP /etc/init.d/mysqld start #启动MySQL LNMP chkconfig mysqld on #设为开机启动 cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:如果 /etc目录下面默认有一个my.cnf 直接覆盖即可) 2.为root账户设置密码 mysql_secure_installation #回车,根据提示输入Y ,输入2次密码,回车,根据提示依次输入Y,最后出现Thabjs for using Mysql! LNMP LNMP Mysql 密码设置完成,重新启动 MySQL: /etc/init.d/mysqld restart #重启 /etc/init.d/mysqld stop #停止 /etc/init.d/mysqld start #启动 三.安装PHP5 1.安装PHP5 yum install php php-fpm -y #安装php直至完成 LNMP 2.安装PHP组件,是PHP5支持MYSQL 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回车 LNMP chkconfig php-fpm on #设置php-fpm 开机启动 /etc/init.d/php-fpm start #启动php-fpm 配置篇: 一.配置nginx 支持php cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak #备份原有的配置文件 vim /etc/nginx/nginx.conf #编辑配置文件 user nginx nginx; #修改nginx 运行账号为;nginx组的nginx用户 :wq #保存退出 cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #备份原有的配置文件 vim /etc/nginx/conf.d/default.conf #编辑配置文件 index index.php index.html index.htm;#添加index.php 如图(大概在14行左右): LNMP #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { 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; } LNMP #取消FastCGI server 部分location 的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name 或者使用绝对路径 service nginx restart #重启nginx 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2014-08/105128p3.htm 二.PHP 配置 vim /etc/php.ini #编辑 date.timezone = PRC #在878行左右 把前面的分号去掉,改为date.timezone = PRC LNMP expose_php = off #在375行左右禁止显示PHP版本信息 LNMP short_open_tag = ON #在211行支持PHP短标签 LNMP :wq #保存退出 三.配置php-fpm cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak #备份原有配置文件 vim /etc/php-fpm.d/www.conf #编辑 user = nginx # 修改用户为nginx group = nginx #修改组为nginx :wq #保存退出 LNMP 测试篇 cd /usr/share/nginx/html vim index.php #添加一下代码 phpinfo(); ?> :wq #保存退出 chown nginx.nginx /usr/share/nginx/html -R #设置权限 service nginx restart #重启nginx service php-fpm restart #重启php-fpm LNMP 在客户端浏览器中输入服务器ip地址,可以看到相关的配置信息 说明lnmp配置成功
到此,CentOS6.4 安装配置LNMP(nginx+php+mysql)完成, 1.下载 wordpress网站代码 http://cn.wordpress.org/ 在官方网站上下载中文的wordpress网站源码 并解压 2.删除 /usr/share/nginx/html 下面的文件,并将刚刚解压的wordpress 源码复制到此目录下 (注意:是复制wordpress里面的文件全部复制进去,不是复制wordpress这个文件夹) LNMP 3.创建wordpress数据库 mysql -u root -p #以root用户登录 mysql 输入密码 LNMP mysql> create database zrq; #创建名为zrq的数据库 LNMP mysql> use zrq; #按回车键出现Database changed 时说明操作成功!) 4.安装wordpress 在客户端打开浏览器输入服务器的ip地址: LNMP 点击创建配置文件: LNMP 点击“现在就开始” LNMP 在提交之前,修改/usr/share/nginx/html 的权限 chmod 777 -R /usr/share/nginx/html 修改完之后点击提交: LNMP 点击进行安装,并输入相关的网站信息: LNMP 点击安装 wordpress ,出现一下画面说明博客搭建成功。 LNMP LNMP 登录之后的界面
恭喜你网站搭建成功! (责任编辑:IT) |