阿里云服务器部署LAMP

阿里云部署LAMP

本实验是将本地部署的lamp环境 直接打包到阿里云上面运行

购买云服务器

选择一台离自己近的服务器
阿里云服务器部署LAMP

买一台2cpu 4Gn内存的云服务器!
阿里云服务器部署LAMP
选择CentOS 7.6
阿里云服务器部署LAMP
网络默认就行
阿里云服务器部署LAMP
流量视情况选择
阿里云服务器部署LAMP
安全组需要详细讲一下
阿里云服务器部署LAMP
这里需要自己授权开启想要的端口号
比如8080或者9000端口等 需要通过安全组授权开启 然后才能够使用 不然无法使用这些端口

阿里云服务器部署LAMP
后面的选项就默认或者自己选

准备LAMP源码包安装后的文件

# 1.打包LAMP软件 [root@lamp local]# mkdir bak [root@lamp local]# tar -czvf httpd.tar.gz httpd [root@lamp local]# mv *.tar.gz bak/ [root@lamp ~]# cp /lib/systemd/system/httpd.service /usr/local/bak/ [root@lamp ~]# cp /etc/init.d/mysqld /usr/local/bak/ [root@lamp ~]# cd /usr/local/bak [root@lamp bak]# ls httpd.service  httpd.tar.gz  mysqld  mysql.tar.gz  php5.tar.gz [root@lamp local]# tar -zcvf bak.tar.gz bak   # 将所有文件远程传输到云服务器 [root@lamp local]# scp bak.tar.gz root@47.108.193.85:/usr/local root@47.108.193.85's password:  bak.tar.gz 100%  339MB   4.0MB/s   01:24                                                                   

切换到云服务器

# 切换到云服务器 [root@lamp bak]# ls httpd.service  httpd.tar.gz  mysqld  mysql.tar.gz  php5.tar.gz [root@lamp bak]# mv httpd.service /lib/systemd/system/ [root@lamp bak]# mv mysqld /etc/init.d/ [root@lamp bak]# ls httpd.tar.gz  mysql.tar.gz  php5.tar.gz  [root@lamp bak]# tar xf httpd.tar.gz && tar xf mysql.tar.gz && tar xf php5.tar.gz  [root@lamp bak]# ls httpd  httpd.tar.gz  mysql  mysql.tar.gz  php5  php5.tar.gz [root@lamp bak]# mv * ../  # 安装依赖 yum install -y apr apr-devel  cyrus-sasl cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre zlib-devel  yum -y install autoconf	# 如果遇到报错 可以装这个  # 创建mysql用户和用户组 groupadd  mysql useradd -M -s /sbin/nologin mysql -g mysql  # 将mysql安装目录的权限改成mysql:mysql chown -R mysql:mysql mysql/  # 将mysql服务添加进系统服务 [root@lamp local]# chkconfig --add mysqld [root@lamp local]# chkconfig --list mysqld  Note: This output shows SysV services only and does not include native       systemd services. SysV configuration data might be overridden by native       systemd configuration.        If you want to list systemd services use 'systemctl list-unit-files'.       To see services enabled on particular target use       'systemctl list-dependencies [target]'.  mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off   # 添加环境变量 echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile  # 启动mysql [root@lamp support-files]# service mysqld start Starting MySQL.210316 18:26:34 mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists.  Create writable for user 'mysql'.The server quit without updating PID file (/var/lib/mysql/l[FAILED].   # 遇到报错 发现是有安装了mariadb # 卸载mariadb [root@lamp support-files]# yum list installed |grep mariadb mariadb-libs.x86_64                  1:5.5.60-1.el7_5                  @anaconda [root@lamp support-files]# yum remove mariadb-libs.x86_64  # 再次打开mysql [root@lamp support-files]# service mysqld start Starting MySQL SUCCESS!   mysql> show databases; +--------------------+ | Database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | test               | | wordpress          | +--------------------+ 5 rows in set (0.00 sec)  # 测试 [root@lamp htdocs]# usr/local/httpd/htdocs [root@lamp htdocs]# vim index.php  <?php phpinfo() ?> 

阿里云服务器部署LAMP
继续测试

[root@lamp htdocs]# vim index.php <?php $link=mysqli_connect('localhost','root','123'); if($link) echo "恭喜你,数据库连接成功啦!!"; mysqli_close($link); ?> 
阿里云服务器部署LAMP

部署博客

[root@lamp htdocs]# tar xf wordpress-4.9.4-zh_CN.tar.gz  [root@lamp htdocs]# ls index.php  wordpress  wordpress-4.9.4-zh_CN.tar.gz [root@lamp htdocs]# mv wordpress/* ./ mv: overwrite ‘./index.php’? y [root@lamp htdocs]# ls index.php    wordpress-4.9.4-zh_CN.tar.gz  wp-comments-post.php  wp-includes        wp-mail.php       xmlrpc.php license.txt  wp-activate.php               wp-config-sample.php  wp-links-opml.php  wp-settings.php readme.html  wp-admin                      wp-content            wp-load.php        wp-signup.php wordpress    wp-blog-header.php            wp-cron.php           wp-login.php       wp-trackback.php 
mysql> drop database wordpress; Query OK, 12 rows affected (0.05 sec).  mysql> create database wordpress; Query OK, 1 row affected (0.00 sec)  mysql> show databases; +--------------------+ | Database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | test               | | wordpress          | +--------------------+ 5 rows in set (0.00 sec)  mysql> use wordpress Database changed mysql> show tables; Empty set (0.00 sec) 
阿里云服务器部署LAMP
阿里云服务器部署LAMP

版权声明:玥玥 发表于 2021-03-26 15:07:31。
转载请注明:阿里云服务器部署LAMP | 女黑客导航