当前位置:首页 » 编程语言 » centos65配置php

centos65配置php

发布时间: 2022-07-29 00:00:19

❶ 如何在centos上布置php网站环境

安装apache:
yum install httpd httpd-devel
启动apache:
/etc/init.d/httpd start
此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口

安装mysql:
yum install mysql mysql-server
启动mysql:
/etc/init.d/mysqld start

安装php
yum install php php-devel
重启apache使php生效
/etc/init.d/httpd restart
此时可以在目录:/var/www/html/下建立一个PHP文件
代码:
<?php phpinfo(); ?>
然后访问这个文件,就能看到PHP的一些信息,php.ini配置文件的路径可以在这个页面上看到

安装php的扩展
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装完扩展之后需要再次重启apache
/etc/init.d/httpd restart

测试mysql是否链接成功的php代码
<?php
$con = mysql_connect("10.0.@.@@","@@","@@");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mydb", $con);

$result = mysql_query("SELECT * FROM sys_user");

while($row = mysql_fetch_array($result))
{
echo $row['UserName'] . " " . $row['PassWord'] . " " . $row['id'];
echo "<br />";
}

mysql_close($con);
?>
可以把上面的代码传入目录/var/www/html/

❷ centos的ip用php怎么设置

使用VirtualBox装了很多虚拟机,默认采用的DHCP的方式,但是随着虚拟机越来越多以后,这种方式很不方便,所以需要将机器的IP都Centos设置静态IP需要添加的几项内容的解释:
IPADDRIP地址
NETMASK子网掩码
NETWORK网关地址

通常,如果我们想更改主机地址为静态地址或者更改主机名,需要修改的几个文件包括:
/etc/sysconfig/network Centos设置主机名和网络配置
/etc/sysconfig/network-scripts/ifcfg-eth0针对特定的网卡进行设置
/etc/resolv.conf设置DNS
/etc/hosts设置指定的域名解析地址

一般我们只需要修改网卡的Centos配置文件就可以了,例如我的Centos配置文件如下:
DEVICE=eth0
BOOTPROTO=static
TYPE=Ethernet
NAME="System etho0"
BROADCAST=192.168.56.255
HWADDR=08:00:27:24:F8:9B
IPADDR=192.168.56.101
IPV6INIT=yes
IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
NETWORK=192.168.56.1
ONBOOT=yes

Centos设置IP完成后,重启一下网卡就可以了:service network restart
我们还有一个办法可以实现Centos设置静态IP,那就是通过 ifconfig 这个命令。通常,我们都用它来查看当前网卡的一些信息,同时,他也可以用来进行一些网卡信息的设置。
修改的命令如下:ifconfig eth0 192.168.56.102

但是,这个命令执行后,只能够在当前会话中修改网卡的地址,我们看一下 ifcfg-eth0 的配置文件,仍然是
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:43:73:2f
也就是说重新启动服务器后,仍然会按照Centos配置文件中的方式进行IP的获取。所以,如果需要修改IP为静态IP的话,最好的方式还是通过修改Centos配置文件来完成。

❸ centos 下如何通过yum安装最新的php

remi源,这里的php版本较新,5.4,5.5,5.6都有,还有配套的各种扩展
rpms.famillecollet.com


Centos 6.默认下没有安装php组件,因此我们需要输入命令:yum -y install php 回车如下图。
不用管,程序会自动完成安装及配置。

Zend组件,Centos 6.3 里面是没有的,需要手动下载,及安装教程请点击下面链接:

到此前期的准备工作已完成,下面就要对Apache进行配置
输入命令 pd/conf/httpd.conf //打开Apache配置文件,
找到ServerTokens OS将“OS”改为“Prod “ 。//显示服务器运行错误信息。与下图一样,那么Apache你就配置成功了,如果不一样请仔细对比上面的教程是不是那个步骤少了#及字母拼写错了。
到此php运行环境便配置成功啦。

❹ centos6.5下配置nginx,nginx页面能出现,php测试页面显示空白!!!!!!

1、php5.3以后版本可以配置php-fpm.conf
listen
=
127.0.0.1:9002
2、启动php-fpm服务器
/etc/init.d/php-fpm
start
3、netstat
-ntlp检查9001端口是否启动
4、配置nginx
server
{
listen
80;
access_log
/data/logs/nginx/access.log;
root
/data/www
;
index
index.php
index.html
index.htm;
location
/
{
expires
1d;
}
location
~
\.php$
{
fastcgi_pass
127.0.0.1:9002;
fastcgi_index
index.php;
include
fastcgi.conf;
}
}

❺ 我在虚拟机中安装了Centos6.6 配置PHP环境,最后几经破折,出现如下问题,请教大神,可有解

在安装系统之前,需要首先对虚拟机的硬件环境进行设置,建议使用系统预置的硬件和配置模板,直接选择centos 6或RHEL 6模式。

因为没在虚拟机中安装过 CentOS 6.3,如果安装之前的版本无此问题,可能是新版本造成的,你可以将虚拟机升级到最新版本试试,如果依然如此,考虑在虚拟机软件升级之前,先安装个老版本的CentOS用着吧。

❻ 我用centos linux系统配置php服务器,别的都没有问题,就是配置php.ini不生效我用phpinfo看了

你写个 test.php
<?php
phpinfo();
?>

执行看看当前用的配置.ini文件在哪个目录。当然,这个文件不存在会用默认配置运行....

❼ 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

❽ 如何在CentOS6下实现Apache+PHP+MySQL的快速安装

LAMP是一个免费、开源的解决方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web服务器。那么如何在CentOS6下实现安装Apache+php+Mysql的快速安装?其具体安装配置步骤可以如下进行:
1.准备工作
使用yum进行安装,为了提高速度,最好先是修改为中国CentOS镜像服务器。目前国内有三个镜像可以选择,分别是:中国科学技术大学、163和Sohu的镜像,建议教育网用户选择中科大,电信用户选择163,他们的repo文件本博客作了备份如下:
http://yupengyan.com/wp-content/uploads/2012/02/CentOS6-Base-163.repo_.txt
http://yupengyan.com/wp-content/uploads/2012/02/CentOS6-Base-sohu.repo_.txt
http://yupengyan.com/wp-content/uploads/2012/02/CentOS6-Base-ustc.repo_.txt
下面命令是备份CentOS-Base.repo文件,并修改使用163镜像作为yum源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo

2.更新系统内核
yum -y update

3.安装Apahce、Mysql、PHP
yum -y install httpd php mysql mysql-server

默认情况下,mysql数据目录位于/var/lib/mysql
4.安装相关组件:
yum install php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc

5.安装MySQL管理工具phpMyAdmin
yum -y install phpMyAdmin
6.配置Apache随系统启动
chkconfig --levels 235 httpd on
/etc/init.d/httpd start

7.配置MySQL随系统启动
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

8.设置数据库root密码
/usr/bin/mysqladmin -u root password 'New+Password#www.yupengyan.com'

9.测试PHP是否安装成功
在 CentOS 中 Apache 的默认根目录是 /var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存储在 /etc/httpd/conf.d/ 目录。

❾ Centos php 修改配置文件

find / -name "php.ini'

如果你安装的话。这里会有的。

热点内容
python打印机打印图片 发布:2025-01-24 14:59:49 浏览:227
javascript设计模式源码 发布:2025-01-24 14:49:07 浏览:908
linqtosql查询 发布:2025-01-24 14:48:57 浏览:120
华为手机更换开机密码如何操作 发布:2025-01-24 14:43:15 浏览:699
快手等待上传 发布:2025-01-24 14:41:37 浏览:380
apache和php7 发布:2025-01-24 14:32:26 浏览:892
linuxio文件 发布:2025-01-24 13:40:21 浏览:438
在excel设密码如何取消 发布:2025-01-24 13:38:54 浏览:483
电脑装存储时不能开机 发布:2025-01-24 13:38:52 浏览:285
2000人同时在线的小程序需要什么服务器 发布:2025-01-24 13:37:17 浏览:853