我一直覺得PHP代碼寫起來還是很簡單,但因為與服務(wù)器彼念,數(shù)據(jù)庫耦合度太高,環(huán)境搭建還是挺麻煩的浅萧,不管是在Window系統(tǒng)還是Linux系統(tǒng)逐沙。還好有集成化工具,不過還是會出現(xiàn)一些問題洼畅。
這里僅做記錄吩案。
XAMPP
官網(wǎng)網(wǎng)址:https://www.apachefriends.org/index.html
1、安裝:
./xampp-linux-XXX.run
在安裝過程中會讓你選擇安裝位置帝簇,默認(rèn)在/opt目錄下
2徘郭、進(jìn)入主目錄:
cd /opt/lampp
3、運行命令
服務(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
專項問題解讀,比如數(shù)據(jù)镇草,虛擬主機眶痰,在這里面,你能找到詳細(xì)答案
8陶夜、問題
我的問題主要在mysql這一塊凛驮,PHP可以連接mysql,但是其他不行条辟,也沒有開啟3306這個端口
不用它的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測試成功
安裝方法:
下載好 .bin 文件
cd到下載目錄
chmod +x ./phpstudy.bin 給權(quán)限
然后在終端中運行 ./phpstudy.bin
等待編譯完成
使用方法
在終端中使用sudo 或者 使用管理員賬號運行 phpstudy start 開啟
命令列表:
phpstudy start | stop | restart 開啟 | 停止 | 重啟
phpstudy add | del | list 添加虛擬主機 | 刪除虛擬主機 | 查看虛擬主機列表
注:添加或刪除過虛擬主機域名婚惫,需要重新修改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控制臺
/phpstudy/mysql/bin/mysql -uroot -proot
手動搭建LAMP環(huán)境
安裝Apache
1魂爪、通過yum源安裝以httpd開頭的命名的軟件包先舷,在命令行下輸入:
yum install httpd
2、然后根據(jù)提示輸入相應(yīng)的命令進(jìn)行安裝操作
3滓侍、一些命令
#啟動apache
systemctl start httpd.service
#停止apache
systemctl stop httpd.service
#重啟apache
systemctl restart httpd.service
#設(shè)置apache開機啟動
systemctl enable httpd.service
- 安裝MariaDB
1蒋川、命令行下輸入:yum install mariadb mariadb-server
2、依舊是根據(jù)提示輸入相關(guān)命令進(jìn)行安裝操作
3撩笆、一些命令
systemctl start mariadb.service #啟動MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重啟MariaDB
systemctl enable mariadb.service #設(shè)置開機啟動
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è)置完成氮兵,重新啟動 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