㈠ 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
㈡ linux下php如何配置
通過yum安裝最方便了,不需要配置那麼多.
"extension_dir=" 一般不要寫,除非你的網站在運行了,需要在線添加外置模塊,才用得到。
LoadMole php5_mole 通過RPM安裝,默認就給你配好了,你也不需要配。
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
讓apache更好的支持其他的軟體。
3. 安裝php的擴展
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-mcrypt
4. 安裝MySQL的擴展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
更好地實現mysql的功能。
5. 配置開機啟動服務
/sbin/chkconfig httpd on
/sbin/service httpd start
/sbin/service mysqld start
6. 簡單配置文件:
apache的配置文件是/etc/httpd/conf下
moles放在/usr/lib/httpd下
php的配置文件在/etc/php.d/下 和/etc/php.ini
php的moles放在/usr/lib/php/moles下
㈢ 怎樣在linux伺服器環境搭建PHP網站
首先應該是你把你的伺服器配置好了 包括php apache mysql 的安裝 等這些都安裝好了。那麼就是配置你的apache了。在這個過程中有什麼疑問可以隨時找我 QQ 530162466
㈣ 阿里雲上的centos 7.2怎麼yum安裝php 5.6
因之前通過網易的 centos 鏡像,將阿里雲的 centos 升級到最新版了,乘自己的項目尚未開始正式開發,遂將所有的相應環境都升級到最高。
查看 centos 版本:
[root@iZ23d ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
1、刪除之前的 php 版本:
[root@iZ23d ~]# yum remove php* php-common
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: php-5.4.16
No Match for argument: php-5.4.16.tar.gz
No Match for argument: php-7.0.1RC1
No Match for argument: php-7.0.1RC1.tar.gz
No Match for argument: phpMyAdmin-4.4.0.tar.gz
No Match for argument: php-common
No Packages marked for removal
2、rpm 安裝 Php7 相應的 yum源:
[root@iZ23d ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.LhJKKR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ################################# [100%]
package webtatic-release-7-3.noarch is already installed
3、 直接yum安裝php7:
[root@iZ23d ~]# yum install php70w
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
。。。 【省略】
Warning: RPMDB altered outside of yum.
Installing : php70w-common-7.0.0-1.w7.x86_64 1/3
Installing : php70w-cli-7.0.0-1.w7.x86_64 2/3
Installing : php70w-7.0.0-1.w7.x86_64 3/3
Verifying : php70w-7.0.0-1.w7.x86_64 1/3
Verifying : php70w-common-7.0.0-1.w7.x86_64 2/3
Verifying : php70w-cli-7.0.0-1.w7.x86_64 3/3
Installed:
php70w.x86_64 0:7.0.0-1.w7
Dependency Installed:
php70w-cli.x86_64 0:7.0.0-1.w7 php70w-common.x86_64 0:7.0.0-1.w7
Complete!
4、檢查 php 版本:
[root@iZ23d ~]# php -v
PHP 7.0.0 (cli) (built: Dec 2 2015 20:42:32) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
[root@iZ23d2e6hoqZ ~]#
以上顯示安裝成功!
5、重啟 Apache,查看 phpinfo :
[root@iZ23d ~]# systemctl restart httpd.service
檢查phpinfo:
PHP Version 7.0.0
SystemLinux iZ23d 3.10.0-229.11.1.el7.x86_64 #1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64
Build DateDec 2 2015 20:43:38
Server APIApache 2.0 Handler
Virtual Directory Supportdisabled
Configuration File (php.ini) Path/etc
Loaded Configuration File/etc/php.ini
Scan this dir for additional .ini files/etc/php.d
Additional .ini files parsed/etc/php.d/bz2.ini, /etc/php.d/calendar.ini, /etc/php.d/ctype.ini, /etc/php.d/curl.ini, /etc/php.d/exif.ini, /etc/php.d/fileinfo.ini, /etc/php.d/ftp.ini, /etc/php.d/gettext.ini, /etc/php.d/gmp.ini, /etc/php.d/iconv.ini, /etc/php.d/json.ini, /etc/php.d/phar.ini, /etc/php.d/shmop.ini, /etc/php.d/simplexml.ini, /etc/php.d/sockets.ini, /etc/php.d/tokenizer.ini, /etc/php.d/xml.ini, /etc/php.d/zip.ini
PHP API20151012
PHP Extension20151012
Zend Extension320151012
Zend Extension BuildAPI320151012,NTS
PHP Extension BuildAPI20151012,NTS
Debug Buildno
Thread Safetydisabled
Zend Signal Handlingdisabled
Zend Memory Managerenabled
Zend Multibyte Supportdisabled
IPv6 Supportenabled
DTrace Supportenabled
Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filterszlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
Configuration
apache2handler
Apache VersionApache/2.4.6 (CentOS)
Apache API Version20120211
Server [email protected]
Hostname:Portxxxx.xxxxx.xxx:0
User/Groupapache(48)/48
Max RequestsPer Child: 0 - Keep Alive: on - Max Per Connection: 100
TimeoutsConnection: 60 - Keep-Alive: 15
Virtual ServerYes
Server Root/etc/httpd
Loaded Molescore mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_mpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_wstunnel mod_ssl mod_systemd mod_cgi mod_perl mod_php7
以上顯示 php7 安裝成功!
㈤ 請問下linux下搭建php環境的一些問題。
這是我自己整理的你可以查考下
基本上沒有什麼包得
一、mysql安裝:
1.安裝bison和cmake
提示:MySQL 5.5 版本的安裝需要這兩個軟體,bison我們可以用方便的yum直接安裝好,cmake則用編譯安裝的辦法。
yum install bison
註:需安裝GCC,ncurses-devel。
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4/
./configure
gmake
gmake install
chkconfig iptables off 禁用iptables(永久生效)
service iptables stop (臨時生效)
3,安裝
提示:如果機器上已有自帶的MySQL版本,最好先卸載自帶的MySQL,以防以後使用的時候混淆。
卸載命令:yum remove mysql
如果不確定機器上是否自帶有MySQL,也一樣可以執行下卸載命令無妨。
/usr/sbin/groupadd mysql (如果有提示已存在,並不是錯誤)
/usr/sbin/useradd -g mysql mysql (如果有提示已存在,並不是錯誤)
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/mysql
make
make install
4,設置
cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf
編輯/etc/my.cnf
在 [mysqld] 段增加
datadir = /data/mysql
wait-timeout = 30
max_connections = 512
max_connect_errors = 10000000
在 [mysqld] 段修改
max_allowed_packet = 16M
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
編輯/etc/rc.d/init.d/mysqld
把basedir=編輯成basedir=/usr/local/mysql
把datadir=編輯成datadir=/data/mysql
service mysqld start
bin/mysqladmin -u root password 'password_for_root'
其中引號內的password_for_root是要設置的root密碼
service mysqld restart
/usr/local/mysql/bin/mysql -uroot -p
show databases;
===========================================================================
二、apache安裝
./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so
make;make install
groupadd apache
useradd -g apache -M -s /sbin/nologin apache
vi /usr/local/apache2/conf/httpd.conf
找到如下2句 並在行頭加#號注釋掉
User daemon
Group daemon
追加如下2句
User apache
Group apache
/usr/local/apache2/bin/apachectl start
lsof -i:80
測試:首先,關閉 service iptables stop
curl http://localhost (linux)
http://伺服器IP(windows)
#cp /usr/local/src/httpd-2.2.19/build/rpm/httpd.init /etc/rc.d/init.d/httpd
#vim /etc/rc.d/init.d/httpd
#apachectl=/usr/local/apache2/bin/apachectl
#httpd=${HTTPD-/usr/local/apache2/bin/httpd}
#CONFFILE=/usr/local/apache2/conf/httpd.conf
#chmod +x /etc/init.d/httpd
#chmod 700 /etc/init.d/httpd
#設置httpd開機自啟動
#chkconfig --add httpd
#chkconfig --level 345 httpd on
#這樣,啟動、停止、重啟Apache就可以用以下方式了:
#/etc/init.d/httpd start
#/etc/init.d/httpd stop
#/etc/init.d/httpd restart
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local
====================================================================
三、php安裝:
yum install libjpeg*
yum install libpng*
tar zxvf php-5.3.3-CP.tar.gz
cd php-5.3.3
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --disable-debug --enable-safe-mode --enable-short-tags --with-gd --with-zlib --with-jpeg-dir --with-png-dir --enable-memory-limit --disable-posix --with-config-file-path=/usr/local/lib --with-mysqli=/usr/local/mysql/bin/mysql_config
make;make install
cp php.ini-proction /usr/local/lib/php.ini
[root@RHEL php-5.2.14]# vi /usr/local/apache2/conf/httpd.conf
在內容里搜一下是否有libphp5.so
我的情況 已經有了 如果沒有追加下面那句前面不帶#的
# LoadMole foo_mole moles/mod_foo.so
LoadMole php5_mole moles/libphp5.so
#
再搜索AddType關鍵字 在那附近追加如下一句
AddType application/x-httpd-php .php .phtml
再搜索下面一段 把第二句DirectoryIndex的後面追加index.php
<IfMole dir_mole>
DirectoryIndex index.html index.php
</IfMole>
cd /usr/local/apache2/htdocs/
vi index.php
輸入內容
<?php
phpinfo();
?>
vim /etc/selinux/config
注釋掉#SELINUX=enforcing 並追加SELINUX=disabled
修改完需重啟伺服器
[root@RHEL php-5.2.14]# /usr/local/apache2/bin/apachectl restart
不重啟:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/moles/libphp5.so
# /usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start
# setenforce 1
[root@RHEL mysql]# curl -I http://localhost/index.php
或者你在你的瀏覽器里輸入http://yourip/index.php
vim phpmysql.php
輸入內容
<?php
mysql_connect("localhost","root","123456") or die("MySQL First Test:Failed");
echo "MySQL First Test:Success";
?>
因為我們編譯php的時候沒有加--with-mysqli選項 所以不支持mysqli擴展
[root@RHEL htdocs]# curl http://localhost/phpmysql.php
MySQL First Test:Success
好了 我這里成功了
你可以再瀏覽器里輸入http://ip/phpmysql.php
=============================================================================
四、配置phpMyAdmin
wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.bz2
cd /root
tar -jxvf phpMyAdmin-3.3.7-all-languages.tar.bz2
test -d /var/www || mkdir -p /var/www #判斷是否存在此目錄,不存在則創建
mv phpMyAdmin-3.3.7-all-languages /var/www/phpMyAdmin
cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
vi /var/www/phpMyAdmin/config.inc.php
追加$cfg['Lang'] = 'zh-utf-8';
----------可選設置 為phpMyAdmin設置50位的短語密碼---------
yum install expect
[root@RHEL src]# mkpasswd -l 50
nxcayzaoqygmp5e$
復制產生的短語密碼
[root@RHEL src]# vi /var/www/phpMyAdmin/config.inc.php
找到如下參數
$cfg['blowfish_secret'] = 'nxcayzaoqygmp5e$'
chown -R root.apache /var/www/phpMyAdmin
cd /usr/local/apache2/conf/
vi extra/phpmyadmin.conf
加入內容
Alias /phpMyAdmin /var/www/phpMyAdmin
<Location /phpMyAdmin>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.110.108.55
#這里改成你實際允許訪問的ip
</Location>
vi httpd.conf
追加:Include conf/extra/phpmyadmin.conf
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
lsof -i:80