當前位置:首頁 » 編程語言 » 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'

如果你安裝的話。這里會有的。

熱點內容
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
怎麼搭建linux伺服器配置 發布:2025-01-24 13:37:16 瀏覽:113