熟悉LAMP使用场景
安装Apache2.4+及扩展
安装mysql或mariadb扩展
安装php7.X
配置apache虚拟主机【基于端口、ip地址、域名】
安装phpMyadmin并配置
发布应用程序进行测试、可以通过smb在windows中编辑程序
搭建过程比较简单,具体可以查看阿里相关的资源。
阿里云搭建lamp
Systemctl stop firewalld
Sentenforce 0
yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
systemctl start httpd
systemctl enable httpd
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-community-server
mysql -V
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
grep "password" /var/log/mysqld.log
mysql_secure_installation
yum install -y \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
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
php -v
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
systemctl restart httpd
mkdir -p /var/www/html/phpmyadmin
cd
wget https://files.phpmyadmin.net/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
mv phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/phpmyadmin
## 创建虚拟主机 ```
基于ip配置
<VirtualHost 192.168.128.129:80>
DocumentRoot "/var/www/html/wjw1"
ServerName www.wjw.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost 192.168.128.130:80>
DocumentRoot "/var/www/html/wjw2"
ServerName www.wjw.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
基于端口配置
Listen 8080
<VirtualHost 192.168.128.129:80>
DocumentRoot "/var/www/html/wjw1"
ServerName www.wjw.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost 192.168.128.129:8080>
DocumentRoot "/var/www/html/wjw2"
ServerName www.wjw.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
基于域名配置
<VirtualHost 192.168.128.129:80>
DocumentRoot "/var/www/html/wjw1"
ServerName www.wjw.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost 192.168.128.129:80>
DocumentRoot "/var/www/html/wjw2"
ServerName www.wjw.cn
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
Cd /var/www/html/wjw1
Cd /var/www/html/wjw2
Touch index.php
<?Php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) { die("连接失败: " . $conn->connect_error);} $sql = "SELECT id, firstname, lastname FROM MyGuests";$result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; }} else { echo "0 结果";}$conn->close();?>