-1

I am pretty new to linux and LAMP setup. I want to setup a LAMP environment with AP on one linux server and M on a different linux server. I have a hard time finding a relevant document with such a configuration.

I have done the following steps so far:

server1:

yum install -y httpd
/sbin/service httpd restart
yum install -y php php-mysql
sed -i "s/Listen 80/#Listen 80/g" /etc/httpd/conf/httpd.conf
yum install -y mod_ssl openssl
/sbin/service httpd restart
service iptables stop

I changed the ServerName in /etc/httpd/conf/httpd.conf from

#ServerName www.example.com:80

to

ServerName 172.32.35.14 (ip address of server1)
/sbin/service httpd restart

server2:

yum install -y mysql-libs
yum install -y mysql
yum install -y perl-DBI
yum install -y perl-DBD-MySQL
yum install -y mysql-server
/sbin/chkconfig mysqld on
/sbin/service mysqld start
mysql -u root  -e "CREATE USER 'mysqluser' IDENTIFIED by 'password'" 
mysql -u root  -e "CREATE USER 'mysqluser'@'localhost' IDENTIFIED by 'password'"
mysql -u root  -e "GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'localhost' WITH GRANT OPTION"
mysql -u root  -e "GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%' WITH GRANT OPTION"
mysql -u mysqluser -p password -e "CREATE DATABASE mysqldb" 
mysql -u mysqluser -p password mysqldb < /tmp/mysqlinstaller/world.sql
service iptables stop

Then I had these post configuration steps:

On server 2, where my mysql is installed, I did the following:

bind-address = 172.32.35.14 (ip of server 1 where apache/php are installed)
service mysql restart

But I am not able to establish a connection. Can you point out what I am missing and guide me please.

5
  • try if you can reach Mysql posrt using nc IPserver2 3306 &> /dev/null; echo $? on server 1 to try if you can access to server 2 Mysql port (3306 is default port, change value if you changed Mysql port). Result should be 1 if ok else it will output 0
    – Froggiz
    Nov 29, 2015 at 11:45
  • I got the response as 127
    – pradeep
    Nov 29, 2015 at 12:30
  • I see the following error when I restart mysqld - service mysqld restart Stopping mysqld: [ OK ] MySQL Daemon failed to start. Starting mysqld: [FAILED]
    – pradeep
    Nov 29, 2015 at 12:32
  • Check your mysql logs to know why (for the command nc IPserver2 3306 would be enought to get info if Mysql is reachable)
    – Froggiz
    Nov 29, 2015 at 12:36
  • I even couldnt reach my apache server... I tried 172.17.50.23... it just says Problem loading page... Seems like I missed something
    – pradeep
    Nov 29, 2015 at 12:49

1 Answer 1

2

You tried to bind MySQL to the wrong address.

bind-address = 172.32.35.14

This address specifies what IP address on that server which MySQL listens to and receives connections.

It should either remain unset, to listen on all interfaces, or set to the IP address of the server it's running on.

5
  • I did bind my MySQL server ip address and the mysqld service has started successfully. Thanks. But still I am not able to access the apache server via 172.17.50.23.
    – pradeep
    Nov 29, 2015 at 14:09
  • And one basic question.. sorry for that... but my MySQL is remote. How will my apache server know to communicate with MySQL if I dont provide an IP
    – pradeep
    Nov 29, 2015 at 14:10
  • Apache does not communicate with your database server. Your application does. So you need to configure your application accordingly.
    – EEAA
    Nov 29, 2015 at 14:47
  • oh ok. Got it. Can you please help me with the access to my apache/php server via url
    – pradeep
    Nov 29, 2015 at 14:56
  • enabled the port 80 and gave the ServerName 172.32.35.14. I have a sample info.php with the following code <?php phpinfo(); ?> inside. Changed the permissions to 777 and tried to access 172.32.35.14/info.php. But in vain. Problem loading page :(
    – pradeep
    Nov 29, 2015 at 15:40

Not the answer you're looking for? Browse other questions tagged .