CentOS 6.6部署MySQL+Nginx+PHP环境(3)

内容编辑后如下:

# 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 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT

启动mysql

service mysql start

1 mysql装完之后,默认的初始化root密码在/root/.mysql_secret里面

所以你登录的时候用 mysql -u root -p密码,就可以了

2 登录之后,必须密码

mysql> set password=password('新的密码');

3 目前为止root只有本地登录权限,没有远程登录权限

至此,mysql安装完毕。

接下来,要开放一个用户可以通过工具可以连接到服务器的数据库,

创建用户命令如下: CREATE USER 'username'@'%' IDENTIFIED BY 'password'; 授权如下: GRANT ALL ON *.* TO 'username'@'%'; Nginx安装

安装nginx需要的环境,pcre(作用rewrite)、zlib(作用压缩)、ssl,这个也可以自己下载编译安装

minimal下要先安装如下支持

yum -y install gcc gcc-c++ autoconf automake openssl openssl-devel pcre-devel zlib-devel zlib pcre

执行以上代码,环境安装完毕。

下载对应的nginx安装包(nginx-*.tar.gz)

下载地址:

本文中下载的是1.11.1版本

解压压缩包

tar –zxvf nginx-1.11.1.tar.gz

进入解压后的目录

cd nginx-1.11.1;

然后执行

./congigure --prefix=/usr/local/nginx;

继续执行代码

make && make install;

为了方便执行nginx命令,这里加入对应的环境变量

执行命令:

vim /ect/profile

新增如下内容

PATH=$PATH:/usr/local/nginx/sbin export PATH

加好后如下:

# /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`id -u` UID=`id -ru` fi USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after pathmunge /sbin after fi HOSTNAME=`/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after pathmunge /sbin after fi HOSTNAME=`/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL PATH=$PATH:/usr/local/nginx/sbin export PATH # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200 # You could check uidgid reservation validity in # /usr/share/doc/setup-*/uidgid file if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null 2>&1 fi fi done unset i unset -f pathmunge

按ESC键退出vim编辑模式,输入

:wq

保存退出

让修改后的环境变量生效:

source /etc/profile

这样环境变量就加好了,测试一下呗。
输入命令:

nginx -v

成功配置后结果显示如下:

nginx version: nginx/1.11.1

接下来修改防火墙配置,开放80端口

执行命令:

vim /etc/sysconfig/iptables

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/84459a42242b5d474c6cd531f82b88b7.html