connecting http service to mysql service
on this example information provides for the database server has ip address 192.168.1.100, and the web server has ip address 192.168.1.200
this tutorial is using oracle linux server 6 but this can be applied to rhel-based distributions
on the database server pcaccess your server,
$ mysql -u root mysql
create new database,
mysql>create database namedb;
create database user,
mysql>create user 'user'@'host_ip_addr_webserver' identified by 'password'
note : use sign '%' at host if you want your database server to be accessed from any IP's
give user created to access database,
mysql>grant all on namedb.* to 'user'@'host_ip_addr_webserver';
mysql>flush privileges;
mysql>exit
edit iptables to open port tcp:3306
on the web server pc
check first your pc can remotely access database on another pc
$ mysql -u user -h ip_addr_databaseserver -p
if success, continue to next step
here i use wordpress cms to gain access database on database server
edit wordpress configuration file, wp-config.php, locate line parameters below
/** MySQL hostname*/
Define('DB_HOST','localhost')
edit 'locahost' change to 'ip_addr_database_server'
edit selinux to allow web server to access database server
# setsebool -P httpd_can_network_connect_db=1
edit iptables to open port tcp:80
source selinux config :
http://stackoverflow.com/questions/4078205/php-cant-connect-to-mysql-with-error-13-but-command-line-can
this is tutorial to connecting htttpd and mysqld on separated pc (dedicated server)
this tutorial is using oracle linux server 6 but this can be applied to rhel-based distributions
on the database server pcaccess your server,
$ mysql -u root mysql
create new database,
mysql>create database namedb;
create database user,
mysql>create user 'user'@'host_ip_addr_webserver' identified by 'password'
note : use sign '%' at host if you want your database server to be accessed from any IP's
give user created to access database,
mysql>grant all on namedb.* to 'user'@'host_ip_addr_webserver';
mysql>flush privileges;
mysql>exit
edit iptables to open port tcp:3306
on the web server pc
check first your pc can remotely access database on another pc
$ mysql -u user -h ip_addr_databaseserver -p
if success, continue to next step
here i use wordpress cms to gain access database on database server
edit wordpress configuration file, wp-config.php, locate line parameters below
/** MySQL hostname*/
Define('DB_HOST','localhost')
edit 'locahost' change to 'ip_addr_database_server'
edit selinux to allow web server to access database server
# setsebool -P httpd_can_network_connect_db=1
edit iptables to open port tcp:80
source selinux config :
http://stackoverflow.com/questions/4078205/php-cant-connect-to-mysql-with-error-13-but-command-line-can
Comments
Post a Comment