時間:2023-08-09 08:24:01 | 來源:網(wǎng)站運營
時間:2023-08-09 08:24:01 來源:網(wǎng)站運營
【實戰(zhàn)演練】Linux操作系統(tǒng)05-用LAMP搭建網(wǎng)站:#本文歡迎轉(zhuǎn)載,轉(zhuǎn)載請注明出處和作者。setenforce 0 vi /etc/selinux/config
修改selinux狀態(tài)disabledSELINUX=disabled
1、安裝apache(httpd)yum install httpd -y
啟動服務(wù)service httpd start
默認(rèn)的目錄在/var/www/html
將測試的carweb文件上傳到/software文件夾mv /software/carweb/* /var/www/html/
另外需要關(guān)閉防火墻,service iptables stop chkconfig iptables off
以及默認(rèn)開機(jī)啟動httpdchkconfig httpd on chmod 777 -R /var/www/html
檢驗apache服務(wù):yum install php -y
重啟httd服務(wù)service httpd restart
然后在/var/www/html目錄編輯php文件進(jìn)行測試。vim index-test.php
內(nèi)容如下:<?php phpinfo() ?>
然后瀏覽器重新訪問linux的IP地址,測試網(wǎng)頁打開是否變成了一個php的頁面。yum install php-mysql -y
-----------------------------------------------------------------------------------------------yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
-----------------------------------------------------------------------------------------------yum install mysql mysql-server -yservice mysqld startmysql_secure_installation
Mysql初始化配置,可以修改root的密碼。其他4個選項維持默認(rèn)。mysql -u root -p
輸入密碼登錄vi /etc/my.cnf
增加以下內(nèi)容:[mysqld] character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8
重啟mysql服務(wù)service mysqld restart
測試的網(wǎng)頁,需要手動新建數(shù)據(jù)庫,并且導(dǎo)入相關(guān)的sql源文件create database dqzqcw default character set utf8 collate utf8_bin;
#創(chuàng)建名為dqzqcw的數(shù)據(jù)庫grant all on dqzqcw.* to dqzqcw@localhost identified by 'password'; flush privileges;
#給賬號使用數(shù)據(jù)庫權(quán)限,并且刷新權(quán)限。use dqzqcw; source /software/qzqcw.sqlquit
#退出數(shù)據(jù)庫。cd /var/www/html/
進(jìn)入apache web目錄,修改名為config.php的文件vi config.php$db_config['DB_HOST'] = '10.1.30.28'
#數(shù)據(jù)庫地址,如果web與數(shù)據(jù)庫都在同一臺機(jī)器,可以寫localhost$db_config['DB_USER'] = 'dqzqcw';
#mysql帳號dqzqcw$db_config['DB_PASS'] = 'password';
#mysql密碼password$db_config['DB_NAME'] = 'dqzqcw';
#數(shù)據(jù)庫名稱service iptables stop
#當(dāng)前臨時關(guān)閉防火墻chkconfig iptables off
#永久開機(jī)自動關(guān)閉防火墻關(guān)鍵詞:操作,系統(tǒng),實戰(zhàn)
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。