网站部署---LAMP环境部署PHP网站
系统环境要求
centos7,yum源正常使用,ip设置为:192.168.8.201;
LAMP环境配置
###软件环境设置
systemctl disable firewalld;systemctl stop firewalld;systemctl status firewalld
setenforce 0;getenforce;sed -i 's/SELINUX=enable/SELINUX=disabled/g' /etc/selinux/config
more /etc/selinux/config
###安装基础软件
yum -y install net-tools vim-enhanced wget lrzsz bash-completion unzip #补全功能需切换终端或重启;
yum list net-tools vim-enhanced wget lrzsz bash-completion unzip
###安装lamp组件及相关插件;
yum -y install httpd php mariadb mariadb-server php-mysql php-gd php-mbstring
yum list httpd php mariadb mariadb-server php-mysql php-gd php-mbstring
systemctl enable httpd mariadb;systemctl start httpd mariadb;systemctl status httpd mariadb
netstat -anptu |grep httpd;netstat -anptu |grep mysqld
###配置php.ini以便调试网站;
sed -i 's/display_errors = Off/display_errors = On/' /etc/php.ini
sed -i 's/display_startup_errors = Off/display_startup_errors = On/' /etc/php.ini
sed -i 's/\;date\.timezone \=/date\.timezone \= "PRC"/' /etc/php.ini
systemctl restart httpd;systemctl status httpd
###~~~测试网站是否正常;
curl http://127.0.0.1
cd /var/www/html
cat >index.php<<eof
<?php
phpinfo();
?>
eof
more index.php
curl http://127.0.0.1 #测试网站是否支持php;
数据库初始化
###mysql安全初始化
# mysql_secure_installation
mysql -e "drop database test;";mysql -e "show databases;" #删除test库及访问权限;
mysql -e 'drop user ""@localhost;' #移除匿名用户,默认4个root账户,2个匿名用户;
mysql -e 'delete from mysql.user where User="" and Host="localhost.localdomain"; ' #删除匿名用户;
mysql -e 'select User,authentication_string,Host from mysql.user;' #查看用户及登录ip;
mysql -e "SHOW GRANTS FOR 'root'@'localhost';" #查看mysql用户权限;
mysql -e "create database ecshop;" #创建数据库;
mysql -e "flush privileges;" #刷新配置;
mysqladmin -uroot password 123456;history -c #设置用户密码;
网站安装
# ~~~上传网站源码,解压、修改文件权限;
cd /var/www/html/;mkdir opensns;
unzip -d ./opensns opensns.zip
id apache;chown -R apache:apache /var/www/html/opensns
ll !$
chmod -R 754 /var/www/html/opensns/Data/
web界面配置网站
find ./ -name install #查找网站安装页面;
登录网站安装页面,如下图。
登录网站后台
登录网站前台