Aliyun Linux 服务器安装mysql + apache + php
第一步,打开mac终端
ssh root@公网ip地址
password 服务器登录密码
第二步,安装apache
yum install httpd #根据提示输入y
配置域名
vi /etc/httpd/conf/httpd.conf #点i进入编辑模式
找到 #servername www.example.com:80
修改为 #servername www.subai.com #自己的域名,没有就设置localhost
按shift+:进入命令行模式
wq保存退出
chkconfig httpd on #设为开机启动
service httpd start
提示你 redirecting to /bin/systemctl start httpd.service
根据提示/bin/systemctl start httpd.service
之后就可以用systemctl start httpd来启动了
可以使用service httpd status查看apache状态
第二步,安装mysql
安装wget命令
yum -y install wget
下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
查看一下
ls -1 /etc/yum.repos.d/mysql-community*
显示
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo
安装mysql
yum install mysql-server
第三步,安装php
yum install php #根据提示输入Y直到安装完成
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #这里选择以上安装包进行安装,根据提示输入Y回车
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche
第四步,编辑一个php程序
cd /var/www/html
vi index.php #编辑输入下面内容
<?php
echo "hello my server!";
?>
:wq! #保存退出
注意:vi 进入编辑器,i进入编辑模式,shift+:进入命令行模式