##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