1.安裝apache
? ?1.1[root@localhost ~]# yum install httpd
? ?根據(jù)提示,輸入Y安裝即可成功安裝
?1.2 systemctl start httpd.service #啟動(dòng)apache
? ? ? ?systemctl stop httpd.service? ? #停止apache
? ? ? ?systemctl restart httpd.service #重啟apache
? ? ? ?systemctl enable httpd.service? #設(shè)置apache開機(jī)啟動(dòng)
centos7修改具體的apache配置 在etc/httpd/conf/httpd.conf目錄下常熙,
2.安裝mariadb(MySQL)操作和mysql一樣
? ? ? yum install mariadb mariadb-server ?#安裝mariadb
? ? ?詢問是否要安裝纬乍,輸入Y即可自動(dòng)安裝,直到安裝完成
? ? ?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)
3 如果需要安裝mysql需要去官網(wǎng)下載
? ? 3.1.下載 wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
? ? 3.2.rpm 安裝 mysql 相應(yīng)的 yum源: ? ?rpm -ivh mysql-community-release-el7-5.noarch.rpm
? ? 3.3.安裝mysql yum install mysql-community-server
? ?3.4.成功安裝之后重啟mysql服務(wù) service mysqld restart
? ?3.5 mysql -u root -p 進(jìn)入mysql 默認(rèn)密碼為空
? ?3.6 mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
????????mysql> exit ?搞定!
? ? ? (修改密碼時(shí)可能會(huì)報(bào)錯(cuò):Error (1133): Can’t find any matching row in the user table)
? ? ? ?在mysql命令行中執(zhí)行 FLUSH PRIVILEGES ?//刷新
????grant all on *.* to root identified by 'root'; ?//遠(yuǎn)程連接語句
4.安裝Php(由于yum自帶的php包版本過低裸卫,可選擇刪除重新安裝)
? ?4.1.刪除舊版本 yum remove php* php-common
? ?4.2.rpm 安裝 Php7 相應(yīng)的 yum源:rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
????提示錯(cuò)誤:
????error: Failed dependencies:
????epel-release >= 7 is needed by webtatic-release-7-3.noarch
????需要先安裝epel-release仿贬。
????1.安裝epel-release
????通過命令:
? ??yum -y install epel-release
????成功安裝。
? ?4.3.安裝phpyum install php70w
? 4.4.重啟apache systemctl restart httpd.service
? 4.5.寫一個(gè)php文件 vi /var/www/html/info.php ?
? 4.6 輸入本機(jī)IP/info.php墓贿,顯示phpinfo信息茧泪,至此apache,php OK了
php常用模塊(php70w-fpm nginx解析php的容器)這里安裝了 后面安裝nignx時(shí)? 直接調(diào)用就可以了
yum -y install php70w-devel php70w.x86_64php70w-cli.x86_64php70w-common.x86_64php70w-gd.x86_64php70w-ldap.x86_64php70w-mbstring.x86_64php70w-mcrypt.x86_64php70w-pdo.x86_64php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongo
安裝常用模塊
5,安裝nginx和php-fpm
? ? yum install -y nginx
? ? #設(shè)置nginx開機(jī)啟動(dòng)
? ? ?systemctl enable nginx
? ? ?#設(shè)置php-fpm開機(jī)啟動(dòng)
? ? ?? ?systemctl enable php-fpm
提示:
1聋袋,之前自己安裝的時(shí)候沒有注意php的版本队伟,apache安裝成功了但是卻不能解析php文件后面發(fā)現(xiàn)apache里沒有加載php_module,
可以使用httpd-M檢查是否安裝幽勒,有則代表安裝過嗜侮。然后安裝php7安裝的時(shí)候自動(dòng)就加上了,可能是版本過低的原因吧~~
2啥容,如果是阿里云服務(wù)器有可能你的數(shù)據(jù)庫一直連接不上锈颗,這時(shí)你應(yīng)該檢查下你阿里云服務(wù)器的安全組接口是否開啟,3306這個(gè)端口是否添加到安全組規(guī)則里
3咪惠,yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm 安裝php-fpm 進(jìn)程管理器
4,如果安裝好了 環(huán)境 執(zhí)行php文件 報(bào)403錯(cuò)誤 看看nginx.conf配置文件里 有沒有指定index.php
如 :location / {
? ? ? # root? html;
? ? ? index? index.html index.htm index.php;
? }
5击吱,如果安裝完執(zhí)行php文件 頁面顯示為空白的話打開php.ini的:
short_open_tag = On