㈠ 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