Centos 7 PHP开发环境搭建
軟件包安裝
安裝Apache
shell# yum install httpd安裝完成之后使用以下命令查看Apache版本
shell# apachectl -v安裝MySQL
由于Centos不再提供MySQL安裝包,需要配置yum源
shell# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm shell# rpm -ivh mysql57-community-release-el7-7.noarch.rpm接下來安裝MySQL
shell# yum install mysql-community-server安裝PHP
由于Centos 7提供的PHP版本與需求不一致,需要配置第三方y(tǒng)um源
shell# wget https://mirror.webtatic.com/yum/el7/epel-release.rpm shell# wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm shell# rpm -ivh epel-release.rpm shell# rpm -ivh webtatic-release.rpm安裝PHP及一些需要的擴(kuò)張
shell# yum install php56w php56w-mysqlnd php56w-gd php56w-mbstringPHP配置
#/etc/php.ini date.timezone = Asia/ShanghaiMySQL配置
配置默認(rèn)字符集
#/etc/my.cnf #在mysqld下添加character_set_server配置參數(shù) [mysqld] #... character_set_server=utf8 #... #添加mysql和client配置項(xiàng),并設(shè)置默認(rèn)字符集 [mysql] default-character-set = utf8[client] default-character-set = utf8設(shè)置root用戶密碼
啟動(dòng)mysql服務(wù)
shell# service mysqld start從/var/log/mysqld.log查找默認(rèn)的root用戶密碼
shell# grep 'temporary password' /var/log/mysqld.log修改密碼
shell# mysqladmin -uroot -p 'old-password' password 'new-password'配置sql_mode
在開發(fā)過程中,因?yàn)椴蝗胹elect字句中的列作為group by字句的參數(shù),因此需要把ONLY_FULL_GROUP_BY配置參數(shù)去掉。
在MySQL終端使用以下命令查看當(dāng)前的sql_mode配置,將ONLY_FULL_GROUP_BY以外的配置參數(shù)復(fù)制下來
將上面復(fù)制下來的內(nèi)容填寫到MySQL配置文件中
#/etc/my.cnf #在mysqld下添加sql_mode配置參數(shù) [mysqld] #... sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION其他
開放80端口。因?yàn)镃entos 7默認(rèn)只開放了ssh訪問端口,想要訪問WEB服務(wù)器,需在iptables中打開80端口。
shell# iptables -A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT配置httpd開機(jī)啟動(dòng)。安裝Apache服務(wù)后并沒有自動(dòng)將httpd服務(wù)添加到開機(jī)啟動(dòng)配置中,因此需手動(dòng)配置。
shell# systemctl enable httpd目錄寫入權(quán)限。因?yàn)镃entos默認(rèn)開啟SELinux,因此如果想在WEB目錄下寫入文件(如緩存/日志文件),則需要給該目錄設(shè)置SELinux對(duì)應(yīng)的權(quán)限。如下:
shell# chcon -R -t httpd_sys_content_rw_t runtime shell# chmod 757 runtime總結(jié)
以上是生活随笔為你收集整理的Centos 7 PHP开发环境搭建的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jmp指令流程图怎么写_策划新人分享——
- 下一篇: php新浪微博第三方登录接口,手机第三方