• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

Probleme mit apache2, php5, mysql

  • Ersteller User 79207
  • Erstellt am

User 79207

Gast
Probleme mit apache2, php5, mysql - solved!

Hallo zusammen,

ich bin seit zwei Tagen stolzer Besitzer eines MacMinis. Hätte ich gewußt wie endgeil das Apple OS ist, wäre ich schon früher umgestiegen.

Jetzt bin ich dabei mir einen Webserver zu bauen. Ich kenne Mamp, Xampp und den bereits installierten apache Webserver.

Allerdings möchte ich gerne (fühle mich dabei besser ;) ) den Webserver, wie auf meiner Linux Kiste (die ich weggehaun hab seit gestern), selber aufsetzen.

Ich hab mir die Sourcen (Quellcode) heruntergeladen, übersetzt und nach /usr/local installiert.

Jetzt hab ich nur das Problem, das ich es einfach nicht schaffe, den apache2 und mysql beim booten automatisch zu starten. Ich benutze „Property List Editor“, hau das xy.plist file nach /Library/LaunchAgents und mach „sudo launchctl load /Library/LaunchAgents/xy.plist“. Leider kommen diverse Fehlermeldungen höchstwahrscheinlich wegen fehlenden Rechten.

Ich schreib mal auf was ich genau gemacht habe: :)

1. Ich hab die Mac Developer Tools (Xcode) installiert, sonst kann ich keine Programme übersetzen. Quelle: http://developer.apple.com/tools/

2. apache2, Quelle: http://httpd.apache.org/download.cgi (Unix Source)
Übersetzt mit:
Code:
# ./configure --enable-so
# make
# sudo make install
3. mysql, Quelle: http://www.mysql.de
Übersetzt mit: (Dauert mit test ewig, ca. 60 Minuten)
Code:
# CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --disable-shared

# make
# (sudo?) make test
# sudo make install
Rechte anpassen:
Code:
# chown -R mysql /usr/local/mysql/var
# chgrp -R mysql /usr/local/mysql/var
Tabellen erstellen:
Code:
#(sudo?) /usr/local/mysql/bin/mysql_install_db
(#(sudo?) /usr/local/mysql/bin/mysql_upgrade)
Passwort ändern:
Code:
#(sudo?) /usr/local/mysqladmin -u root password hierneuespasswort
4. gd, Quelle: http://www.libgd.org/Main_Page
Code:
# ./configure
# make
# sudo make install
5. freetype, Quelle: http://www.freetype.org/
Code:
# ./configure
# make
# sudo make install
6. libpng, Quelle: http://libpng.org/pub/png/libpng.html
Code:
# ./configure
# make
# sudo make install
7. gettext, Quelle: http://www.gnu.org/software/gettext/
Code:
# ./configure
# make
# sudo make install
8. mcrypt, Quelle: http://mcrypt.sourceforge.net/
Code:
# ./configure
# make
# sudo make install
9. php, Quelle: http://www.php.net/
Code:
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-debug --enable-sigchild --enable-magic-quotes --enable-bcmath --with-bz2 --enable-calendar --enable-ctype --with-curl --enable-dba --enable-exif --enable-ftp --with-gettext --with-mhash --with-iconv --enable-mbstring --with-mcrypt --with-mime-magic --enable-sockets --enable-inline-optimization --enable-mbstring --enable-shmop --enable-wddx --with-regex=php --with-xsl --with-ttf --with-freetype-dir --with-mysql=/usr/local/mysql --without-mysqli --without-pear --with-zlib --with-gd

# make
# (sudo?) make test
# sudo make install
10. php in apache aktivieren:
Code:
# sudo nano /usr/local/apache2/conf/httpd.conf
-> Listen 8080
-> LoadModule php5_module modules/libphp5.so
-> <IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
-> AddType text/html .php

11. Symbolischen Link erstellen:

Code:
# ln -s ~/htdocs /usr/local/apache2/htdocs
12. phpmyadmin, Quelle: http://www.phpmyadmin.net/home_page/index.php

OK, so weit so gut, mit:

Code:
# sudo /usr/local/apache2/bin/apachectl -k start
und
Code:
# sudo /usr/local/mysql/bin/mysqld_safe
kann ich meinen Webserver problemlos starten.

Um jetzt das ganze automatisch beim booten zu starten habe ich folgendes gemacht.

Ich habe zwei Files mit dem Editor erstellt.

apache2.plist mit dem Inhalt:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>RunAtLoad</key>
    <true/>
    <key>Label</key>
    <string>apache2</string>
    <key>Program</key>
    <string>/usr/local/apache2/bin/startapache2.sh</string>
</dict>
</plist>
mysql.plist mit dem Inhalt:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>RunAtLoad</key>
    <true/>
    <key>Label</key>
    <string>mysql</string>
    <key>Program</key>
    <string>/usr/local/mysql/bin/startmysql.sh</string>
</dict>
</plist>
startapache2.sh Inhalt:
Code:
#!/bin/bash
/usr/local/apache2/bin/apachectl -k start
startmysql.sh Inhalt:
Code:
#!/bin/bash
/usr/local/mysql/bin/mysqld_safe
Nach einem restart bekomme ich folgende Meldungen im /var/log/system.log:


Code:
May  3 00:46:56 andreas-rexs-mac-mini com.apple.launchd[68] (mysql[84]): posix_spawn("/usr/local/mysql/bin/startmysql.sh", ...): Permission denied
May  3 00:46:56 andreas-rexs-mac-mini com.apple.launchd[68] (mysql[84]): Exited with exit code: 1
May  3 00:47:01 andreas-rexs-mac-mini apache2[83]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 00:47:01 andreas-rexs-mac-mini apache2[83]: Unable to open logs
May  3 00:47:01 andreas-rexs-mac-mini com.apple.launchd[68] (apache2[83]): Exited with exit code: 1
Ich hab die rechte in /usr/local/apache2/logs angepasst, ich hab den user und die gruppe _www zugeteilt.

Zudem hab ich das Problem, das ich mit einem selbst erstellen sql user nicht auf die Datenbank zugreifen kann, ich bekomm die Meldung:

Access denied for user xy on localhost (ähnlich)

Hab den Port in meinen php settingfile auf 8080 gesetzt.


Ich denk ich hab einfach Rechte Probleme. Leider kenn ich mich nicht so gut aus, hab den Mac ja erst seit neuestem und möchte jetzt nicht wild mit rechten rumspielen.

Ich denke es wäre schonmal viel geschafft, wenn die zwei Start scripts als root ausgeführt werden würden. Leider konnte ich dazu nichts ergoogeln.


Dann hab ich noch das Problem, das meine php Dateien einfach nicht angezeigt werden, sie bleiben leer. Aber ich denk das ist erstmal mein Problem.


Edit:

OK, hab wenigstens eins bis jetzt geschafft, ich kann mit meinem User xy auf die Datenbank über php zugreifen. Ich musste bei phpMyAdmin nur einstellen, das der User vom Host "lokalhost" zugriff hat.

Es fehlt nur noch, das ich apache2 und mysql automatisch starten kann. Wäre echt super, wenn mir da jemand helfen könnte. Danke.

Edit2:

Hab jetzt die zwei .plist files angepaßt, bringt immer noch nix

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>mysql</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/mysql/bin/mysqld_safe</string>
    </array>
    <key>SHAuthorizationRight</key>
    <string>system.preferences</string>
</dict>
</plist>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>apache2</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/apache2/bin/httpd</string>
        <string>-D</string>
        <string>FOREGROUND</string>
    </array>
    <key>SHAuthorizationRight</key>
    <string>system.preferences</string>
</dict>
</plist>
Log:
Code:
May  3 03:25:40 andreas-rexs-mac-mini com.apple.launchd[63] (apache2): Unknown key: SHAuthorizationRight
May  3 03:25:40 andreas-rexs-mac-mini com.apple.launchd[63] (mysql): Unknown key: SHAutorizationRight
May  3 03:25:40 andreas-rexs-mac-mini com.apple.launchd[63] (com.apple.AirPortBaseStationAgent): Unknown key for boolean: EnableTransactions
May  3 03:25:41 andreas-rexs-mac-mini apache2[81]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 03:25:41 andreas-rexs-mac-mini apache2[81]: Unable to open logs
May  3 03:25:41 andreas-rexs-mac-mini com.apple.launchd[63] (apache2[81]): Exited with exit code: 1
May  3 03:25:41 andreas-rexs-mac-mini com.apple.launchd[63] (apache2): Throttling respawn: Will start in 9 seconds
May  3 03:25:41 andreas-rexs-mac-mini mysql[82]: 090503 03:25:41 mysqld_safe Logging to '/usr/local/mysql/var/andreas-rexs-mac-mini.local.err'.
May  3 03:25:41 andreas-rexs-mac-mini mysql[82]: touch: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:42 andreas-rexs-mac-mini mysql[82]: 090503 03:25:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
May  3 03:25:42 andreas-rexs-mac-mini mysql[82]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:42 andreas-rexs-mac-mini mysql[82]: /usr/local/mysql/bin/mysqld_safe: line 137: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:42 andreas-rexs-mac-mini mysql[82]: 090503 03:25:42 mysqld_safe mysqld from pid file /usr/local/mysql/var/andreas-rexs-mac-mini.local.pid ended
May  3 03:25:42 andreas-rexs-mac-mini mysql[82]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:42 andreas-rexs-mac-mini com.apple.launchd[63] (mysql[82]): Exited with exit code: 1
May  3 03:25:42 andreas-rexs-mac-mini com.apple.launchd[63] (mysql): Throttling respawn: Will start in 8 seconds
May  3 03:25:42 andreas-rexs-mac-mini /System/Library/CoreServices/coreservicesd[45]: SFLSharePointsEntry::CreateDSRecord: dsCreateRecordAndOpen(Andreas Rexs öffentlicher Ordner) returned -14135
May  3 03:25:50 andreas-rexs-mac-mini apache2[152]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 03:25:50 andreas-rexs-mac-mini apache2[152]: Unable to open logs
May  3 03:25:50 andreas-rexs-mac-mini com.apple.launchd[63] (apache2[152]): Exited with exit code: 1
May  3 03:25:50 andreas-rexs-mac-mini com.apple.launchd[63] (apache2): Throttling respawn: Will start in 10 seconds
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: 090503 03:25:50 mysqld_safe Logging to '/usr/local/mysql/var/andreas-rexs-mac-mini.local.err'.
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: touch: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: 090503 03:25:50 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: /usr/local/mysql/bin/mysqld_safe: line 137: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: 090503 03:25:50 mysqld_safe mysqld from pid file /usr/local/mysql/var/andreas-rexs-mac-mini.local.pid ended
May  3 03:25:50 andreas-rexs-mac-mini mysql[153]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:25:50 andreas-rexs-mac-mini com.apple.launchd[63] (mysql[153]): Exited with exit code: 1
May  3 03:25:50 andreas-rexs-mac-mini com.apple.launchd[63] (mysql): Throttling respawn: Will start in 10 seconds
May  3 03:26:00 andreas-rexs-mac-mini apache2[200]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 03:26:00 andreas-rexs-mac-mini apache2[200]: Unable to open logs
May  3 03:26:00 andreas-rexs-mac-mini com.apple.launchd[63] (apache2[200]): Exited with exit code: 1
May  3 03:26:00 andreas-rexs-mac-mini com.apple.launchd[63] (apache2): Throttling respawn: Will start in 10 seconds
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: 090503 03:26:00 mysqld_safe Logging to '/usr/local/mysql/var/andreas-rexs-mac-mini.local.err'.
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: touch: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: 090503 03:26:00 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: /usr/local/mysql/bin/mysqld_safe: line 137: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: 090503 03:26:00 mysqld_safe mysqld from pid file /usr/local/mysql/var/andreas-rexs-mac-mini.local.pid ended
May  3 03:26:00 andreas-rexs-mac-mini mysql[201]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:00 andreas-rexs-mac-mini com.apple.launchd[63] (mysql[201]): Exited with exit code: 1
May  3 03:26:00 andreas-rexs-mac-mini com.apple.launchd[63] (mysql): Throttling respawn: Will start in 10 seconds
May  3 03:26:10 andreas-rexs-mac-mini apache2[246]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 03:26:10 andreas-rexs-mac-mini apache2[246]: Unable to open logs
May  3 03:26:10 andreas-rexs-mac-mini com.apple.launchd[63] (apache2[246]): Exited with exit code: 1
May  3 03:26:10 andreas-rexs-mac-mini com.apple.launchd[63] (apache2): Throttling respawn: Will start in 10 seconds
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: 090503 03:26:10 mysqld_safe Logging to '/usr/local/mysql/var/andreas-rexs-mac-mini.local.err'.
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: touch: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: 090503 03:26:10 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: /usr/local/mysql/bin/mysqld_safe: line 137: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: 090503 03:26:10 mysqld_safe mysqld from pid file /usr/local/mysql/var/andreas-rexs-mac-mini.local.pid ended
May  3 03:26:10 andreas-rexs-mac-mini mysql[247]: /usr/local/mysql/bin/mysqld_safe: line 100: /usr/local/mysql/var/andreas-rexs-mac-mini.local.err: Permission denied
May  3 03:26:10 andreas-rexs-mac-mini com.apple.launchd[63] (mysql[247]): Exited with exit code: 1
May  3 03:26:10 andreas-rexs-mac-mini com.apple.launchd[63] (mysql): Throttling respawn: Will start in 10 seconds
May  3 03:26:16 andreas-rexs-mac-mini com.apple.launchctl.System[2]: BootCacheControl: could not fetch history: Cannot allocate memory
May  3 03:26:16 andreas-rexs-mac-mini com.apple.launchctl.System[2]: BootCacheControl: could not stop cache/fetch history: Cannot allocate memory
May  3 03:26:20 andreas-rexs-mac-mini apache2[294]: (13)Permission denied: httpd: could not open error log file /usr/local/apache2/logs/error_log.
May  3 03:26:20 andreas-rexs-mac-mini apache2[294]: Unable to open logs
May  3 03:26:20 andreas-rexs-mac-mini com.apple.launchd[63] (apache2[294]): Exited with exit code: 1
Edit 3:

lol, geschafft!

Ich hab die zwei .plist dateien in /Library/LaunchDaemons verschoben. Jetzt gehts :)

Als Anmerkung, hab php5 nochmal übersetzt mit:

Code:
./configure --disable-dependency-tracking --with-apxs2=/usr/local/apache2/bin/apxs --with-ldap --with-kerberos --enable-cli --with-zlib --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring=all --enable-mbregex --enable-dbx --enable-sockets --with-iodbc --with-curl --with-mysql-sock  --with-mysql=/usr/local/mysql --with-openssl --with-xmlrpc --with-xsl --with-pear --with-gd  --with-png-dir --with-db --with-ttf --with-mcrypt --enable-dbase --enable-memory-limit --enable-calendar --enable-wddx --enable-bcmath --enable-gd-imgstrttf --enable-shmopt --enable-mhash --with-mhash --with-openssl --enable-xslt --with-xslt-sablot --with-dom --with-dom-xslt --with-dom-exslt  --with-iconv --with-freetype-dir --with-bz2 --with-gettext --enable-exif --with-idn --with-kerberos --with-zip
Mit der Quelle: http://qdbm.sourceforge.net/

Edit 4:

Um das ganze abzuschließen, ich hab noch aus den Sourcen die Datei php.ini-dist genommen und nach /usr/local/lib/php.ini kopiert. Jetzt bleiben die Dateien auch nicht mehr leer :)
Dann noch den Webserver neu gestartet mit: sudo /usr/local/apache2/bin/apachectl -k restart

Ich bin jetzt rundum zufrieden, bis darauf, das ich mich hätte besser anstellen können. :( Jetzt mach ich schon so lang rum mit Computer und ich brauch manchmal noch ewig ums auf die Reihe zu bekommen. Im nachhinein ist alles so logisch. Naja, es war auch spät :)
 
Zuletzt bearbeitet von einem Moderator:
  • Like
Reaktionen: Katzenfutter