##centOS 7 环境下的 LNMP环境搭建 centOS 7 设置命令行模式 systemctl set-default multi-user.targetphp
####安装编译nginx nginx最新稳定版下载地址 http://nginx.org/en/download.htmlhtml
cd /usr/local/src wget http://nginx.org/download/nginx-1.10.2.tar.gz tar zxvf nginx-1.10.2.tzr.gz mv nginx-1.10.2 nginx cd nginx ./configure --prefix=/usr/local/nginx
若是提示the HTTP rewrite module requires the PCRE library 就从http://pcre.org下载pcre库,缺乏其余库相同操做。 nginx1.10+须要pcre、zlib以及openssl库 若是在安装编译pcre的时候提示 You need a C++ compiler for C++ support ,就 yum -y gcc gcc-c++
nginx1.6版本以上须要指定库source地址,几个库我都是下载在/usr/local/lib中,从新编译mysql
./configure --prefix=/usr/local/nginx \ --with-pcre=/usr/local/lib/pcre \ --with-zlib=/usr/local/lib/zlib \ --with-openssl=/usr/local/lib/openssl make && make install
当没法经过时,检查是否权限不够。 启动nginx ./sbin/nginx
linux
设置centOS 7中的静态IP地址nginx
cd /etc/sysconfig/network-script vim ifcfg-ens192
讲BOOTPROTO改成"static",添加IPADDR 192.168.xx.xx,NETMASK,DNS,GATEWAY 若是系统中装了iptables,在打开防火墙的状况下,须要配置80端口经过防火墙c++
PHP7的下载地址http://ca1.php.net/get/php-7.1.0.tar.gz/from/this/mirrorsql
解压查看./configure -help数据库
# ./configure --help # ./configure --prefix=/usr/local/php \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip
使用yum一并安装vim
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl curl-devel
安装完以后./configure 上面的指令,而后make && make installapi
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp /usr/local/src/php/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
若是想将PHP加入全局变量,则在/etc/profile中最后一行加入
PATH=$PATH:/usr/local/php/bin #保存并在命令行执行 source /etc/profile
*** vim /usr/local/nginx/conf/nginx.conf sbin/nginx -s reload
去掉下面php的注释,并将$DOCUMENT_ROOT改成php项目根路径
MySql的下载地址http://mirrors.sohu.com/mysql
tar zxf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz mv zxf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz /usr/local/mysql
groupadd mysql useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql cd /usr/local/mysql chown -R mysql ./ chgrp -R mysql ./
mkdir data bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --explicit_defaults_for_timestamp
如我这里的位n,y<EDa2sJ 4. 初始化数据库
bin/mysql_ssl_rsa_ setup
cp /usr/local/mysql/support-files/my-defult.cnf /etc/my.cnf cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql vim /etc/my.cnf
更改basedir=/usr/local/mysql datadir=/usr/local/mysql/data port=3306 socket=/usr/local/mysql/mysql.sock 6. 启动mysql并用生成的临时密码登陆,设置登陆密码
cd /usr/local/mysql bin/mysqld_safe --user=mysql & bin/mysql --u root -p set password=password('123456'); grant all privileges on *.* to root@'%' identified by '123456'; flush privileges;
若是提示Can't connect to local MySQL server through socket '/tmp/mysql.sock' 就ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock 7. 添加系统路径,配置开机启动
vim /etc/profile export PATH=/usr/local/mysql/bin:$PATH source /etc/profile chmod 755 /etc/init.d/mysql chkconfig --add mysql chkconfig --level 345 mysql on