⑴ linux系統下怎麼搭建網站伺服器
具體方法如下:
1、使用putty或類似的SSH工具登錄伺服器(本地安裝跳過);
⑵ linux yum安裝php7.3
先安裝前面的教程,再安裝後面的
參考教程1:
https://blog.csdn.net/weixin_43731793/article/details/91488289
參考教程2:
http://www.bubuko.com/infodetail-2931909.html
安裝PHP
1、安裝PHP73
1.1、卸載舊版本PHP
yum remove php*
1.2、安裝EPEL:
sudo yum install epel-release
1.3、安裝remi(選一個):
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
1.4、查看目前有php的什麼版本(可忽略)
sudo yum list php*
1.5、列出所有的php相關的rpm包(可忽略)
rpm -qa|grep php
1.6、刪除php相關的rpm包(一次只能刪除一個)(可忽略)
rpm -e php72w-mysqlnd-7.2.17-1.w7.x86_64
1.7、列出remi倉庫下所有PHP7.3可用模塊。(可忽略)
yum --enablerepo=remi-php73 search php | grep php73
1.8、安裝PHP 7.3
yum --enablerepo=remi-php73 install php
1、安裝 PHP7.3:
(解決yum安裝apache關聯不了PHP的問題,用以下命令安裝)
yum --enablerepo=remi-php73 install php
安裝模塊
yum --enablerepo=remi-php73 install php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml
2、設置開機啟動、運行服務:
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
3、查找php.ini位置:
find /etc/opt/remi/php73 -name php.ini
/etc/opt/remi/php73/php.ini
找到apache的配置文件:httpd.conf
sudo find / -name httpd.conf
位置如下:
/etc/httpd/conf/httpd.conf
5、PHP日常操作
systemctl restart php73-php-fpm #重啟
systemctl start php73-php-fpm #啟動
systemctl stop php73-php-fpm #關閉
systemctl status php73-php-fpm #檢查狀態
php -m #查看PHP已安裝拓展模塊
php -v #查看PHP版本
⑶ 如何在linux下安裝多個不同版本的PHP
Linux下部署php多版本共存
背景說明
自php7問世,身為最新版本控的我馬上升級體驗,但是由於伺服器上還有舊程序在運行,只好部署一個php多版本共存環境。
現有環境是lnmp
- CentOS 6.7
- nginx 1.10.1
- mariadb-10.0.26
- php 7.0.8
為了更好兼容舊的php程序,推薦使用5.4.45. 主要是兼容mysql擴展。
開始安裝
首先要下載php-5.4.45.tar.gz源碼包。
通過源碼安裝
# tar xzvf php-5.4.45.tar.gz
# cd php-5.4.45
# ./configure --prefix=/usr/local/php54 --with-config-file-path=/usr/local/php54/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=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --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 --with-gettext --disable-fileinfo --enable-intl --with-xsl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# cp php.ini-proction /usr/local/php/etc/php.ini
------------------------------------------------------------------------------------------------
php.ini 配置
post_max_size = 50M
upload_max_filesize = 50M
date.timezone = PRC
short_open_tag = On
cgi.fix_pathinfo=0
max_execution_time = 300
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
------------------------------------------------------------------------------------------------
php-fpm.conf 配置
------------------------------
# vim /usr/local/php/etc/php-fpm.conf1
[global]
pid = /usr/local/php54/var/run/php-fpm.pid
error_log = /usr/local/php54/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php54-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9001
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 40
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 40
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
----------------------------------------------------------------------------------
啟動 php-fpm
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php54-fpm
# chmod +x /etc/init.d/php54-fpm
# /etc/init.d/php54-fpm start
-------------------------------------------------------------------------------------------
修改nginx配置,對需要的服務配置使用php-5.4.45
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php54-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
----------------------------------------------------------------------------------------
配置php-5.4.45 的php54-fpm 開機自動啟動
# chkconfig --add php54-fpm
# chkconfig php54-fpm on