php5217安装
A. 在网下载的php系统如何安装
你只装一个apache是不行的。PHP开发环境配置需要安装apache+mysql+php-5.4,这样配置起来比较麻烦,而且很容易出错的。建议你使用集成开发环境APMServer或者是wampserver。把php环境安装好之后把下载的php系统放到根目录。然后再浏览器上输入127.0.0.1\。
要是你下载的是cms之类的,那就先安装程序。(要是你解压之后文件夹里面有“install”文件夹,那么就需要先安装)127.0.0.1\install\index.php(DEDECMS是这个目录)
B. 如何在linux下安装多个不同版本的PHP
Linux (测试环境 Ubuntu 12.04 Server X86_64)
1. 安装编译工具及所需类库
$ sudo apt-get install build-essential gcc g++ autoconf libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev bzip2 libbz2-dev openssl libssl-dev curl libcurl4-openssl-dev libpcre3 libpcre3-dev libevent-1.4-2 libevent-dev libmcrypt4 libmcrypt-dev mcrypt libltdl-dev libldap2-dev libsasl2-dev libmhash-dev libc-client2007e libc-client2007e-dev
2. 安装MySQL
$ sudo apt-get install mysql-server libmysqlclient-dev
3. 安装PHP
Linux下多版本PHP共存需要自己手工编译安装。
下载PHP源文件到/opt/src目录
$ mkdir /opt/src
$ cd /opt/src
$ wget http://museum.php.net/php5/php-5.2.17.tar.bz2 -O php-5.2.17.tar.bz2
$ wget http://cn2.php.net/get/php-5.3.28.tar.bz2/from/this/mirror -O php-5.3.28.tar.bz2
$ wget http://cn2.php.net/get/php-5.4.29.tar.bz2/from/this/mirror -O php-5.4.29.tar.bz2
$ wget http://cn2.php.net/get/php-5.5.14.tar.bz2/from/this/mirror -O php-5.5.14.tar.bz2
创建PHP各版本安装目录
$ mkdir -p /opt/php/{5217,5328,5429,5514}
安装PHP 5.2.17
$ cd /opt/src
$ tar -xvjf php-5.2.17.tar.bz2
$ cd php-5.2.17
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libkrb5.so /usr/lib/libkrb5.so
$ wget -O debian_patches_disable_SSLv2_for_openssl_1_0_0.patch “https://bugs.php.net/patch-display.php?bug_id=54736&patch=debian_patches...”
$ patch -p1 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
$ ./configure --prefix=/opt/php/5217 --with-config-file-scan-dir=/opt/php/5217/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-mime-magic --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-recommended /opt/php/5217/lib/php.ini
安装PHP 5.3.28
$ cd /opt/src
$ tar -xvjf php-5.3.28.tar.bz2
$ cd php-5.3.28
$ ./configure --prefix=/opt/php/5328 --with-config-file-scan-dir=/opt/php/5328/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5328/lib/php.ini
安装PHP 5.4.29
$ cd /opt/src
$ tar -xvjf php-5.4.29.tar.bz2
$ cd php-5.4.29
$ ./configure --prefix=/opt/php/5429 --with-config-file-scan-dir=/opt/php/5429/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5429/lib/php.ini
安装PHP 5.5.14
$ cd /opt/src
$ tar -xvjf php-5.5.14.tar.bz2
$ cd php-5.5.14
$ ./configure --prefix=/opt/php/5514 --with-config-file-scan-dir=/opt/php/5514/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5514/lib/php.ini
4. 安装Apache
$ sudo apt-get install apache2
启用相应模块
$ a2enmod headers
$ a2enmod expires
$ a2enmod actions
$ a2enmod rewrite
5. 配置Apache
$ sudo vi /etc/apache2/httpd.conf
追加如下脚本映射和虚拟主机配置,原理同Windows的配置说明。
ServerName localhost
AddType application/x-httpd-php .php
ScriptAlias /php-5217/ "/opt/php/5217/bin/"
ScriptAlias /php-5328/ "/opt/php/5328/bin/"
ScriptAlias /php-5429/ "/opt/php/5429/bin/"
ScriptAlias /php-5514/ "/opt/php/5514/bin/"
<Directory /var/www/sites>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/sites/5217>
Action application/x-httpd-php "/php-5217/php-cgi"
</Directory>
<Directory /var/www/sites/5328>
Action application/x-httpd-php "/php-5328/php-cgi"
</Directory>
<Directory /var/www/sites/5429>
Action application/x-httpd-php "/php-5429/php-cgi"
</Directory>
<Directory /var/www/sites/5514>
Action application/x-httpd-php "/php-5514/php-cgi"
</Directory>
# Virtualhosts
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5217/test.local"
ServerName php5217.local
ErrorLog "/var/log/apache2/php5217.local-error.log"
CustomLog "/var/log/apache2/php5217.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5328/test.local"
ServerName php5328.local
ErrorLog "/var/log/apache2/php5328.local-error.log"
CustomLog "/var/log/apache2/php5328.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5429/test.local"
ServerName php5429.local
ErrorLog "/var/log/apache2/php5429.local-error.log"
CustomLog "/var/log/apache2/php5429.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5514/test.local"
ServerName php5514.local
ErrorLog "/var/log/apache2/php5514.local-error.log"
CustomLog "/var/log/apache2/php5514.local-access.log" common
</VirtualHost>
保存配置后,创建各站点的DocumentRoot目录,再往每个目录放置一个phpinfo的测试文件,完成后重启Apache服务器并在本地hosts文件加入域名解析,现在就可以访问各站点来测试多版本PHP共存了。
好了,基本的多版本PHP共存解决方案已经完成,如果还需要添加其他的PHP类库支持,后续自己再调用对应php目录下的pecl, php_config等脚本编译安装就可以了。
C. PHP 如何安装
从http://www.php.net网站下载WINDOWS版本的php压缩包或安装包
(如果是安装包,可以直接安装,则以下操作基本上可以忽略。但为了更好的安全性,建议采用压缩包自己安装配置有关参数)
2. 将下载的php5.0压缩包解压到指定位置,如为C:\PHP5
3. 在c:\php5文件夹中,用记事本打开文件php.ini-dist,修改如下内容后“另存为...”php.ini文件
(1)查找到safe_mode = 段落,将safe_mode = Off修改为safe_mode = On
(2)查找到expose_php = On段落,将expose_php = On修改为expose_php = Off
(3)查找到display_errors = On段落,将display_errors = On修改为display_errors = Off
(4)查找到extension_dir = 段落,设置动态库扩展的路径,如extension_dir = c:\php5\ext
(5)查找到 ; cgi.force_redirect = 1段落,修改为 cgi.force_redirect = 0
提示:(4)和(5)是必须做的。记着要另存为php.ini
4. 将编辑好的php.ini文件剪切到Windows安装文件夹下(如:C:\Winnt 或 C:\Windows)
5. 在IIS中,选择要使用PHP的站点,右键菜单中选择“属性”,选择“主目录”标签,在该界面中点“配置”,添加或重新编辑php扩展的“应用程序扩展名映射”,可执行文件选择为C:\php5\php5isapi.dll,扩展名为php,确定应用后退出IIS配置
6. 停止IIS的WEB站点,并重新启动该站点。
提示:如果是Windows 2003,应增加WEB扩展,将PHP置为允许
D. 怎么安装PHP环境
LAMP/LNMP 环境搭建
一.检查系统环境
1.确认centos版本
[root@localhost ~]# cat /etc/redhat-release
2.检查是否安装过apache
rpm -qa | grep httpd
或者:
apachectl -v
或者:
httpd -v
3.检查是否安装过Mysql
service mysqld start
如果未被识别则没有安装
如果系统安装过,或者安装失败,清理一下系统
4.清理Mysql痕迹
yum remove mysql
rm -f /etc/my.cnf
5.卸载Apache包
rpm -qa|grep httpd
注意:如果是新的系统或者你从来没有尝试安装过,则以上步骤省略
二.安装Apache、PHP、Mysql
停止防火墙服务
[root@localhost ~]# systemctl stop firewalld.service
禁用防火墙开机启动服务
[root@localhost ~]# systemctl disable firewalld.service
1.安装apache
[root@localhost ~]# yum -y install httpd
2.安装php
[root@localhost ~]# yum -y install php
3.安装php-fpm
[root@localhost ~]# yum -y install php-fpm
4.安装Mysql
[root@localhost ~]# yum -y install mysql
5.安装 mysql-server
[root@localhost ~]# yum install mariadb-server
CentOS 7+ 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了,entos7配置教程上,大多都是安装mariadb,因为centos7默认将mariadb视作mysql。
因为mysql被oracle收购后,原作者担心mysql闭源,所以又写了一个mariadb,这个数据库可以理解为mysql的分支。如果需要安装mariadb,只需通过yum就可。
6.安装 php-mysql
[root@localhost ~]# yum -y install php-mysql
三.安装基本常用扩展包
1.安装Apache扩展包
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
2.安装PHP扩展包
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel
3.安装Mysql扩展包
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
四.配置Apache、mysql开机启动
重启Apache、mysql服务(注意这里和centos6有区别,Cenots7+不能使用6的方式)
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
重启数据库
#启动MariaDB
[root@localhost ~]# systemctl start mariadb.service
#停止MariaDB
[root@localhost ~]# systemctl stop mariadb.service
#重启MariaDB
[root@localhost ~]# systemctl restart mariadb.service
#设置开机启动
[root@localhost ~]# systemctl enable mariadb.service
五.配置Mysql
初次安装mysql是没有密码的,我们要设置密码,mysql的默认账户为root
方式1:设置 MySQL 数据 root 账户的密码:
[root@localhost ~]# mysql_secure_installation
当出现如下提示时候直接按回车:
Enter current password for root
出现如下再次回车:
Set root password? [Y/n]
出现如下提示输入你需要设置的密码,这里输入了root,输入密码是不显示的,回车后再输入一次确认:
New password:
接下来还会有四个确认,分别是:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
直接回车即可。
方式2:进入mysql mysql -r
修改mysql密码:set password for 'root'@'localhost'=password('root');
mysql授权远程连接(navicat等): grant all on *.* to root identified by 'root';
六.测试环境
我们在浏览器地址栏输入http://ip/,正常显示,说明我们的lamp 环境搭建成功
七.安装nginx
yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
Nginx 版本号可变更http://nginx.org/packages/centos/7/noarch/RPMS/$版本
八.配置nginx
1.nginx启动,停止,重启
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重启
systemctl enable nginx.service #设置开机启动
更改nginx端口号(根据自己需求)
cd /etc/nginx/conf.d/
vim default.conf
把listen 80改成listen 81
3.访问http://ip:81即可看到nginx首页
安装完成访问时候需要启动php-fpm,不重启访问会出现下载文件,重启命令如下
systemctl start php-fpm.service #启动php-fpm
systemctl enable php-fpm.service #设置开机启动
4.更改nginx配置文件识别php
vi /etc/nginx/conf.d/default.conf,把之前的#给去掉就可以了,顺手改一下
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;
}
方法二 安装nginx
yum install nginx
启动nginx,并设置为开机启动
systemctl start nginx
systemctl enable nginx
5.在 /usr/share/nginx/html中新建一个test.php
访问http://ip:81/test.php即可看到php页面
修改完成配置记得启动apache 和php-fpm 哦!
九.负载配置
upstream site{
server 172.16.170.138;
server 172.16.170.139;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://site;
}
apache 默认目录 /var/www/html
nginx 默认目录 /usr/share/nginx/html
升级php版本
centos7 默认安装php是5.4
查看yum的可安装的php版本列表
yum provides php
开始升级PHP更新源:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum remove php-common -y #移除系统自带的php-common
php72版本
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring
php56版本
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring #安装依赖包
查看php版本
php -v
安装php fpm:
yum install php72w-fpm
yum provides php-fpm #因为我是准备搭建lnmp,所以安装php-fpm,这里会提示多个安装源,选择5.6版本的安装就可以了
yum install php56w-fpm-5.6.31-1.w7.x86_64 -y
systemctl start php-fpm.service 【启动】
systemctl enable php-fpm.service【开机自启动】
CentOS yum有时出现“Could not retrieve mirrorlist ”的解决办法——resolv.conf的配置
原因:没有配置resolv.conf
解决方法:
到/etc目录下配置resolv.conf加入nameserver IP,如:
nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain
保存再次运行上面的命令就可以。
https://blog.csdn.net/mao834099514/article/details/73470001
nginx目录 : /usr/share/nginx/html
/etc/nginx/conf.d/default.conf nginx配置目录
apache目录 : /var/www/html
/etc/httpd/conf/httpd.conf apache配置文件
nginx 配置域名
cd /etc/nginx
cp default.conf imooc.conf
修改server_name imooc.test.com 以及项目目录
配置虚拟域名 windows 访问需要在host增加 linuxip
ServerName www.nine.com
DocumentRoot "/var/www/html/learnlaravel/public"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
关闭防火墙
setenforce 0
E. linuxphp网站怎么安装
配置php服务
安饥塌装yasm汇编器(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfyasm-1.2.0.tar.gz
[root@linuxprobesrc]cdyasm-1.2.0
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安装libmcrypt加密算法扩展库(解烂银圆压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibmcrypt-2.5.8.tar.gz
[root@linuxprobesrc]cdlibmcrypt-2.5.8
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安装libvpx视频编码器(解压与编译过程搏旦已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarxjvflibvpx-v1.3.0.tar.bz2
[root@linuxprobesrc]cdlibvpx-v1.3.0
[[email protected]]./configure--prefix=/usr/local/libvpx--enable-shared--enable-vp9
[[email protected]]make
[[email protected]]makeinstall
安装Tiff标签图像文件格式(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvftiff-4.0.3.tar.gz
[root@linuxprobesrc]cdtiff-4.0.3
[[email protected]]./configure--prefix=/usr/local/tiff--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装libpng图片(png格式)函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibpng-1.6.12.tar.gz
[root@linuxprobesrc]cdlibpng-1.6.12
[[email protected]]./configure--prefix=/usr/local/libpng--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装freetype字体引擎(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvffreetype-2.5.3.tar.gz
[root@linuxprobesrc]cdfreetype-2.5.3
[[email protected]]./configure--prefix=/usr/local/freetype--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装jpeg图片(jpeg格式)函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfjpegsrc.v9a.tar.gz
[root@linuxprobesrc]cdjpeg-9a
[root@linuxprobejpeg-9a]./configure--prefix=/usr/local/jpeg--enable-shared
[root@linuxprobejpeg-9a]make
[root@linuxprobejpeg-9a]makeinstall
安装libgd图像处理程序(解压与编译过程已省略):
[root@linuxprobejpeg-9a]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibgd-2.1.0.tar.gz
[root@linuxprobesrc]cdlibgd-2.1.0
[[email protected]]./configure--prefix=/usr/local/libgd--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/tiff--with-vpx=/usr/local/libvpx
[[email protected]]make
[[email protected]]makeinstall
安装t1lib图片生成函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvft1lib-5.1.2.tar.gz
[root@linuxprobesrc]cdt1lib-5.1.2
[[email protected]]./configure--prefix=/usr/local/t1lib--enable-shared
[[email protected]]make
[[email protected]]makeinstall
将函数库文件放至合适的位置:
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so
[root@linuxprobesrc]cp-frp/usr/lib64/libXpm.so*/usr/lib/
安装php服务程序(命令比较长,请一定要复制完整!!!):
[root@linuxprobesrc]tar-zvxfphp-5.5.14.tar.gz
[root@linuxprobesrc]cdphp-5.5.14
[[email protected]]exportLD_LIBRARY_PATH=/usr/local/libgd/lib
[[email protected]]./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype
[[email protected]]make
[[email protected]]makeinstall
复制php服务程序的配置文件到安装目录:
[[email protected]]cpphp.ini-proction/usr/local/php/etc/php.ini
删除默认的php配置文件:
[[email protected]]rm-rf/etc/php.ini
创建php配置文件的软连接到/etc/目录中:
[[email protected]]cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php.ini/etc/php.ini
编辑php服务程序的配置文件:
[[email protected]]vim/usr/local/php/etc/php-fpm.conf
//将第25行参数前面的分号去掉。
pid=run/php-fpm.pid
//修改第148和149行,将user与group修改为www。
user=www
group=www
添加php-fpm服务程序到开机启动项:
[[email protected]]cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm
[[email protected]]chmod+x/etc/rc.d/init.d/php-fpm
[[email protected]]chkconfigphp-fpmon
为了保障网站的安全性,禁用掉不安全的功能:
[[email protected]]vim/usr/local/php/etc/php.ini
//修改第305行的disable_functions参数,追加参数为:
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
配置nginx服务程序支持php:
[[email protected]]vim/usr/local/nginx/conf/nginx.conf
//将第2行前面的号去掉并修改为userwwwwww;
//将第45行参数修改为indexindex.htmlindex.htmindex.php;
//将第65-71行前面的号去掉,修改为:
location~.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
重启nginx与php-fpm服务程序:
[[email protected]]systemctlrestartnginx
[[email protected]]systemctlrestartphp-fpm
F. 如何安装PHP模块
php模块安装的方式
1、静态安装
将先将在安装php之前先将需要安装的程序装上,如ftp、mhash、mcrypt……安装完成后,解压php安装包,执行./configure
--with-ftp
--with-mhash
--wth-mcrypt等等。后面具体跟的参数可以参看./configure
--help查看。编译好后,执行make
&&
make
install
就行了。
2、动态安装
而在往往我们进行编译php时经常会忘记添加某扩展,后来想添加扩展,但是因为安装php后又装了一些东西如PEAR等,不想再重新装php,于是可以采用phpize来动态加载需要安装的模块。
具体实现方法如下(这里以忘记安装pdo_mysql模块为例):
cd
/root/source/php-5.3.10/ext/pdo_mysql
/usr/local/php/bin/phpize
在安装完mysql后,并不是进入/root/source/mysql-5.5.21目录运行phpize,而是进入php的源文件中要增加的扩展模块的文件目录---也就是/root/source/php-5.3.10/ext/pdo_mysql目录执行phpize。如果不是这样操作的话就会提示下面的错误:
Cannot
find
config.m4.
Make
sure
that
you
run
'/usr/local/php/bin/phpize'
in
the
top
level
source
directory
of
the
mole
关于上面的这个错误,我不得不鄙视下网上有些自以为是的家伙,自认为对所有的安装操作很懂,报上面的错误的时候,去修改源代码,搞的乱七八糟,误人子弟。根本不按php官方的文档操作。
目录/root/source/php-5.3.10/ext/pdo_mysql
,在运行phpize命令前并没有configure文件,只有config.m4文件。运行phpize就生成了一个可执行的configure文件。此时就可以按照下的方法编译了:
./configure
--with-php-config=/usr/bin/php-config
(还可以加一些其他的参数,可通过./configure
--help查看)
make
make
install
编译完成后会提示扩展模块生成在/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626目录。
修改php.ini文件
vi
/usr/local/php/etc/php.ini
在其文件结尾加入下面的内容:
extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
extension=pdo_mysql.so
安装完成后,重启php-fpm和web服务器。(因为我用的是php-fpm和tengine,如果用的是apache则也重启相应的程序,重新加载就行了)
G. 如何在Windows7环境下安装 PHP
方法/步骤
1、请先下载相关工具。根据自己系统下载相应版本,我下载的都是64位。
2、首先安装PHPManagerForIIS,安装成功后会IIS界面会多出PHPManager图标,等待后续操作。
3、将下载的PHP 7.0.2 for win解压并确定好要放置的位置。我这里放到C盘根目录下并改名为PHP 7.0.2。可根据自己需要进行调整。
4、将php.ini-development拷贝至C盘windows文件夹下,改名为php.ini;将extension_dir = "D:\PHP 7.0.2\ext"——实际对应EXT文件夹的位置。
5、此时重新打开IIS中的PHPManager管理界面,选择安装PHP。图中是安装后的效果,没安装时只有这个选项可用。安装时选择PHP文件夹下的PHP-CGI.exe文件即可。
6、此时可以尝试运行PHP文件夹下的php可执行文件,如果没有报错就OK。如果报错说VCRUNTIME140.DLL丢失,就是电脑缺少Visual C++Redistributable环境这时候就要用到vc_redist.x64(你的电脑也许是vc_redist.x86),微软官方下载安全可靠...安装完成后就OK了,可以开始你的PHP之旅了。