centos7 安装php7+mysql5.7+nginx+redis

1.先修改yum源  https://webtatic.com

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.安装nginx 继续阅读“centos7 安装php7+mysql5.7+nginx+redis”

MySQL命令行创建用户与授权

1. 创建用户:

命令:CREATE USER ‘username’ IDENTIFIED BY ‘password’;

说明:username ->你将创建的用户名, password ->该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器.

举个栗子:CREATE USER wordpress IDENTIFIED BY ‘wordpresspwd’; 继续阅读“MySQL命令行创建用户与授权”

centos搭建LNMP

转载者语:

转载于:http://www.osyunwei.com/archives/2353.html

原文标题:CentOS 6.2yum安装配置lnmp服务器(Nginx+PHP+MySQL)

本人以CentOS6.5亲测成功.

以下是原文.

————————————————————————————————————————————

准备篇:

yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch freetype-devel

1、配置防火墙,开启80端口、3306端口
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙)
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允许3306端口通过防火墙)
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
添加好之后防火墙规则如下所示:

继续阅读“centos搭建LNMP”

mysql 排除重复记录 insert 使用INSERT IGNORE into

INSERT IGNORE 与INSERT INTO的区别

INSERT IGNORE 与INSERT INTO的区别就是INSERT IGNORE会忽略数据库中已经存在 的数据,如果数据库没有数据,就插入新的数据,如果有数据的话就跳过这条数据。这样就可以保留数据库中已经存在数据,达到在间隙中插入数据的目的。
eg:
insert ignore into table(name)  select  name from table2

在centos7上搭建Apache+mariadb+php7

  • 安装mariadb

# yum install mariadb-server mariadb

啟動及設定開機自動執行 MariaDB:

# systemctl start mariadb
# systemctl enable mariadb

安装Apache

# yum install httpd

跟著回答 “y” 後便會完成安裝, 然後輸入以下指令啟動及設定 Apache 開機自動執行:

# systemctl start httpd
# systemctl enable httpd

安裝 PHP 7

下载php7包到/usr/local/src/ 目录并解压

安装扩展包

# yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel

进入php7解压包

# ./configure \
–prefix=/usr/local/php7/usr \
–with-config-file-path=/usr/local/php7/usr/etc \
–enable-mbstring \
–enable-zip \
–enable-bcmath \
–enable-pcntl \
–enable-ftp \
–enable-exif \
–enable-calendar \
–enable-sysvmsg \
–enable-sysvsem \
–enable-sysvshm \
–enable-wddx \
–with-curl \
–with-mcrypt \
–with-iconv \
–with-gmp \
–with-pspell \
–with-gd \
–with-jpeg-dir=/usr \
–with-png-dir=/usr \
–with-zlib-dir=/usr \
–with-xpm-dir=/usr \
–with-freetype-dir=/usr \
–enable-gd-native-ttf \
–enable-gd-jis-conv \
–with-openssl \
–with-pdo-mysql=/usr \
–with-gettext=/usr \
–with-zlib=/usr \
–with-bz2=/usr \
–with-recode=/usr \
–with-mysqli=/usr/bin/mysql_config \
–with-apxs2

然后

#make

#make test

#make install

复制 php.ini-development 文件到 /usr/local/lib 保存为 php.ini

编辑Apache配置文件 /etc/httpd/conf/httpd.conf  加入以下内容

LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

保存后重启Apache