LNMP(Linux+Nginx+MySQL+PHP)centos6.4安装

nginx命令
中止nginx服务:# /etc/init.d/nginx stop
启动nginx服务:# /etc/init.d/nginx start
编辑nginx配置文件:# vim /etc/nginx/nginx.confphp

/etc/init.d/php-fpm restart
service php-fpm starthtml

最后只要 yum -y update 一下,全是最新的
别忘了开机启动
chkconfig --level 345 mysqld on
chkconfig --level 345 php-fpm on
chkconfig --level 345 nginx onmysql

你能够用下列方法检查配置文件是否有语法错误
# /etc/init.d/nginx configtest linux

 

问题:nginx

1.打开phpmyadmin时出现mysqli扩展c++

  设置:extension_ext = "/var/lib64/php/modules";web

2.打开phpmyadmin时,出现:Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.sql

  首先看session.auto_start = 0,若是设置0不行,就设置1.
  若是还不行,看session.save_path,看看这个路径有没有权限。apache

1.MySQL
yum源:http://dev.mysql.com/downloads/repo/yum/ vim

配置yum源:http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html 

# yum -y install mysql-server
# chkconfig mysqld on
# service mysqld start

2.Nginx.

在/etc/yum.repos.d/目录下创建一个nginx.repo软件源配置文件。命令以下:
# cd /etc/yum.repos.d/
# vim

而后填写以下文件内容

[nginx] 
name=nginx repo 
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ 
gpgcheck=0 
enabled=1

注意:必定要看这句话(参考:http://nginx.org/en/linux_packages.html#stable)

执行vim命令保存文件为nginx.repo完整路径是/etc/yum.repos.d/nginx.repo
:w

执行yum命令安装nginx

yum install nginx

添加防火墙
在安装完成nginx后,须要设置防火墙设置容许80端口,操做以下: 
# vim /etc/sysconfig/iptables   
添加一行 

-A INPUT –m state –state NEW –m tcp –p tcp –dport 80 –j ACCEPT 

在修改完防火墙后须要执行以下命令重启防火
# /etc/init.d/iptables restart
紧接着启动nginx
# /etc/init.d/nginx start


而后保存并退出:wq 

nginx伪静态:

1.将include /www/web1.nginx加入到nginx的虚拟机配置文件中,
      加入到location / {}部分。

2.伪静态文件:

rewrite ^/about\.html$ /?do=profile last;

注意:1.前部分须要加根目录斜线"/";
        2.将RewriteRule改为rewrite;
        3.末尾加上 last;

 

编译安装:(参考:http://lxsym.blog.51cto.com/1364623/293096)

安装PHP(PHP5.3之后,php-fpm就是php的核心模块存在了)
      这个地方是最重要的地方,由于默认状况下Nginx和PHP他俩之间是一点感受没有的。在以前,不少朋友都搭建过Apache+PHP,Apache+PHP编译后生成的是模块文件,而Nginx+PHP须要PHP生成可执行文件才能够,因此要利用fastcgi技术来实现Nginx与PHP的整合,这个只要咱们安装是启用FastCGI便可。这次咱们安装PHP不只使用了FastCGI,并且还使用了PHP-FPM这么一个东东,PHP-FPM说白了是一个管理FastCGI的一个管理器,它做为PHP的插件纯在,在安装PHP要想使用PHP-FPM时就须要把PHP-FPM以补丁的形式安装到PHP中,并且PHP要与PHP-FPM版本一致,这是必须的,切记!

 

整合Nginx与PHP
上面已经讲过,Nginx本身并不处理动态网页的请求,并且Nginx将获得的动态请求转交给PHP,下面咱们打开Nginx的配置文件看一下
#vi /etc/nginx/conf.d/default.conf
 

看上图,Nginx已经知道怎么把获得的请求传达给PHP,Nginx在获得*.php请求时,会把请求经过9000端口传给PHP。

      那么只有Nginx本身知道咋找PHP了还不行,还须要PHP知道咋找Nginx,PS:你见过大街上的JJMM约会时有不是相互认识对方,或者是不知道用啥方法和对方接头的?这点咱们不须要担忧,PHP-FPM已经在配置文件中定义了从哪接受PHP请求,咱们能够打开配置文件看一下
#vi /etc/php-fpm.d/www.conf

如上图所示,咱们在前面已经看到过Nginx是经过本机的9000端口将PHP请求转发给PHP的,而上图咱们能够看到PHP本身是从本机的9000端口侦听数据 ,Nginx与PHP经过本机的9000端口完成了数据请求。

 

php源码安装:
1.cd /usr/local/php/
wget http://cn2.php.net/distributions/php-5.6.8.tar.gz

2.

./configure --prefix=/usr/local/php --enable-fpm --enable-mbstring --with-mysql=/usr/local/mysql --with-iconv-dir=/usr/local --with-apxs2=/usr/local/apache2/bin/apxs

 

 

PHP编译安装出现的各类问题:

php版本:php-5.4.3

安装前.先安装些软件和库文件

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

领导要咱们本身手动装 不容许咱们直接用yum 因此上面的都没执行

编译安装PHP

进入php的解压目录

./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt=/usr/local/libmcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-pdo --with-pdo-mysql --with-gettext --with-curl --with-pdo-mysql --enable-sockets --enable-bcmath --enable-xml --with-bz2 --enable-zip --enable-freetype

运行以后遇到的问题:

error 1

checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.

(看提示就明白 是一个lib库没装 先用 yum search 名字 看是否能搜到名字 ,找到名字后 把软件包 开发包装上)

解决办法

yum install libxml2-devel.x86_64

error 2

checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

这是ssl没装

解决办法

yum install openssl.x86_64 openssl-devel.x86_64 -y

error 3

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

这是bzip2软件包没有安装

解决办法

yum install bzip2-devel.x86_64 -y

error 4

configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

curl和curl库文件没有安装

解决办法

yum install libcurl.x86_64 libcurl-devel.x86_64 -y

error 5

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found

GD库没有安装

解决办法

yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

error 6

checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

libmcrypt库没有安装 ,要是不能用yun安装的话 就要去下载个gz包 本身编译安装

(编译安装 ./configure --piefix=/usr/local/libmcrypt make && make install)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

要是错误里面含有mysql的 那是mysql-devel 没有安装

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

出现

Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c

编译PHP的--with-gd=/usr/include错误提示:configure: error: Unable to find gd.h anywhere under代表已经装好GD库啦,把后面的路径取消就能够啦--with-gd --with-jpeg --with-pngok

相关文章
相关标签/搜索