centosphp55安装
1. centos 如何安装最新php
一般服务器都加装防火墙,所以第一步要暂停防火墙,否则连接不到相关外网和程序源
Centos 6.默认下没有安装php组件,因此我们需要输入命令:yum -y install php 回车如下图。
不用管,程序会自动完成安装及配置。
Zend组件,Centos 6.3 里面是没有的,需要手动下载,及安装教程请点击下面链接:http://www.juxiwang.com/read-tid-2982.html
到此前期的准备工作已完成,下面就要对Apache进行配置
输入命令:vi /etc/httpd/conf/httpd.conf //打开Apache配置文件,
找到ServerTokens OS将“OS”改为“Prod “ 。//显示服务器运行错误信息。与下图一样,那么Apache你就配置成功了,如果不一样请仔细对比上面的教程是不是那个步骤少了#及字母拼写错了。
到此php运行环境便配置成功啦。
启动http, /etc/rc.d/init.d/httpd start
输入命令:vi /var/www/html/test.php 在弹出的对话框里输入信息:<?phpphpinfo();?>保存退出。然后通过你的浏览器输入:http://127.0.0.1/test.php如出现下图界面,恭喜里php运行环境你配置成功啦。
有时由于httpd.conf没有正确配置,本想浏览php文件,实际是下载了php文件,这个是因为系统没有识别php文件,所以就认为你要下载了。
修改方法: 检查你的httpd.conf当中是否有以下几行LoadMole php5_mole d:\php5\php5_apache2.dll (windows系统)
或LoadMole php5_mole /usr/libexec/apache2/php5.so(或者是libphp5.so)(linux系统)||||||根据你的平台而定,实际路径也因环境而异增加AddType application/x-httpd-php .php|||||||增加DirectoryIndex index.php index.html。一定可以ok
另,如果遇到启动httpd时出现报错信息,httpd: apr_sockaddr_info_get() failed for shiweihttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName,原因是没有设定ServerName
解决办法:
1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80
(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)
还有可能遇到的问题,linux系统里存在多个httpd.conf文件,你不知道是哪个在起作用,那么service httpd restart 启动后,用ps -ef|more看http用的是什么进程,如果是、usr/sbin就用/usr/sbin/httpd -S命令,如果是/usr/local/apache2/bin/httpd,就用/usr/local/apache2/bin/httpd -S。看是启动了哪个,httpd。conf文件启动时是唯一的。
2. centos下,我怎么安装php和apache
查看是否有RPM包安装的这两个软件
rpm -qa |grep httpd #查看是否安装APACHE
rpm -qa |grep hph #查看是否安装php
如果有安装的话执行上两条命令时会显示已相应经安装的文件名,如果什么都没显示的话就说明没有安装
查看是否有编译安装的这两个软件
find / -name apaceh
find / -name php
如果有安装的话会有文件显示,没有显示的话说明没安装
要安装这两个软件最方便的就是将这台机器连上网然后执行以下两条命令
yum install apache
yum install php
3. centos6.5怎么安装php5.5
1.******已安装Nginx******
ps -aux | grep nginx
netstat -anptu | grep 80
2.清除系统中php痕迹:
yum remove php
rm -rvf /etc/php
rm -rvf /etc/php.ini
rm -f /usr/bin/php
3.安装php所需软件包:
tar zxvf autoconf-2.68.tar.gz -C /usr/src
cd /usr/src/autoconf-2.68/
./configure && make && make install
tar zxvf libiconv-1.14.tar.gz -C /usr/src
cd /usr/src/libiconv-1.14/
./configure && make && make install
tar zxvf libmcrypt-2.5.8.tar.gz -C /usr/src
cd /usr/src/libmcrypt-2.5.8/
./configure && make && make install
ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
tar zxvf mhash-0.9.9.9.tar.gz -C /usr/src
cd /usr/src/mhash-0.9.9.9/
./configure && make && make install
tar zxvf mcrypt-2.6.8.tar.gz -C /usr/src
cd /usr/src/mcrypt-2.6.8/
./configure && make && make install
4.加载php动态模块:
ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8
/usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1
/usr/lib64/libmhash.so.2.0.1
cp -R /usr/lib64/libpng.* /usr/lib/
cp -R /usr/lib64/libjpeg.* /usr/lib/
echo "/lib" >> /etc/ld.so.conf
echo "/usr/lib" >> /etc/ld.so.conf
echo "/usr/lib64" >> /etc/ld.so.conf
echo "/usr/local/lib" >> /etc/ld.so.conf
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nproc 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo "fs.file-max=65535" >> /etc/sysctl.conf
ldconfig
5.解压、配置、编译、安装php:
tar zxvf php-5.5.25.tar.gz -C /usr/src
cd /usr/src/php-5.5.25/
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--enable-opcache \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo
make ZEND_EXTRA_LIBS='-liconv'
make install
6.链接php可执行文件:
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/phpize /usr/bin/phpize
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm
7.编辑php.ini配置文件:
cp /usr/src/php-5.5.25/php.ini-proction
/usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
vim /etc/php.ini
[PHP]
engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision
= 12
y2k_compliance = On
output_buffering = On
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func=
serialize_precision = 100
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket
disable_classes =
expose_php = On
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = Off
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
variables_order = "EGPCS"
register_globals = Off
register_long_arrays = Off
register_argc_argv = On
auto_globals_jit = On
post_max_size = 50M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
extension_dir =
"/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"
enable_dl = On
cgi.fix_pathinfo=0
file_uploads = On
upload_max_filesize = 50M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[Date]
date.timezone = PRC
[filter]
[iconv]
[sqlite]
[Pcre]
[Syslog]
define_syslog_variables = Off
[mail function]
SMTP = localhost
smtp_port = 25
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mSQL]
msql.allow_persistent = On
msql.max_persistent = -1
msql.max_links = -1
[OCI8]
[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase]
sybase.allow_persistent = On
sybase.max_persistent = -1
sybase.max_links = -1
sybase.min_error_severity = 10
sybase.min_message_severity = 10
sybase.compatability_mode = Off
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Informix]
ifx.default_host =
ifx.default_user =
ifx.default_password =
ifx.allow_persistent = On
ifx.max_persistent = -1
ifx.max_links = -1
ifx.textasvarchar = 0
ifx.byteasvarchar = 0
ifx.charasvarchar = 0
ifx.blobinfile = 0
ifx.nullformat = 0
[Session]
session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor
= 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=,fieldset="
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[FrontBase]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
[Zend Optimizer]
zend_extension =
/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
zend_loader.enable = 1
zend_loader.disable_licensing = 0
zend_loader.obfuscation_level_support = 3
8.编辑php-fpm.conf配置文件:
cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
[global]
pid = /home/php/pid/php-fpm.pid
error_log = /home/php/log/php-fpm_error.log
log_level = notice
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /home/php/log/slow.log
9.编写php-fpm启动脚本
vim /etc/init.d/php-fpm
#!/bin/sh
# chkconfig:
2345 90
10
#
Description:
Start and
Stop php-fpm
# Provides:
php-fpm
#
Default-Start:
2 3 4 5
#
Default-Stop:
0 1 6
prefix=/usr/local/php
exec_prefix=${prefix}
php_fpm_BIN=${prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=/home/php/pid/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php-fpm..."
$php_fpm_BIN --daemonize $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Stoping php-fpm..."
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
10.创建目录并修改权限,重启nginx服务:
mkdir -p /home/php/log
mkdir -p /home/php/pid
chown -R www:www /home/php/log
chown -R www:www /home/php/pid
service nginx restart
11.添加php-fpm系统服务:
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig --level 2345 php-fpm on
chkconfig --list | grep php-fpm
12.启动php-fpm服务:
service php-fpm start
ps -aux | grep php-fpm
netstat -anptu | grep 9000
13.配置php测试页:
vim /home/www/html/phpinfo.php
4. centos下安装php
yum install -y php
## 这个只安装PHP
## 建议安装运行库及MySQL的支持
yum install -y php php-devel php-mysql
## 如果你的系统是CentOS 5.6那么上面这条命令安装的是PHP 5.1,要安装 PHP 5.3则执行下面的命令:
yum install -y php53 php53-devel php53-mysql
5. 关于CENTOS上编译安装PHP5的问题,求教
Centos编译安装PHP 5.5笔记
Written by 一像素 on 2013年十月25日
本篇是在 Centos 6.4 32bit 下编译安装 php 5.5.5 的笔记,接上篇 Centos编译安装Apache 2.4.6笔记。php 5.5.x 和 centos 源里面的 php 5.3.x 之间的性能差异见升级到 PHP 5.5.x + opcache。
首先是编译准备工作:
yum groupinstall "Development tools"
然后是编译安装 PHP 5.5.x 需要用到的 devel 包:
yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
从官方下载,解压:
wget http://us3.php.net/get/php-5.5.5.tar.gz/from/cn2.php.net/mirror
tar -xvf php-5.5.5.tar.gz
cd php-5.5.5
编译安装 php 5.5 的参数:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-cli --enable-shared --with-libxml-dir --with-gd --with-openssl --enable-mbstring --with-mcrypt --with-mysqli --with-mysql --enable-opcache --enable-mysqlnd --enable-zip --with-zlib-dir --with-pdo-mysql --with-jpeg-dir --with-freetype-dir --with-curl --without-pdo-sqlite --without-sqlite3
我已经尽量的在参数上做了精简,用以上参数编译安装好的 php 运行 wordpress, joomla, ip board 等常见的博客、论坛程序都是没有问题的,因为有了 --disable-cli,所以就没法 make test 了,安装好以后也没法 php -v 了。安装吧:
make
make install
cp php.ini-proction /usr/local/lib/php.ini
#记住上面 php.ini 的位置哦。
是时候让 apache 知道有 php 的存在了,在 apache 配置文件 httpd.conf 中添加:
LoadMole php5_mole moles/libphp5.so
#上面那行可能在编译安装 php 的过程中已经由系统自动添加了
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
OK!重启 apache,人品好的人是不会出现问题的。
Tags: LAMP
Comments
# jieweiwo 2015-08-26 19:20
为啥我编译安装之后没有bin目 录 控制台无法执行
Reply
# 一像素 2015-08-26 19:53
编译参数里面的 --disable-cli 去掉。
Reply
# jieweiwo 2015-08-26 23:37
非常感谢你的教程!那这个编译安 装的php是不是就能应付一般的 的开发了 没有安装的特性以后需要怎么办?
Reply
# 一像素 2015-08-26 23:40
需要什么再 --enable-xxx 就好了呀,不过真看不出还需要啥 了...俺不搞开发...
6. linux centos 7 下用yum 安装iso镜像里自带的php5.4.16版本的但是没有php-fqm文件不知道怎么重启php服务
systemctl restart php-fpm.service #这条命令是重启php服务
下面是一个比较靠谱的php安装步骤:
先删除已有的php版本 ,执行下面的命令删除php
yum remove php-common
然后像安装那样问你是否继续的,输入yes即可
添加 yum 源
CentOS 6.x 的源
# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装 PHP
# yum install --enablerepo=remi,remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
注:安装5.6版本为remi-php56,安装5.5版本为remi-php55
7. 如何在centos上安装php
.1 安装Apahce, PHP, MySQL以及php连接mysql库组件。 #yum -y install httpd php mysql mysql-server php-mysql 2. 安装apache扩展 #yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql 3. 安装php的扩展 #yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc 4. 安装MySQL的扩展 #yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
遇到类似的问题,你可以去后盾人平台看看的哦,里面的东西不错应该能帮你解决一些不明白的问题(❁´◡`❁)*
8. centos 如何检测php安装
需要准备的材料分别是:电脑、centos主机,linux连接工具。
1、首先连接上centos主机,进入等待输入指令的linux命令行状态。
9. 如何在CentOS上安装phpMyAdmin
cd /etc/yum.repos.d/
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum clean all
yum makecache
yum -y install --enablerepo=rpmforge phpmyadmin
10. 如何在centos7上安装php
您好,安装PHP的方式可以一步一步的按照教程去安装,这个可以到网上搜一搜,因为步骤太多,我就不复制粘贴了。但是我这里最推荐的就是使用phpstudy一键安装,没错,就是在Linux上一键安装,可以去试一试。
黑马程序员的PHP是国内最早开设的真正人工智能课程。课程全面系统,紧跟时代潮流。