lnmp安装--php安装
版本:php5.6.4 x86_64centos 6.6 x86_64
安装php之所以难,是因为要安装的扩展多,依赖关系复杂。
安装前的准备:
先看你想要安装哪些扩展。需要哪些包。下载地址:http://pan.baidu.com/s/1kTn7VQB
-rw-r--r--.1 root root 3001938 Jun 152013 curl-7.19.6.tar.gz
-rw-r--r--.1 root root 1775673 Jun 172013 freetype-2.3.5.tar.gz
-rw-r--r--.1 root root 587617 Nov32004 gd-2.0.33.tar.gz
-rw-r--r--.1 root root 258396 Jun 152013 GD-2.44.tar.gz-rw-r--r--.1 root root 991456 Jun 152013 jpegsrc.v8d.tar.gz
-rw-r--r--.1 root root 2353373 Jun 172013 libgd-2.1.0-rc2.tar.gz
-rw-r--r--.1 root root 1335178 Jun 152013 libmcrypt-2.5.8.tar.gz
-rw-r--r--.1 root root 837439 Jun 152013 libpng-1.4.12.tar.gz
-rw-r--r--.1 root root 471915 Jun 152013 mcrypt-2.6.8.tar.gz
-rw-r--r--.1 root root 655906 Jun 152013 mhash-0.9.9.9.tar.bz2-rw-r--r--.1 root root 2402592 Dec 232006 ncurses-5.6.tar.gz
-rw-r--r--.1 root root17323206 May 182013 perl-5.18.0.tar.gz-rw-r--r--.1 root root 560351 Jun 152013 zlib-1.2.7.tar.gz
再看看配置项:
./configure --prefix=/usr/local/php --with-config-file-path=/etc--with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
可以看出我需要的功能有,gd库,mysql,mysqli,pdo,fpm,curl,mbstring。
可能新手会很困惑,php怎么和mysql结合,这里要说一下,php只需要安装上mysql的扩展(mysql,mysqli,pdo-mysql),php程序连接mysql的时候,会自动到对应host的端口连接mysql,只要mysql服务在监听就没有问题。
/etc/my.cnf配置
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
将上面所列出的包,依次安装上。
然后再./configure php
yum install libxml2 libxml2-devel
yum install bzip2 bzip2-devel
找不到 gd.h。
gdlib-config--all
实际上找不到gd.h是因为没有安装下面两个包。
yum install libXpm
yum install libXpm-devel
安装完,配置gd库。
perl ./Makefile.PL
cd libgd-2.1.0-rc2
./configure --with-xpm=/usr/lib
中间会显示gd支持的特性。
make
make install
cd GD-2.44
perl ./Makefile.PL
make&&make install
./configure --prefix=/usr/local/php --with-config-file-path=/etc--with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
754make
755make install
756php
757/usr/local/sbin/php-fpm -h
758/usr/local/php/sbin/php-fpm -h
759ls /usr/local/php/php/
760ls /usr/local/php/
761ls
762cp php.ini-development/usr/local/php/php/php.ini
763ls /usr/local/php/php/
764find / -name php-fpm.conf.default
765cp /usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
766cp sapi/fpm/php-fpm /usr/local/bin/
767php-fpm start
768php-fpm
769vim /usr/local/php/php/php.ini
View Code 至此全部安装完毕。
663ls
664./configure --help
665./configure --help |grep mysqli
666./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
667yum install libxml2 libxml2-devel
668./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
669yum install BZip2
670yum list |grep bzip2
671yum install bzip2 bzip2-devel
672./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
673ls /usr/local |grep gd
674ls /usr/local/
675./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
676ls /usr/local
677ls /usr/local/lib
678find / -name gd.h
679./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
680./configure --prefix=/usr/local/php --with-config-file-path=/etc--with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
681vim README.md
682ls
683vim INSTALL
684make
685ls /usr/local/
686ls /usr/local/lib
687find / |grep gd$
688cd /usr/share/locale/gd/
689ls
690cd /root/Downloads/
691ls
692cd extended/
693ls
694cd GD-2.44
695ls
696vim README
697find / |grep bin/gd
698/usr/sbin/gdm
699/usr/sbin/gdm --help
700/usr/sbin/gdm --version
701find / |grep bin/gd$
702gd_info();
703gd_info() ;
704gd_info
705gdlib-config
706gdlib-configall
707gdlib-config--all
708gdbus
709gdm
710gdm --help
711gdm-binary
712gdm-binary --help
713gdcmpgif
714gdlib-config
715gdlib-config--libs
716gdlib-config--revision
717gdlib-config --features
718yum install libXpm
719yum install libXpm-devel
720gdlib-config --features
721ls
722./perl Makefile.PL
723vim README
724perl ./Makefile.PL
725perl ./Makefile.PL -h
726perl ./Makefile.PL
727make
728make install
729gdlib-config
730perl ./Makefile.PL--help
731perl ./Makefile.PL-h
732perl ./Makefile.PL ?
733perl ./Makefile.PL--with-xpm=/usr/local/lib
734vim README
735cd ..
736ls
737cd libgd-2.1.0-rc2
738ls
739./configure --with-xpm=/usr/lib
740make
741cd ..
742ls
743cd libgd-2.1.0-rc2
744make install
745cd ..
746cd GD-2.44
747perl ./Makefile.PL
748make&&make install
749cd ..
750cd php-5.6.4
751./configure --prefix=/usr/local/php --with-config-file-path=/etc--with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
752find / |grep gd.h
753./configure --prefix=/usr/local/php --with-config-file-path=/etc--with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm--with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
754make
755make install
756php
757/usr/local/sbin/php-fpm -h
758/usr/local/php/sbin/php-fpm -h
759ls /usr/local/php/php/
760ls /usr/local/php/
761ls
762cp php.ini-development/usr/local/php/php/php.ini
763ls /usr/local/php/php/
764find / -name php-fpm.conf.default
765cp /usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
766cp sapi/fpm/php-fpm /usr/local/bin/
767php-fpm start
768php-fpm
769vim /usr/local/php/php/php.ini
770vim /usr/local/nginx/conf/nginx.conf
771/usr/local/nginx/ -s stop
772/usr/local/nginx/sbin/nginx -s stop
773/usr/local/nginx/sbin/nginx
774service mysqld start
775php-fpm
776cd /usr/local/nginx/html/
777ls
778vim index.php
779/usr/local/mysql/bin/mysql -uroot -p
780vim index.php
781vim /usr/local/php/php/php.ini
782/usr/local/nginx/sbin/nginx -s stop
783/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
784find /usr/ -name php-fpm.conf
785vim /usr/local/php/etc/php-fpm.conf
786pkill php-fpm
787/usr/local/bin/php-fpm
788cat /etc/passwd |grep www
789vim /usr/local/php/etc/php-fpm.conf
790/usr/local/bin/php-fpm
791pkill php-fpm
792/usr/local/bin/php-fpm
793cat /etc/passwd
794groupadd nginx
795useradd -r -g nginx nginx
796vim /usr/local/php/etc/php-fpm.conf
797/usr/local/bin/php-fpm
798vim /usr/local/php/etc/php-fpm.conf
799/usr/local/bin/php-fpm
800/usr/local/nginx/sbin/nginx -s stop
801/usr/local/nginx/sbin/nginx
802ls
803cd ..
804ls -l
805chmod -R 777 ./html/
806ps -ef |grep php
807/usr/local/mysql/bin/mysql -hlocalhost -uroot -p
808ls
809vim html/index.php
810/usr/local/mysql/bin/mysql -uroot -p -hlocalhost
811history
安装中用过的所有命令: 可能发生的错误:
configure: error: Please reinstall the BZip2 distribution
yum install bzip2 bzip2-devel
yum install -y libmcrypt libmcrypt-devel
configure:error: *** libmcrypt was not found
为了的到mcrypt.so库文件,先后安装编译了mhash和libmcrypt, 但是到最后编译mcrypt时报错:
configure: error: *** libmcrypt was not found
# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次编译
http://www.iyunv.com/Linux/2009-03/18739.htm
http://www.it165.net/os/html/201304/4868.html
安装gd的时候,会报这个错误 “usr/local/src/php-5.5.6/ext/gd/gd.c:57:22: error: X11/xpm.h: No such file or directory make: *** Error 1”
yum install libXpm-dev libXpm
在配置gd2的时候多加一条 --with-xpm=/usr/lib
./configure 的时候 会发现
"Support for Xpm library : yes"这一项,说明配置成功。
php支持 mysqli,pdo-mysql
mysqlnd(专门为php写的),libmysqlclient(用c连接数据库用的,搞到php上来了)
http://php.net/manual/en/ref.pdo-mysql.php
nginx 发生permission deny
去看看php-fpm的用户配置,nginx的用户配置
当连接数据库的时候,我遇到这个问题了。后来发现,写127.0.0.1就可以连接,写localhost就不可以连接。mysql版本是 5.6.
create user 'root'@'localhost'的时候也有问题。总之搞不懂。
有人说和selinux有关。
http://blog.sina.com.cn/s/blog_a0d5a7f10101dzbc.html
lnmp环境的操作部分:
安装php+nginx:http://www.iyunv.com/simpman/p/4151662.html
安装mysql:http://www.iyunv.com/simpman/p/4192942.html
安装php:http://www.iyunv.com/simpman/p/4196051.html
lnmp环境的理论部分:
FastCgi与PHP-fpm关系[转] 读完本文瞬间明朗了很多 : http://www.iyunv.com/simpman/p/4151639.html
epoll和select区别:http://www.iyunv.com/simpman/p/4150005.html
扩展下载包:http://pan.baidu.com/s/1kTn7VQB
pycurl版本低:http://www.fireinfo.cn/content-11-63668-1.html
页:
[1]