-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMP on Yosemite
177 lines (132 loc) · 6.73 KB
/
AMP on Yosemite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#start apache service
sudo apachectl start
#To find the Apache version
httpd -v
#The Apache version that comes in OSX Yosemite is Apache/2.4.10
#test via localhost or
#apachectl configtest
#The files are shared in the filing system at –
#/Library/WebServer/Documents/
#User Level Root
#setup user-level-webroot-sites-folder
mkdir ~/Sites Folder
sudo nano /etc/apache2/users/username.conf
cd /etc/apache2/users
sudo nano username.conf
#Then add the content below swapping in your ‘username’ in the code below:
#<Directory "/Users/username/Sites/">
#AllowOverride All
#Options Indexes MultiViews FollowSymLinks
#Require all granted
#</Directory>
#Permissions on the file should be:
#-rw-r--r-- 1 root wheel 298 Jun 28 16:47 username.conf
#sudo chmod 644 username.conf
#Open the main httpd.conf and allow some modules:
sudo nano /etc/apache2/httpd.conf
#And make sure these 3 modules are uncommented (the first 2 should be on a clean install):
#LoadModule authz_core_module libexec/apache2/mod_authz_core.so
#LoadModule authz_host_module libexec/apache2/mod_authz_host.so
#LoadModule userdir_module libexec/apache2/mod_userdir.so
#LoadModule php5_module libexec/apache2/libphp5.so
#and also
#Include /private/etc/apache2/extra/httpd-userdir.conf
#Then open another Apache config file and uncomment another file:
#sudo nano /etc/apache2/extra/httpd-userdir.conf
#And uncomment:
#Include /private/etc/apache2/users/*.conf
#Restart Apache for the new file to be read:
sudo apachectl restart
Then this user level document root will be viewable at:
http://localhost/~username/
#Override .htaccess and allow URL Rewrites
#If you are going to use the document root at /Library/WebServer/Documents it is a good idea to allow any .htaccess files used to override the default settings – this can be accomplished by editing the httpd.conf file at line 217 and setting the AllowOverride to All and then restart Apache. This is already taken care of at the Sites level webroot by following the previous step.
sudo nano /etc/apache2/httpd.conf
#osx-htaccess-override
#osx-htaccess-override
#Also whilst here allow URL rewrites so your permalinks look clean not ugly.
#Uncomment in httpd.conf
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so
################PHP
sudo nano /etc/apache2/httpd.conf
#uncomment
#LoadModule php5_module libexec/apache2/libphp5.so
sudo apachectl restart
To see and test PHP, create a file name it “phpinfo.php” and file it in your document root with the contents below, then view it in a browser.
<?php phpinfo(); ?>
####################MySQL
#install dmg from site
sudo /usr/local/mysql/support-files/mysql.server start
#To find the MySQL version from the terminal, type at the prompt:
#/usr/local/mysql/bin/mysql -v
#add sql command to path
cd ; nano .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
#reload profile file
source ~/.bash_profile
#mysql -v
#You will get the version number again, just type “q” to exit.
#Set the MySQL root password
/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'
#Use the single ‘quotes’ surrounding the password
'
Fix the 2002 MySQL Socket error
Fix the looming 2002 socket error – which is linking where MySQL places the socket and where OSX thinks it should be, MySQL puts it in /tmp and OSX looks for it in /var/mysql the socket is a type of file that allows mysql client/server communication.
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
AutoStarting MySQL on Reboot
There was a solution recently posted on how to autostart MySQL on reboot on Yosemite, if you follow this it will work:
sudo nano /Library/LaunchDaemons/com.mysql.mysql.plist
And paste in:
<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>
</dict>
</plist>
Save it and then:
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
Then it will load on a restart.
'
phpMyAdmin
phpMyAdmin is installed pretty much the same way as another guide on this site, but to recap….
'
Fix the 2002 socket error first if you haven’t done so from the MySQL section-
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Download phpMyAdmin, the zip English package will suit a lot of users, then unzip it and move the folder with its contents into the document root level renaming folder to ‘phpmyadmin’.
'
#Make the config folder
mkdir ~/Sites/phpmyadmin/config
#Change the permissions
chmod o+w ~/Sites/phpmyadmin/config
#Run the set up in the browser
#http://localhost/~username/phpmyadmin/setup/ or http://localhost/phpmyadmin/setup/
#You need to create a new localhost mysql server connection, click new server.
#Switch to the Authentication tab and set the local mysql root user and the password.
#Add in the username “root” (maybe already populated, add in the password that you set up earlier for the MySQL root user set up, click on save and you are returned to the previous screen.
#(This is not the OSX Admin or root password – it is the MySQL root user).
Make sure you click on save, then a config.inc.php is now in the /config directory of phpmyadmin directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.
Now going to http://localhost/~username/phpmyadmin/ will now allow you to interact with your MySQL databases.
'
To upgrade phpmyadmin just download the latest version and copy the older ‘config.inc.php‘ from the existing directory into the new folder and replace – backup the older one just in case.
Permissions
To run a website with no permission issues it is best to set the web root and its contents to be writeable by all, since it’s a local development it should’nt be a security issue.
Lets say that you have a site in the User Sites folder at the following location ~/Sites/testsite you would set it to be writeable like so:
sudo chmod -R a+w ~/Sites/testsite
If you are concerned about security then instead of making it world writeable you can set the owner to be Apache _www but when working on files you would have to authenticate more as admin you are “not” the owner, you would do this like so:
sudo chown -R _www ~/Sites/testsite
This will set the contents recursively to be owned by the Apache user.
If you had the website stored at the System level Document root at say /Library/WebServer/Documents/testsite then it would have to be the latter:
sudo chown -R _www /Library/WebServer/Documents/testsite
'