LAMP环境YUM安装Linux(Centos7.0)

安装Apache, PHP, MySQL以及php连接mysql库组件

    yum -y install httpd php mysql mysql-server mariadb-server php-mysql

安装apache扩展

    yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

安装php的扩展

    yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

安装MySQL的扩展

    yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

说明:
Apache默认站点/var/www/html
Apache的配置文件/etc/httpd/conf.d/vhosts.conf(新建vhosts.conf)
mysql密码设置:

[root@JiangGS ~]# systemctl start mariadb.service

[root@JiangGS ~]# mysql

MariaDB [mysql]> use mysql;
MariaDB [mysql]> UPDATE user SET password=password('newpassword') WHERE user='root';
MariaDB [mysql]> flush privileges; [重载权限]
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'newpassword' WITH GRANT OPTION; [增加远程链接用户]
MariaDB [mysql]> exit;[退出]

配置只有域名可以访问网站:

配置路径:/etc/httpd/conf.d/vhosts.conf //新建vhosts.conf

//禁止IP访问网站

NameVirtualHost 121.*.*.* //服务器外网IP
<VirtualHost 121.*.*.*>
ServerName 121.*.*.*
<Location />
Order Allow,Deny
Deny from all
</Location>
</VirtualHost>

//允许域名访问网站

<VirtualHost 121.*.*.*>
DocumentRoot "/var/www/html" //网站根目录
ServerName www.jianggangsheng.com //域名
</VirtualHost>

发表新评论