lnmp搭建(Nginx1.12.1;mysql5.7.20;php7.2.0)
2017-12-18 14:16
381 查看
安装依赖包:
创建www用户:
一、安装Nginx1.12.1:
centos6.8的镜像带的Nginx版本是1.12.1
二、安装mysql5.7.20:
三、安装PHP7.2.0
3.1源码编译安装
上面configure步骤,可能会因为缺少依赖包而报错,我这台机器安装过其他一些其他的包,不同的机器情况可能不一样,在编译的时候根据报错信息
用yum search 查找依赖包并安装,编译完成之后是没有error的!!!
make install 完成后也是没有error的才可以进行后面的步骤。
3.2 配置PHP
3.3启动php-fpm
3.4添加 PHP 命令到环境变量
使之生效:
3.5查看PHP版本:
3.6测试结果:
Nginx配置文件修改的地方(在server里面添加 index.php格式的文件。增加一个location模块)
重新加载Nginx,重启php-fpm
测试:
或者直接到网页上访问。
至此,lnmp环境搭建成功
#yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel libpng-devel libjpeg-devel freetype freetype-devel
创建www用户:
#groupadd www #useradd -g www -s /sbin/nologin -M www
一、安装Nginx1.12.1:
centos6.8的镜像带的Nginx版本是1.12.1
#yum install -y nginx #/etc/init.d/nginx start
二、安装mysql5.7.20:
#wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm #rpm -Uvh mysql57-community-release-el6-9.noarch.rpm #yum install mysql-community-server #service mysqld start #grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}' #mysql -uroot -p mysql>set global validate_password_policy=0; mysql>set global validate_password_length=6; mysql>SET PASSWORD FOR 'root'@'localhost' =PASSWORD('******');
三、安装PHP7.2.0
3.1源码编译安装
#wget rm -php-7.2.0.tar.xz #tar xvJf php-7.2.0.tar -C /usr/local/ #cd /usr/local/php-7.2.0 #./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath -- 4000 enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts --with-libdir=lib64 # make # make install
上面configure步骤,可能会因为缺少依赖包而报错,我这台机器安装过其他一些其他的包,不同的机器情况可能不一样,在编译的时候根据报错信息
用yum search 查找依赖包并安装,编译完成之后是没有error的!!!
make install 完成后也是没有error的才可以进行后面的步骤。
3.2 配置PHP
#cp /usr/local/php-7.2.0/php.ini-development /usr/local/php/etc/php.ini
#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#cp /usr/local/php-7.2.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod +x /etc/init.d/php-fpm
#cp /usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf
3.3启动php-fpm
# /etc/init.d/php-fpm start Starting php-fpm done
3.4添加 PHP 命令到环境变量
vim ~/.bash_profile cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/local/php/bin export PATH
使之生效:
#. ~/.bash_profile
3.5查看PHP版本:
# php -v PHP 7.2.0 (cli) (built: Dec 17 2017 19:58:31) ( ZTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
3.6测试结果:
vim /usr/share/nginx/html/a.php <?php phpinfo(); ?>
vim /etc/nginx/conf.d/default.conf cat /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
Nginx配置文件修改的地方(在server里面添加 index.php格式的文件。增加一个location模块)
重新加载Nginx,重启php-fpm
# /etc/init.d/nginx restart Stopping nginx: [ OK ] Starting nginx: [ OK ] # /etc/init.d/php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done
测试:
# curl 192.168.1.185/a.php
或者直接到网页上访问。
至此,lnmp环境搭建成功
相关文章推荐
- lnmp搭建(Nginx1.12.1;mysql5.7.20;php7.2.0)
- 高性能LNMP搭建(linux/nginx/mysql/php-fastcgi)
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- 高性能LNMP搭建(linux/nginx/mysql/php-fastcgi)
- centos 下lnmp(linux+nginx+mysql+php)环境搭建
- centos6 LNMP的搭建(linux+nginx+mysql+php)
- lnmp 环境搭建 源代码包安装 linux,nginx,mysql,php
- CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)【转】
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- LNMP linux+nginx+mysql+php 环境搭建(基于centos)
- 搭建lnmp=(nginx+mysql+php)
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- Centos下搭建LNMP(Linux+MySQL+nginx+PHP)
- LNMP(Linux+Nginx+MySQL+PHP)环境搭建
- nginx+mysql+php lnmp环境搭建
- LNMP(Linux+Nginx+Mysql+PHP---源码)环境搭建
- LNMP环境搭建,自启动 php7,mysql5.6,nginx1.11
- LNMP环境搭建(httpd-2.4.9,mysql-5.6.17,php-5.5.12,nginx-1.4.6,zendopcache,memcache)
- 阿里云服务器搭建lnmp。Centos6.8 + nginx-1.10.3 + MySQL-5.6.16 + PHP-5.4.16
- LNMP(linux+nginx+mysql+php)环境搭建_1