服务器架设篇-----CentOS架设WWW服务器-Nginx+Mysql+PHP

Nginx安装配置

安装nginx

系统环境:CentOS-6.3

软件:nginx-1.7.9.tar.gz

安装方式:源码编译安装

安装位置:/usr/local/nginx

安装前提

在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:

[[email protected] /]#yum install gcc-c++
[[email protected] /]#yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

检查系统安装的Nginx:

[[email protected] /]# find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.7.9/objs/nginx

卸载原有的Nginx

[[email protected] /]# yum remove nginx

安装

将安装包文件上传到/usr/local/soft中执行以下操作:

[[email protected] ~]# su root
[[email protected] ~]# cd /usr/local
[[email protected] local]# mkdir soft
[[email protected] local]# cd soft
[[email protected] soft]#wget http://nginx.org/download/nginx-1.7.9.tar.gz

解压缩

[[email protected] soft]# tar -zxv -f nginx-1.7.9.tar.gz
[[email protected] soft]#ls
nginx-1.7.9 nginx-1.7.9.tar.gz
[root@webServer soft]# mv nginx-1.7.9 /usr/local/nginx

[root@webServer soft]# rm -rf nginx-1.7.9.tar.gz

编译安装

[[email protected] nginx]#./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf

[root@webServer nginx]# make&&make install

安装完成后 目录有如下文件:

[[email protected] nginx]# lsauto   fastcgi.conf   koi-win   mime.types.default   scgi_params
CHANGES       fastcgi.conf.default   LICENSE nginx.conf   scgi_params.default
CHANGES.ru    fastcgi_params  logs   nginx.conf.default     src
conf   fastcgi_params.default    Makefile      objs   uwsgi_params
configure     html   man   README   uwsgi_params.default
contrib   koi-utf   mime.types   sbin   win-utf 

配置

#修改防火墙配置:
[[email protected] nginx]# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
[[email protected] nginx]# service iptables restart

启动nginx

#方法1
[[email protected] nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
[[email protected] nginx]# cd /usr/local/nginx/sbin
[[email protected] sbin]# ./nginx

停止nginx

#查询nginx主进程号
[[email protected] nginx]# ps -ef | grep nginx
#停止进程
[[email protected] nginx]#kill -QUIT 主进程号
#快速停止
[[email protected] nginx]#kill -TERM 主进程号
#强制停止
[[email protected] nginx]# pkill -9 nginx

重启nginx

[[email protected] nginx]# /usr/local/nginx/sbin/nginx -s reload

测试是否安装成功

#测试端口
[[email protected] nginx]#netstat –na|grep 80
#浏览器中测试
http://127.0.0.1:80

MySql安装配置

1.通过yum安装

#直接安装yum源中的mysql
[[email protected] ~]#yum -y install mysql-server

2.修改mysql配置

#暂修改默认编码
[[email protected] ~]#vim /etc/my.cnf
添加default-character-set = utf8

/var/lib/mysql     #mysql数据库的数据库文件存放位置
/var/log/mysqld.log   #mysql数据库的日志输出存放位置
netstat -anp   #命令来查看3306端口是否在监听

3.设置mysql随系统启动

#设置MySQL服务随系统启动自启动
[[email protected] ~]#chkconfig mysqld on
[[email protected] ~]#chkconfig --list mysqld  确保2--5为on的状态就行,然后启动MySQL服务
[[email protected] ~]#/etc/rc.d/init.d/mysqld start

4.设置root密码和用户操作

#为root用户设置密码
[[email protected] ~]/usr/bin/mysqladmin -u root password ‘newPassword‘
#用root用户登录MySQL服务器
[[email protected] ~]#mysql -u root -p
#查看用户信息
mysql>select user,host,password from mysql.user;

#建立对test数据库有完全操作权限的名为userA的用户
#格式:grant select on 数据库名.* to 用户名@登录主机 identified by "密匙";
mysql>grant all privileges on test.* to [email protected] identified by ‘用户密匙‘;
#创建一个可以从任何地方连接服务器的一个完全的超级用户userM
mysql>grant all privileges on *.* to [email protected]% identified by ‘密匙‘;
#删除root的远程授权
mysql>revoke all privileges on *.* from [email protected]"%";
#删除root的远程用户
mysql>delete from user where user="root" and host="%";
#刷新 使以上操作生效
mysql>flush privileges;

#修改userA的密码为NewPassword
mysql>set password for [email protected]=password(‘NewPassword‘);
#删除匿名用户
mysql>delete from mysql.user where user=‘‘;

5.数据库常用sql

mysql>show databases;  #查看系统中所有数据库
mysql>drop database test;  #删除名为test的数据库,不提醒
mysql>mysqladmin drop test;  #删除名为test的数据库前,有提示

mysql>show variables like ‘port‘;  #mysql查看打开的端口

mysql>create database test;  #建立名为test的数据库
mysql>use test;  #连接到数据库
mysql>show tables;  #查看数据库中已存在的表
mysql>alter table test rename test_study;  #重命名表test为test_study
mysql>describe test;  #表的详细描述

6.CentOS系统中mysqldump

#备份数据库
[[email protected] ~]mysqldump -h yourhost vi -uroot -p dbname <dbname_backup.sql
#恢复数据库
[[email protected] ~]mysqldump -h yourhost -uroot -p dbname < dbname_backup.sql
#如果只想Dump建表指令,则命令如下:
[[email protected] ~]mysqladmin -u root -p -d databasename > a.sql
#如果只想Dump插入数据的sql命令,而不需要建表命令,则命令如下:
[[email protected] ~]mysqladmin -u root -p -t databasename > a.sql
#那么只想要数据,而不想要什么sql命令时,
[[email protected] ~]mysqldump -T./ phptest driver
#其中,只有指定了-T参数才可以输出纯文本文件,表示输出数据的目录,./表示当前目录,即与mysqldump同一目录。
#如果不指定driver 表,则将卸出整个数据库的数据。每个表会生成两个文件,一个为.sql文件,包含建表执行。另一个为.txt文件,只包含数据,且没有sql指令。

PHP安装配置

#获取需安装的PHP版本
[[email protected] soft]#wget http://cn2.php.net/get/php-5.6.9.tar.gz
#解压
[[email protected] soft]# tar -zxvf php-5.6.9.tar.gz
#编译安装
[[email protected] soft]# cd php-5.4.26
[[email protected] php-5.4.26]# ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --enable-fpm --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
[[email protected] php-5.4.26]# make&&make install
[[email protected] php-5.4.26]# cd /usr/local/php
[[email protected] php]#  cp php.ini-production php.ini
时间: 2024-08-25 05:39:53

服务器架设篇-----CentOS架设WWW服务器-Nginx+Mysql+PHP的相关文章

Centos 6.5 安装 Nginx+MySQL+PHP

本文转载自:http://www.osyunwei.com/archives/2353.html 原文为安装CentOS 6.2 的步骤.博主安装6.5版本成功. 也安装了CentOS 7 版本成功.可至产看. 一下是原文: --------------------------------------------------------------------------------------------------------------------- 准备篇: 1.配置防火墙,开启80端口

CentOS 7编译安装Nginx+MySQL+PHP

一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/ip

centos中编译安装nginx+mysql +php(未完)

参考地址:http://www.cnblogs.com/htian/p/5728599.html 去官网找到PCRE,并下载http://www.pcre.org/wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.gz解压:tar -xzvf pcre.tar.gz进入pcre目录:cd pcre安装pcre./configure --prefix /usr/local/pcre2makemake

在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境

阿里云的云服务器(ECS)可以选择多种操作系统,打算用它运行 Drupal或者 WordPress ,你最好选择 Linux 系统,这篇文章的演示是基于阿里云的 CentOS 操作系统的服务器.我们在上面搭建一个 nginx + mysql + php-fpm 的环境,这就是常说的 LNMP .我们不过多解释什么是什么,而是着重讲流程与方法,想了解具体的细节,去搜索下吧:)这个手册是在阿里云上测试的,不过应该也适用于其它使用 CentOS 系统的服务器. 背景 宁皓网的< CentOS:在阿里云

CentOS 7 DNS服务器架设

CentOS 7 DNS服务器部署 项目背景和要求 要保证即能够解析内网域名linuxidc.local的解析,又能解析互联网的域名. 主DNS服务器:ZZYH1.LINUXIDC.LOCAL 辅助DNS服务器:ZZYH2.LINUXIDC.LOCAL 包含以下域的信息: 1.linuxidc.local域的信息: FQDN IP地址 备注 zzyh1.linuxidc.local 192.168.188.15 DNS1服务器 zzyh2.linuxidc.local 192.168.188.1

(转)推荐一个在Linux/Unix上架设ASP.NET的 WEB服务器--Jexus

在Linux/Unix上架设ASP.NET WEB服务器,有两个可选方式,一种是Mono+XSP,一种是Mono+Jexus,其它的方式,比如 Apache+mod_mono.Nginx+FastCgi 等等,其实质与XSP并无区别,都是使用Mono所提供的ASP.NET处理模块:Mono.WebServer名字空间实现对ASP.NET网站的支 持.Jexus不但具有跨平台ASP.NET服务器这样的标志性特征,同时还拥有内核级的安全监控.入侵检测.URL重写.无文件路由等一系列重要功能和 专有特

在CentOS 7中安装nginx服务器

简要地介绍一下,如何在CentOS 7中安装nginx服务器  下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm  建立nginx的yum仓库 # rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm  下载并安装nginx # yum inst

详细配置架设自己的Serv-U FTP服务器图文教程

首先:Serv-U设置匿名登录帐户的操作是非常简单的 其次:匿名 的英文是:Anonymous 最后:在Serv-U的现有域里新建一个帐户名为Anonymous的用户,没有大小写之分.跟建普通用户不一样:如果匿名用户名 "Anonymous"输入正确的话,它是不会提示你输入密码的,然后直接跑到选择目录那一项,建好用户后给这个用户加权限,然后测试,OK成功 启动Serv-U adminisrator之后,出现如图界面,先看看"本地服务器"这个项目,如图,有个选项是&q

服务器 CentOS上yum安装Nginx服务

一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses a new mirrorlist system developed by Lance Davis for CentOS. # The mirror system uses the connecting IP address of the client and the # update status