phpnginx安装
A. linux怎么快速安装nginx和php,不用安装数据库
Linux下如果要搭建nginx和php环境,需要安装三个软件包:
nginx,php,php-fpm
比如说如果是centos的话:
yuminstallnginxphpphp-fpm
可能软件包名有差别,这个查查就知道了。
然后配置nginx,修改nginx.conf,如果用sock就这样写,如果是端口就些端口:
location~.php${
fastcgi_passunix:/var/run/php-fpm/php-fpm.sock;
fastcgi_indexindex.php;
includefastcgi.conf;
}
然后启动服务,以centos7为例:
systemctlstartnginx
systemctlstartphp-fpm
B. windows7配置Nginx+php+mysql的详细操作是怎样
在Windows下配置搭建PHP环境的步骤:
一、准备工作-下载所需软件
Apache httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
PHP php-5.3.10-Win32-VC9-x86.zip
MySQL mysql-5.5.20-win32.msi
二、安装软件
1、安装Apache: 双击安装,与安装其他Windows软件没有什么区别,在填Server Infomation时,并没有特殊规定,只要输入的信息符合格式即可。
安装完成之后,在浏览器输入http://localhost,如果显示It Works!,表示Apache安装成功。
2、安装PHP:将php-5.3.10-Win32-VC9-x86.zip解压到一个目录即可。
3、安装MySQL:双击答桐安装,如果需要更改安装目录,则在Choose Setup Type选择Custom
安装完成后开肆举迅始配置MySQL,全部保持默认选项即可,但最好把MySQL默认编码改为utf8,在Modify Security Settings选项中设置密码,输入两次密码即可完成,最后点Execute完成配置。
三、整合Apache+PHP+MySQL
Apache : 首先修改Apache的配置文件,让Apache支持解析裂此PHP文件。Apache配置文件在Apache安装目录的conf目录下的httpd.conf。
1. 让Apache可以解析php文件,在配置文件中找到
#LoadMole vhost_alias_mole moles/mod_vhost_alias.so
在下一行添加 (绿色的位置是根据PHP的所在目录而定的)
LoadMole php5_mole "D:/Develop/PHP/php5apache2_2.dll"PHPIniDir "D:/Develop/PHP"AddType application/x-httpd-php .php .html .htm
2. 在配置文件中找到
DirectoryIndex index.html
改为
DirectoryIndex index.php index.html
3. 修改Apache站点目录,在配置文件中找到(Apache安装的目录不同,显示的值不一样)
DocumentRoot "D:/Develop/Apache2.2/htdocs"
改为
DocumentRoot "D:/Workspace/PHP"
再找到
<Directory "D:/Develop/Apache2.2/htdocs">
改为
<Directory "D:/Workspace/PHP">
PHP : 把php.ini-development改名为php.ini,作为PHP的配置文件。修改php.ini
1. 设置PHP扩展包的具体目录,找到
; On windows:; extension_dir = "ext"
改为 (值是ext文件夹的目录)
; On windows: extension_dir = "D:/Develop/PHP/ext"
2. 开启相应的库功能,找到需要开启的库的所在行
;extension=php_curl.dll
;extension=php_gd2.dll
;extension=php_mbstring.dll
;extension=php_mysql.dll
;extension=php_xmlrpc.dll
去掉前面的分号(注释),即改为
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_xmlrpc.dll
3. 设置时区,找到
;date.timezone =
改为
date.timezone = Asia/Shanghai
配置完成,检测一下配置是否成功。重启Apache,在站点目录下新建文件index.php,输入内容。
C. 如何架设Nginx+Php Web服务器
由于每个过程较繁琐,所以这里说说具体步骤,每个步骤的具体内容可以网络搜索。
安装步骤
一、 编译安装PHP5.2.9所需的支持库
二、编译安装MySQL 5.1.34扩展库
三、编译安装PHP(FastCGI模式)
四、修改php-fpm配置文件
五、创建www用户组及www用户
六、编译安装Nginx
七、创建fcgi.conf文件
八、编辑Nginx配置文件
九、配置开机自动启动Nginx + PHP
十、优化Linux内核参数
D. ubuntu 14.04安装nginx+php+mysql
本文将详细指导如何在Ubuntu 14.04上搭建Nginx、PHP、MySQL环境,以解决旧资料可能带来的困扰。操作步骤均通过命令行进行,确保环境的稳定性与高效性。
首先,为方便后续操作,切换到root权限模式。
通过以下命令安装系统所需的管理工具、添加Nginx与PHP的安装源:
1. sudo su
2. apt-get install python-software-propertiesadd-apt-repository ppa:nginx/stableadd-apt-repository ppa:ondrej/php5
接着,更新系统软件库并安装MySQL服务器。
3. apt-get update
4. apt-get install mysql-server
随后,安装PHP及其相关的MySQL支持组件。
5. apt-get install php5 php5-fpm php5-mysql php-apc
针对实际需求,可以自选安装PHP的各类功能模块,包括:
6. apt-get install php-pear php5-dev php5-curl
7. apt-get install php5-gd php5-intl php5-imagick
8. apt-get install php5-imap php5-mcrypt php5-memcache
9. apt-get install php5-ming php5-ps php5-pspell
10. apt-get install php5-recode php5-snmp php5-sqlite
11. apt-get install php5-tidy php5-xmlrpc php5-xsl
完成PHP组件的安装后,安装Nginx作为Web服务器。
12. apt-get install nginx
针对PHP配置文件进行调整,以优化Nginx与PHP-FPM的交互。
13. vi /etc/php5/fpm/php.ini
将cgi.fix_pathinfo=1更改为cgi.fix_pathinfo=0
然后,对Nginx的配置文件进行调整,以正确识别并处理PHP文件。
14. mkdir /www
15. chmod 755 /www
创建并设置权限为755的/www目录。
16. vi /etc/nginx/sites-enabled/default
将root路径更改为root /www,并在index文件中增加index.php
17. 在location配置中,调整fastcgi参数,包括尝试文件和fastcgi传递路径,确保正确解析PHP文件。
18. 解决Nginx与PHP-FPM之间的小bug,通过在fastcgi_params配置文件中添加指定参数,以正确传递文件路径。
19. 重启所有相关服务,包括php5-fpm与nginx,以应用新配置。
20. vi /www/index.php,创建测试文件并添加PHP代码,用于验证环境配置。
21. 访问http://localhost测试环境,如能正常输出PHP环境信息,表明搭建成功。
E. centos5 婧愮爜瀹夎匩ginx + mysql + apache + php镄勬柟娉
涓昏佷緷镦х殑鏄寮犲寸殑涓绡囧崥鏂囥http://blog.s135.com/post/366/銆嬶纴瀹夎呯殑杞浠舵槸涔熸槸浠庝粬鎻愪緵镄勫垪琛ㄤ腑涓嬭浇锛岃繖閲岄兘鏄痶ar.gz镙煎纺锛屽傛灉镟村笇链涙槸rpm镙煎纺镄勮瘽锛屾彁渚涗竴涓缃戝潃銆http://rpmfind.net/linux/rpm2html/search.php銆嬭繖閲屽垪鍑轰简姣旇缉瀹屽叏镄勪笅杞藉寘銆
鎴戝畨瑁呯殑绯荤粺锛欳entos5
1銆佷笅杞斤绂
鎴戝畨瑁呯殑涓嬭浇𨱒ヨ嚜寮犲村崥鏂囦笅镄勫湴鍧锛屼笅杞戒缭瀛樼殑鏄痟ome涓嬭嚜宸辩洰褰旷殑涓涓鏂囦欢澶逛笅锛
澶嶅埗浠g爜
浠g爜濡备笅:
cd /home/xuxx/software
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.7.51.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.8-fpm-0.5.10.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.33.zip
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz
2銆佸嗳澶囩紪璇戝畨瑁呯幆澧冿纴闇瑕佺紪璇戞簮镰佺敤鍒癵c++
寤鸿濡傛灉鏄鏂板畨瑁呯殑绯荤粺锛屼娇鐢▂um upgrade镟存柊涓嬬郴缁熴
澶嶅埗浠g爜
浠g爜濡备笅:
sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
openldap openldap-devel nss_ldap openldap-clients openldap-servers
娉ㄦ剰锛氲繖閲屾墍链夌殑锻戒护鏄涓琛岀殑钥屼笉鑳芥湁鎹㈣岀︼纴濡傛灉鏄痗opy镄勬椂鍊欙纴娉ㄦ剰瑕佸幓澶勮ユ崲琛岀
纭淇濆畨瑁呮垚锷燂紒镓嶈兘姝g‘浣跨敤缂栬疟銆
3銆佸畨瑁咃细
涓銆佸畨瑁匬HP 5.2.8锛团astCGI妯″纺锛
1銆佺紪璇戝畨瑁匬HP 5.2.8镓闇镄勬敮鎸佸簱锛
1锛 libiconv搴
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make
make install
make clean
make distclean
cd ../
make clean 鍜宫ake distclean閮芥槸鍒犻櫎瀹夎呰繃绋嬩腑鐢熸垚镄勭紦瀛樻枃浠躲傚綋铹跺傛灉浣犱笉浠嬫剰鏀剧潃涔熷彲浠ヨ烦杩囱繖涓ゆユ竻鐞嗘搷浣溿
2锛絣ibmcrypt搴
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
make clean
make distclean
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
make clean
make distclean
cd http://www.cnblogs.com/
3] mhash搴
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
4锛絤crypt搴
娉ㄦ剰锛氩洜涓鸿ュ簱鍜宭ibmcrypt链変緷璧栨э纴镓浠ュ湪瀹夎呭墠蹇呴’鐭ラ亾libmcrypt锛屽惁鍒欑殑璇濅细鍑虹幇锛
阌栾
澶嶅埗浠g爜
浠g爜濡备笅:
checking for libmcrypt 钬 version = 2.5.0钬
*** 钬榣ibmcrypt-config 钬捣ersion钬 returned 2.4.0, but LIBMCRYPT (2.5.8)
*** was found! If libmcrypt-config was correct, then it is best
*** to remove the old version of LIBMCRYPT. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
*** /etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG
*** to point to the correct of libmcrypt-config, and remove the file config.cache
*** before re-running configure
configure: error: *** libmcrypt was not found
鏄锲犱负path镄勯梾棰桡纴镓浠ユ墽琛岋细
澶嶅埗浠g爜
浠g爜濡备笅:
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
铹跺悗鍐嶅畨瑁咃细
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
浜屻佸畨瑁卪ysql
澶嶅埗浠g爜
浠g爜濡备笅:
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql xxx
unzip mysql-5.1.33.zip
cd mysql-5.1.33/
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables
--with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
make
make install
make clean
make distclean
chmod +w /usr/local/webserver/mysql
chown -R xxx:mysql /usr/local/webserver/mysql
cp support-files/my-medium.cnf.sh /usr/local/webserver/mysql/my.cnf
cd ../
娉ㄦ剰锛氲繖閲岀紪璇./configure锻戒护鏄涓琛岀殑钥屼笉鑳芥湁鎹㈣岀︼纴濡傛灉鏄痗opy镄勬椂鍊欙纴娉ㄦ剰瑕佸幓澶勮ユ崲琛岀
鍦ㄦ渶钖庝竴姝ユ嫹璐濈殑镞跺欙纴鎴戝畨瑁呭畬鍦╯upport-files涓嬫病链尘y-medium.cnf钥屽彧链尘y-medium.cnf.sh镓浠ュ皢杩欎釜鏂囦欢𨰾疯礉杩囧幓銆
锛犲紶瀹村师鏂囷细
闄勶细浠ヤ笅涓洪梼锷犳ラわ纴濡傛灉浣犳兂鍦ㄨ繖鍙版湇锷″櫒涓婅繍琛孧ySQL鏁版嵁搴掳纴鍒欐墽琛屼互涓嬩袱姝ャ傚傛灉浣犲彧鏄甯屾湜璁㏄HP鏀鎸丮ySQL镓╁𪾢搴掳纴鑳藉熻繛鎺ュ叾浠栨湇锷″櫒涓婄殑MySQL鏁版嵁搴掳纴闾d箞锛屼互涓嬩袱姝ユ棤闇镓ц屻
鈶犮佷互xxx鐢ㄦ埛甯愬彿镄勮韩浠藉缓绔嬫暟鎹琛锛
澶嶅埗浠g爜
浠g爜濡备笅:
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=xxx
鈶°佸惎锷∕ySQL锛堟渶钖庣殑琛ㄧず鍦ㄥ悗鍙拌繍琛岋级
澶嶅埗浠g爜
浠g爜濡备笅:
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf
3銆佺紪璇戝畨瑁匬HP锛团astCGI妯″纺锛
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf php-5.2.8.tar.gz
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
cd php-5.2.8/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem
--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap
--with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
娉ㄦ剰锛氲繖閲./configure锻戒护鏄涓琛岀殑钥屼笉鑳芥湁鎹㈣岀︼纴濡傛灉鏄痗opy镄勬椂鍊欙纴娉ㄦ剰瑕佸幓澶勮ユ崲琛岀
4銆佺紪璇戝畨瑁匬HP5镓╁𪾢妯″潡--鍙阃夊畨瑁
澶嶅埗浠g爜
浠g爜濡备笅:
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
make clean
make distclean
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
make clean
make distclean
cd ../
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
5銆佷慨鏀筽hp.ini鏂囦欢
STRONG镓嫔伐淇鏀癸细/STRONG镆ユ垒/usr/local/webserver/php/etc/php.ini涓镄别xtension_dir = "./"
淇鏀逛负extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
骞跺湪姝よ屽悗澧炲姞浠ヤ笅鍑犺岋纴铹跺悗淇濆瓨锛
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
鍐嶆煡镓紧utput_buffering = Off
淇鏀逛负output_buffering = On
6銆侀厤缃甧Accelerator锷犻烶HP锛
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
鎸塻hift+g阌璺冲埌閰岖疆鏂囦欢镄勬渶链灏撅纴锷犱笂浠ヤ笅閰岖疆淇℃伅锛
澶嶅埗浠g爜
浠g爜濡备笅:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
淇鏀归厤缃鏂囦欢锛
vi /etc/sysctl.conf
kernel.shmmax = 134217728
铹跺悗镓ц屼互涓嫔懡浠や娇閰岖疆鐢熸晥锛/sbin/sysctl -p
浠ヤ笅镄勬ラゅ拰寮犲存ラや腑涓镙烽厤缃锛屼笉鍐嶈禈璇