php系統安裝
① 如何在Windows7環境下安裝 php
方法/步驟:
1、請先下載相關工具。根據自己系統下載相應版本,我下載的都是64位。
2、首先安裝PHPManagerForIIS,安裝成功後會IIS界面會多出PHPManager圖標,等待後續操作。
3、將下載的PHP 7.0.2 for win解壓並確定好要放置的位置。我這里放到C盤根目錄下並改名為PHP 7.0.2。可根據自己需要進行調整。
4、將php.ini-development拷貝至C盤windows文件夾下,改名為php.ini;將extension_dir = "D:\PHP 7.0.2\ext"——實際對應EXT文件夾的位置。
5、此時重新打開IIS中的PHPManager管理界面,選擇安裝PHP。圖中是安裝後的效果,沒安裝時只有這個選項可用。安裝時選擇PHP文件夾下的PHP-CGI.exe文件即可。
6、此時可以嘗試運行PHP文件夾下的php可執行文件,如果沒有報錯就OK。如果報錯說VCRUNTIME140.DLL丟失,就是電腦缺少Visual C++Redistributable環境這時候就要用到vc_redist.x64(你的電腦也許是vc_redist.x86),微軟官方下載安全可靠...安裝完成後就OK了,可以開始你的PHP之旅了。
② linuxphp網站怎麼安裝
配置php服務
安飢塌裝yasm匯編器(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfyasm-1.2.0.tar.gz
[root@linuxprobesrc]cdyasm-1.2.0
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安裝libmcrypt加密演算法擴展庫(解爛銀圓壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibmcrypt-2.5.8.tar.gz
[root@linuxprobesrc]cdlibmcrypt-2.5.8
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安裝libvpx視頻編碼器(解壓與編譯過程搏旦已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarxjvflibvpx-v1.3.0.tar.bz2
[root@linuxprobesrc]cdlibvpx-v1.3.0
[[email protected]]./configure--prefix=/usr/local/libvpx--enable-shared--enable-vp9
[[email protected]]make
[[email protected]]makeinstall
安裝Tiff標簽圖像文件格式(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvftiff-4.0.3.tar.gz
[root@linuxprobesrc]cdtiff-4.0.3
[[email protected]]./configure--prefix=/usr/local/tiff--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝libpng圖片(png格式)函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibpng-1.6.12.tar.gz
[root@linuxprobesrc]cdlibpng-1.6.12
[[email protected]]./configure--prefix=/usr/local/libpng--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝freetype字體引擎(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvffreetype-2.5.3.tar.gz
[root@linuxprobesrc]cdfreetype-2.5.3
[[email protected]]./configure--prefix=/usr/local/freetype--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝jpeg圖片(jpeg格式)函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfjpegsrc.v9a.tar.gz
[root@linuxprobesrc]cdjpeg-9a
[root@linuxprobejpeg-9a]./configure--prefix=/usr/local/jpeg--enable-shared
[root@linuxprobejpeg-9a]make
[root@linuxprobejpeg-9a]makeinstall
安裝libgd圖像處理程序(解壓與編譯過程已省略):
[root@linuxprobejpeg-9a]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibgd-2.1.0.tar.gz
[root@linuxprobesrc]cdlibgd-2.1.0
[[email protected]]./configure--prefix=/usr/local/libgd--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/tiff--with-vpx=/usr/local/libvpx
[[email protected]]make
[[email protected]]makeinstall
安裝t1lib圖片生成函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvft1lib-5.1.2.tar.gz
[root@linuxprobesrc]cdt1lib-5.1.2
[[email protected]]./configure--prefix=/usr/local/t1lib--enable-shared
[[email protected]]make
[[email protected]]makeinstall
將函數庫文件放至合適的位置:
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so
[root@linuxprobesrc]cp-frp/usr/lib64/libXpm.so*/usr/lib/
安裝php服務程序(命令比較長,請一定要復制完整!!!):
[root@linuxprobesrc]tar-zvxfphp-5.5.14.tar.gz
[root@linuxprobesrc]cdphp-5.5.14
[[email protected]]exportLD_LIBRARY_PATH=/usr/local/libgd/lib
[[email protected]]./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype
[[email protected]]make
[[email protected]]makeinstall
復制php服務程序的配置文件到安裝目錄:
[[email protected]]cpphp.ini-proction/usr/local/php/etc/php.ini
刪除默認的php配置文件:
[[email protected]]rm-rf/etc/php.ini
創建php配置文件的軟連接到/etc/目錄中:
[[email protected]]cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php.ini/etc/php.ini
編輯php服務程序的配置文件:
[[email protected]]vim/usr/local/php/etc/php-fpm.conf
//將第25行參數前面的分號去掉。
pid=run/php-fpm.pid
//修改第148和149行,將user與group修改為www。
user=www
group=www
添加php-fpm服務程序到開機啟動項:
[[email protected]]cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm
[[email protected]]chmod+x/etc/rc.d/init.d/php-fpm
[[email protected]]chkconfigphp-fpmon
為了保障網站的安全性,禁用掉不安全的功能:
[[email protected]]vim/usr/local/php/etc/php.ini
//修改第305行的disable_functions參數,追加參數為:
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
配置nginx服務程序支持php:
[[email protected]]vim/usr/local/nginx/conf/nginx.conf
//將第2行前面的號去掉並修改為userwwwwww;
//將第45行參數修改為indexindex.htmlindex.htmindex.php;
//將第65-71行前面的號去掉,修改為:
location~.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
重啟nginx與php-fpm服務程序:
[[email protected]]systemctlrestartnginx
[[email protected]]systemctlrestartphp-fpm
③ 如何安裝PHP
得看是什麼程序以及程序寫的怎麼樣了。
如果是文本資料庫的 並且程序寫的不錯的話
直接上傳上去 不用設置什麼 就可以使用了。
如果寫的一般的話 需要設置一下 文本資料庫的路徑。
如果是Mysql數據做支持的話,
首先得程序自帶的安裝程序 創建資料庫
如果程序沒有自帶安裝程序,那麼你就得自己手動的創建資料庫了。
然後設置好mysql的相關鏈接參數後,一般就可以用了。
希望我的回答對你有所幫助。
④ 伺服器上怎麼安裝php程序
你好,如果你的伺服器是Windows系統,那麼你需要遠程到你的伺服器,進行啟動IIS(asp環境),如果你需要php環境,你可以從xp.cn(小皮)或者bt.cn(寶塔)安裝面板
如果你的伺服器是Linux,建議使用寶塔
打開終端,不同Linux系統的輸入指令不同:
Centos安裝腳本
終端輸入:yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
Ubuntu/Deepin安裝腳本
終端輸入:wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
Debian安裝腳本
終端輸入:wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
Fedora安裝腳本
終端輸入wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh
輸入後進行安裝就可以了
⑤ 怎麼安裝PHP環境
LAMP/LNMP 環境搭建
一.檢查系統環境
1.確認centos版本
[root@localhost ~]# cat /etc/redhat-release
2.檢查是否安裝過apache
rpm -qa | grep httpd
或者:
apachectl -v
或者:
httpd -v
3.檢查是否安裝過Mysql
service mysqld start
如果未被識別則沒有安裝
如果系統安裝過,或者安裝失敗,清理一下系統
4.清理Mysql痕跡
yum remove mysql
rm -f /etc/my.cnf
5.卸載Apache包
rpm -qa|grep httpd
注意:如果是新的系統或者你從來沒有嘗試安裝過,則以上步驟省略
二.安裝Apache、PHP、Mysql
停止防火牆服務
[root@localhost ~]# systemctl stop firewalld.service
禁用防火牆開機啟動服務
[root@localhost ~]# systemctl disable firewalld.service
1.安裝apache
[root@localhost ~]# yum -y install httpd
2.安裝php
[root@localhost ~]# yum -y install php
3.安裝php-fpm
[root@localhost ~]# yum -y install php-fpm
4.安裝Mysql
[root@localhost ~]# yum -y install mysql
5.安裝 mysql-server
[root@localhost ~]# yum install mariadb-server
CentOS 7+ 版本將MySQL資料庫軟體從默認的程序列表中移除,用mariadb代替了,entos7配置教程上,大多都是安裝mariadb,因為centos7默認將mariadb視作mysql。
因為mysql被oracle收購後,原作者擔心mysql閉源,所以又寫了一個mariadb,這個資料庫可以理解為mysql的分支。如果需要安裝mariadb,只需通過yum就可。
6.安裝 php-mysql
[root@localhost ~]# yum -y install php-mysql
三.安裝基本常用擴展包
1.安裝Apache擴展包
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
2.安裝PHP擴展包
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel
3.安裝Mysql擴展包
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
四.配置Apache、mysql開機啟動
重啟Apache、mysql服務(注意這里和centos6有區別,Cenots7+不能使用6的方式)
systemctl start httpd.service #啟動apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重啟apache
systemctl enable httpd.service #設置apache開機啟動
重啟資料庫
#啟動MariaDB
[root@localhost ~]# systemctl start mariadb.service
#停止MariaDB
[root@localhost ~]# systemctl stop mariadb.service
#重啟MariaDB
[root@localhost ~]# systemctl restart mariadb.service
#設置開機啟動
[root@localhost ~]# systemctl enable mariadb.service
五.配置Mysql
初次安裝mysql是沒有密碼的,我們要設置密碼,mysql的默認賬戶為root
方式1:設置 MySQL 數據 root 賬戶的密碼:
[root@localhost ~]# mysql_secure_installation
當出現如下提示時候直接按回車:
Enter current password for root
出現如下再次回車:
Set root password? [Y/n]
出現如下提示輸入你需要設置的密碼,這里輸入了root,輸入密碼是不顯示的,回車後再輸入一次確認:
New password:
接下來還會有四個確認,分別是:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
直接回車即可。
方式2:進入mysql mysql -r
修改mysql密碼:set password for 'root'@'localhost'=password('root');
mysql授權遠程連接(navicat等): grant all on *.* to root identified by 'root';
六.測試環境
我們在瀏覽器地址欄輸入http://ip/,正常顯示,說明我們的lamp 環境搭建成功
七.安裝nginx
yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
Nginx 版本號可變更http://nginx.org/packages/centos/7/noarch/RPMS/$版本
八.配置nginx
1.nginx啟動,停止,重啟
systemctl start nginx.service #啟動nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重啟
systemctl enable nginx.service #設置開機啟動
更改nginx埠號(根據自己需求)
cd /etc/nginx/conf.d/
vim default.conf
把listen 80改成listen 81
3.訪問http://ip:81即可看到nginx首頁
安裝完成訪問時候需要啟動php-fpm,不重啟訪問會出現下載文件,重啟命令如下
systemctl start php-fpm.service #啟動php-fpm
systemctl enable php-fpm.service #設置開機啟動
4.更改nginx配置文件識別php
vi /etc/nginx/conf.d/default.conf,把之前的#給去掉就可以了,順手改一下
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
方法二 安裝nginx
yum install nginx
啟動nginx,並設置為開機啟動
systemctl start nginx
systemctl enable nginx
5.在 /usr/share/nginx/html中新建一個test.php
訪問http://ip:81/test.php即可看到php頁面
修改完成配置記得啟動apache 和php-fpm 哦!
九.負載配置
upstream site{
server 172.16.170.138;
server 172.16.170.139;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://site;
}
apache 默認目錄 /var/www/html
nginx 默認目錄 /usr/share/nginx/html
升級php版本
centos7 默認安裝php是5.4
查看yum的可安裝的php版本列表
yum provides php
開始升級PHP更新源:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum remove php-common -y #移除系統自帶的php-common
php72版本
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring
php56版本
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring #安裝依賴包
查看php版本
php -v
安裝php fpm:
yum install php72w-fpm
yum provides php-fpm #因為我是准備搭建lnmp,所以安裝php-fpm,這里會提示多個安裝源,選擇5.6版本的安裝就可以了
yum install php56w-fpm-5.6.31-1.w7.x86_64 -y
systemctl start php-fpm.service 【啟動】
systemctl enable php-fpm.service【開機自啟動】
CentOS yum有時出現「Could not retrieve mirrorlist 」的解決辦法——resolv.conf的配置
原因:沒有配置resolv.conf
解決方法:
到/etc目錄下配置resolv.conf加入nameserver IP,如:
nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain
保存再次運行上面的命令就可以。
https://blog.csdn.net/mao834099514/article/details/73470001
nginx目錄 : /usr/share/nginx/html
/etc/nginx/conf.d/default.conf nginx配置目錄
apache目錄 : /var/www/html
/etc/httpd/conf/httpd.conf apache配置文件
nginx 配置域名
cd /etc/nginx
cp default.conf imooc.conf
修改server_name imooc.test.com 以及項目目錄
配置虛擬域名 windows 訪問需要在host增加 linuxip
ServerName www.nine.com
DocumentRoot "/var/www/html/learnlaravel/public"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
關閉防火牆
setenforce 0
⑥ PHP如何安裝及配置
將下載的壓縮包解壓到純英文目錄下;
2.因為PHP是被動型的服務,目的就是為apache提供了處理php代碼的服務。因此我們要做的配置就是告訴apache,PHP在哪?需要它處理什麼樣的文件。
所以,打開apache的配置文件,httpd.conf。
搜索LoadMole,找到之後按照相同的格式載入php模塊,輸入:
接著搜索mime_mole,找到後按照相同格式在該標簽內,輸入:
放的位置是沒什麼要求,最好是能跟好隊形,好修改。
上面添加的配置,分別是告訴php的位置,然後告訴伺服器.php的文件會被當作「application/x-httpd-php」格式處理,而伺服器里處理application/x-httpd-php格式的就是php。這樣配置之後,一旦是.php的文件伺服器都會調用我們的php來處理。
到這里php代碼就可以正常使用了。
3.php的配置以及添加擴展
php本身的配置是要自己創建的。
首先,在解壓的php目錄下找到php.ini-development文件,這是php提供的配置模版,復制並修改文件名為php.ini。
由於php是被動服務,它的配置文件也一樣是apache來調用,所以還是要到apache的配置文件httpd.conf里添加:
接著,如果要添加擴展,可以在php的配置文件php.ini里搜索extension_dir,找到下圖:
php配置文件的注釋是靠「;」,這項配置是說明擴展文件的所在目錄。
按格式加上:extension_dir = "你的擴展文件目錄"
你的擴展文件目錄就是php解壓目錄下的ext文件夾,即:"解壓目錄/ext"。
接著需要告訴php載入哪些擴展:
在php.ini里添加:extension=你要添加的擴展名字