Skip to main content

how to connect httpd service to mysqld service

connecting http service to mysql service


this is tutorial to connecting htttpd and mysqld on separated pc (dedicated server)

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

Comments

Popular posts from this blog

about gigabyte NIC onboard not detected on enterprise linux distribution

on several gigabyte motherboard, onboard network interface card  will not be detected on enterprise linux distribution (e.g. scientific linux, oracle linux server, etc). alternatively you must supply add-on card. or if you insist to use the onboard card, you must install the unofficial nic driver. this is tutorial how to install driver for onboard network interface card GIGABYTE first of all prepare your system. make sure it has package group "Development Tools" installed. if it has not, install it # yum groupinstall “Development Tools” download the source code : https://www.dropbox.com/s/na91bu4az4p9827/AR81Family-linux-v1.0.1.14.tar.gz extract the source code : # tar zxvf AR81Family-linux1.0.1.14.tar.gz the extraction process will make the new directory "AR81Family*", change to the directory # cd AR81Family* compile the source by type on terminal : # make then, # make install wait until the compiling process finish. next make the new scrip...

about getsebool and setsebool

The setsebool is used to set SELinux boolean value i.e. various configurations can be enabled or disabled using this tool. In other words, the setsebool command switches on and off the protection of SELinux. Type getsebool -a to see all such options which can be enabled or disabled at run time: e.g. # getsebool -a The following should give you a complete listing of all the vsftpd switches: e.g.  # getsebool -a | grep ftp  For example, if httpd_disable_trans set to 1, it will disable SELinux protection for  Apache web server. To disable it, enter:  # setsebool -P httpd_can_network_connect=1 To enable it, enter:    # setsebool -P httpd_can_network_connect=0

All certification