一、關(guān)閉防火墻 1.查看防火墻狀態(tài) systemctl status firewalld
2.關(guān)閉防火墻 systemctl stop firewalld 3.永久關(guān)閉防火墻 systemctl disable firewalld 二、安裝Apache 1.安裝Apache服務(wù)及擴(kuò)展包 yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql 2.啟動(dòng)Apache服務(wù) systemctl start httpd 3.設(shè)置Apache服務(wù)開機(jī)自啟動(dòng) systemctl enable httpd 4.查看apache是否安裝成功 在瀏覽器地址欄輸入 http://ip地址,運(yùn)行,出現(xiàn)如下頁面即安裝成功 ? ? 三、安裝并配置MySQL ? 1.更新YUM源 rpm -Uvh http://dev./get/mysql57-community-release-el7-9.noarch.rpm 2.安裝MySQL yum -y install mysql-community-server 如果出現(xiàn)”No match for argument“錯(cuò)誤,請先運(yùn)行yum module disable mysql禁用默認(rèn)的mysql模塊,再安裝MySQL 3.查看MySQL版本號(hào) mysql -V 出現(xiàn)如下信息即表示安裝成功,注意”V“要大寫 ? ? ?4.啟動(dòng)mysql systemctl start mysqld 5.設(shè)置開機(jī)自啟動(dòng) systemctl enable mysqld systemctl daemon-reload 6.查看初始密碼 grep "password" /var/log/mysqld.log 7.配置MySQL的安全性 mysql_secure_installation
Enter password for user root: #輸入上一步獲取的root用戶初始密碼 The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? (Press y|Y for Yes, any other key for No) : Y #是否更改root用戶密碼,輸入Y New password: #輸入新密碼,長度為8至30個(gè)字符,必須同時(shí)包含大小寫英文字母、數(shù)字和特殊符號(hào)。特殊符號(hào)可以是()` ~!@#$%^&*- =|{}[]:;‘<>,.?/ Re-enter new password: #再次輸入新密碼 Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y #是否刪除匿名用戶,輸入Y Success.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root遠(yuǎn)程登錄,輸入Y Success.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否刪除test庫和對它的訪問權(quán)限,輸入Y - Dropping test database... Success.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加載授權(quán)表,輸入Y Success. All done! 四、安裝PHP 1.更新YUM源
yum install -y https://repo./ius-release-el7.rpm https://dl./pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror./yum/el7/webtatic-release.rpm 2.安裝PHP yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb 3.查看PHP版本 php -v 出現(xiàn)如下結(jié)果即表示php安裝成功 4.在Apache網(wǎng)站根目錄創(chuàng)建測試文件 echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php 5.重啟Apache服務(wù) systemctl restart httpd 6.運(yùn)行。在瀏覽器地址欄輸入http://ip地址/phpinfo.php,出現(xiàn)如下頁面即表示安裝成功 ? ? ?五、安裝phpMyAdmin 1.創(chuàng)建phpMyAdmin數(shù)據(jù)存放目錄 mkdir -p /var/www/html/phpmyadmin 2.下載phpMyAdmin壓縮包并解壓
wget https://files./phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip
yum install -y unzip unzip phpMyAdmin-4.0.10.20-all-languages.zip 3.復(fù)制phpMyAdmin文件到準(zhǔn)備好的數(shù)據(jù)存放目錄 mv phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/phpmyadmin 4.檢查是否安裝成功。在瀏覽器地址欄輸入http://ip地址/phpmyadmin,運(yùn)行,出現(xiàn)如下頁面即表示安裝成功
? LAMP環(huán)境配置完成! 如果使用navicat連接數(shù)據(jù)庫報(bào)錯(cuò),ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server,是無法給遠(yuǎn)程連接的用戶權(quán)限問題,就是”7.配置MySQL的安全性“中第三步設(shè)置了禁止遠(yuǎn)程登陸 解決辦法: mysql -u root -p密碼 進(jìn)入Mysql控制臺(tái)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
flush privileges;來源:https://www./content-3-781951.html |
|