之前的文章写了apache的SSL部署方法,但是没有LAMP环境的部署,在这里补上。
预装环境
yum install -y vim
#backspace正常使用
echo "stty erase ^H" >> ~/.bash_profile
source ~/.bash_profile
#安装lrzsz实现上传下载
yum install -y man man-pages man-pages-overrides
yum install -y lrzsz
#网络工具安装
yum install -y net-tools
防火墙设置
systemctl start firewalld.service
systemctl enable firewalld.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Apache和php环境
yum -y install httpd php php-devel php-gd php-mcrypt php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext
安装完成后,需要启动并设置Apache开机启动:
systemctl enable httpd.service
systemctl start httpd.service
cat > /var/www/html/index.php<<EEE
<?php
phpinfo();
EEE
浏览器输入ip地址即可访问,获取php的信息
echo >> /etc/httpd/conf/httpd.conf 'include vhost-conf.d/*.conf '
mkdir /etc/httpd/vhost-conf.d
mkdir /var/www/html/apache.shadowwu.club
cat > /etc/httpd/vhost-conf.d/example.conf<<EEE
<VirtualHost *:80>
ServerName apache.shadowwu.club
ServerAlias apache.shadowwu.club
DocumentRoot /var/www/html/apache.shadowwu.club/
DirectoryIndex index.html index.php
</VirtualHost>
EEE
cat > /var/www/html/apache.shadowwu.club/index.html<<EEE
Hello,this is a apache web.
EEE
systemctl restart httpd.service
mysql环境安装
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
tar -xvf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
rm -f *.gz
mv mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf -y
安装mysql依赖
yum -y install autoconf
yum install -y libaio
安装mysql
/usr/local/mysql/scripts/mysql_install_db --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#清空配置文件
cat /dev/null >/etc/my.cnf
#填写配置
cat > /etc/my.cnf<<EEE
[client]
socket=/tmp/mysql.sock
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
skip-name-resolve
user = root
#设置3306端口
port = 3306
socket=/tmp/mysql.sock
#设置mysql的安装目录
basedir=/usr/local/mysql
#设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
#允许最大连接数\nmax_connections=200
#服务端使用的字符集默认 为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
EEE
chmod 644 /etc/my.cnf
#复制服务脚本,进系统环境
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
#赋予服务控制执行脚本的权利
chmod +x /etc/rc.d/init.d/mysqld
#配置环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> ~/.bash_profile
#使环境变量生效
source ~/.bash_profile
#添加服务进系统服务
chkconfig --add mysqld
systemctl start mysqld
mysql密码权限配置
mysql
>set password = password('ssssss');
>exit;
开启root访问权限示
mysql -u root -pssssss
>grant all privileges on *.* to 'root'@'%' identified by 'ssssss' with grant option;
>> flush privileges;
>>exit;
LAMP一键脚本及注释
yum install -y vim
#backspace正常使用
echo "stty erase ^H" >> ~/.bash_profile
source ~/.bash_profile
#安装lrzsz实现上传下载
yum install -y man man-pages man-pages-overrides
yum install -y lrzsz
#网络工具安装
yum install -y net-tools
#防火墙设置
systemctl start firewalld.service
systemctl enable firewalld.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
## Apache和php环境
yum -y install httpd php php-devel php-gd php-mcrypt php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext
安装完成后,需要启动并设置Apache开机启动:
systemctl enable httpd.service
systemctl start httpd.service
cat > /var/www/html/index.php<<EEE
<?php
phpinfo();
EEE
echo >> /etc/httpd/conf/httpd.conf 'include vhost-conf.d/*.conf '
mkdir /etc/httpd/vhost-conf.d
mkdir /var/www/html/apache.shadowwu.club
cat > /etc/httpd/vhost-conf.d/example.conf<<EEE
<VirtualHost *:80>
ServerName apache.shadowwu.club
ServerAlias apache.shadowwu.club
DocumentRoot /var/www/html/apache.shadowwu.club/
DirectoryIndex index.html index.php
</VirtualHost>
EEE
cat > /var/www/html/apache.shadowwu.club/index.html<<EEE
Hello,this is a apache web.
EEE
systemctl restart httpd.service
## mysql环境安装
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
tar -xvf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
rm -f *.gz
mv mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf -y
## 安装mysql依赖
yum -y install autoconf
yum install -y libaio
## 安装mysql
/usr/local/mysql/scripts/mysql_install_db --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#清空配置文件
cat /dev/null >/etc/my.cnf
#填写配置
cat > /etc/my.cnf<<EEE
[client]
socket=/tmp/mysql.sock
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
skip-name-resolve
user = root
#设置3306端口
port = 3306
socket=/tmp/mysql.sock
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数\nmax_connections=200
# 服务端使用的字符集默认 为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
EEE
chmod 644 /etc/my.cnf
#复制服务脚本,进系统环境
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
#赋予服务控制执行脚本的权利
chmod +x /etc/rc.d/init.d/mysqld
#配置环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> ~/.bash_profile
#使环境变量生效
source ~/.bash_profile
#添加服务进系统服务
chkconfig --add mysqld
systemctl start mysqld
Apache配置文件位置
/etc/httpd/conf/httpd.conf
网站配置文件夹位置
/etc/httpd/vhost-conf.d
php配置文件位置
/etc/php.ini
mysql配置文件路径
/etc/my.cnf
mysql数据存贮位置
/usr/local/mysql/data