服務(wù)器開發(fā)之路五:PHP環(huán)境搭建

我一直覺得PHP代碼寫起來還是很簡(jiǎn)單,但因?yàn)榕c服務(wù)器,數(shù)據(jù)庫耦合度太高,環(huán)境搭建還是挺麻煩的,不管是在Window系統(tǒng)還是Linux系統(tǒng)。還好有集成化工具,不過還是會(huì)出現(xiàn)一些問題。

這里僅做記錄。

XAMPP

官網(wǎng)網(wǎng)址:https://www.apachefriends.org/index.html

1、安裝:
./xampp-linux-XXX.run

在安裝過程中會(huì)讓你選擇安裝位置,默認(rèn)在/opt目錄下

2、進(jìn)入主目錄:
cd /opt/lampp

3、運(yùn)行命令

服務(wù)

./lampp start | stop | status | restart

mysql

./lampp startmysql | stopmysql

4、安全

設(shè)置密碼

./lampp security

XAMPP: Quick security check...

XAMPP: MySQL is accessable via network.

XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] yes

XAMPP: Turned off.

XAMPP: Stopping MySQL...

XAMPP: Starting MySQL...

XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!

XAMPP: Do you want to set a password? [yes] yes

XAMPP: Password: ******

XAMPP: Password (again): ******

XAMPP: Setting new MySQL pma password.

XAMPP: Setting phpMyAdmin's pma password to the new one.

XAMPP: MySQL has no root passwort set!!!

XAMPP: Do you want to set a password? [yes] yes

XAMPP: Write the passworde somewhere down to make sure you won't forget it!!!

XAMPP: Password: ******

XAMPP: Password (again): ******

XAMPP: Setting new MySQL root password.

XAMPP: Setting phpMyAdmin's root password to the new one.

XAMPP: The FTP password for user 'nobody' is still set to 'lampp'.

XAMPP: Do you want to change the password? [yes] yes

XAMPP: Password: ******

XAMPP: Password (again): ******

XAMPP: Reload ProFTPD...

XAMPP: Done.

5、讓局域網(wǎng)訪問

Require local 注釋掉,添加 Require all granted

6、mysql 遠(yuǎn)程訪問

use mysql

grant all privileges on . to root@'%' identified by "password";
// 你也可以修改表

flush privileges;

7、瀏覽技巧

/dashboard/faq.html
常見問題介紹,相當(dāng)于快速入門

/dashboard/howto.html
專項(xiàng)問題解讀,比如數(shù)據(jù),虛擬主機(jī),在這里面,你能找到詳細(xì)答案

8、問題

我的問題主要在mysql這一塊,PHP可以連接mysql,但是其他不行,也沒有開啟3306這個(gè)端口

不用它的mysql,安裝其他mysql,PHP又不能用。

phpstudy

最開始用他最大的原因是可以外網(wǎng)訪問。

phpstudy for linux版環(huán)境安裝
本文主要和大家分享PHP環(huán)境安裝-phpstudy for linux版,希望能幫助到大家。

下載地址:

下載版:http://lamp.phpstudy.net/phpstudy.bin

完整版:http://lamp.phpstudy.net/phpstudy-all.bin

PHP環(huán)境支持:

解釋:Apache/Nginx/Tengine/Lighttpd

PHP版本:支持php5.2/5.3/5.4/5.5切換

操作系統(tǒng):已經(jīng)在centos-6.5,debian-7.4.,ubuntu-13.10測(cè)試成功

安裝方法:

下載好 .bin 文件

cd到下載目錄

chmod +x ./phpstudy.bin 給權(quán)限

然后在終端中運(yùn)行 ./phpstudy.bin

等待編譯完成

使用方法

在終端中使用sudo 或者 使用管理員賬號(hào)運(yùn)行 phpstudy start 開啟

命令列表:

phpstudy start | stop | restart 開啟 | 停止 | 重啟

phpstudy add | del | list 添加虛擬主機(jī) | 刪除虛擬主機(jī) | 查看虛擬主機(jī)列表

注:添加或刪除過虛擬主機(jī)域名,需要重新修改host文件配置,(sudo vim /etc/hosts)

phpstudy ftp add | del | list

配置文件地址

apache配置文件:/phpstudy/server/httpd/conf/httpd.conf

PHP配置文件:/phpstudy/server/php/etc/php.ini

打開Mysql控制臺(tái)

/phpstudy/mysql/bin/mysql -uroot -proot

手動(dòng)搭建LAMP環(huán)境

安裝Apache

1、通過yum源安裝以httpd開頭的命名的軟件包,在命令行下輸入:

yum install httpd

2、然后根據(jù)提示輸入相應(yīng)的命令進(jìn)行安裝操作

3、一些命令

#啟動(dòng)apache
systemctl start httpd.service 

#停止apache
systemctl stop httpd.service 

#重啟apache
systemctl restart httpd.service 

#設(shè)置apache開機(jī)啟動(dòng)
systemctl enable httpd.service 
  • 安裝MariaDB

1、命令行下輸入:yum install mariadb mariadb-server

2、依舊是根據(jù)提示輸入相關(guān)命令進(jìn)行安裝操作

3、一些命令

systemctl start mariadb.service #啟動(dòng)MariaDB

systemctl stop mariadb.service #停止MariaDB

systemctl restart mariadb.service #重啟MariaDB

systemctl enable mariadb.service #設(shè)置開機(jī)啟動(dòng)

4、拷貝配置文件:

cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

5、為root賬戶設(shè)置密碼

輸入:

mysql_secure_installation

根據(jù)提示輸入Y,輸入2次密碼,根據(jù)提示一路輸入Y,最后出現(xiàn):Thanks for using MySQL!

MySql密碼設(shè)置完成,重新啟動(dòng) MySQL:

重啟MariaDB輸入:

systemctl restart mariadb.service

  • 安裝PHP

1、命令行下輸入

yum install php

回車開始安裝

2、安裝PHP組件,使PHP支持 MariaDB

命令行下輸入:

yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

3、然后你需要重啟

#重啟MariaDB
systemctl restart mariadb.service 

#重啟apache
systemctl restart httpd.service 

資料

1、CentOS 7.0 如何安裝LAMP服務(wù)器方法

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容