Web Server

Setup MAMP (Mac, Apache, MySQL And PHP) on Mac OS X 10.5 Leopard

New Mac OS X 10.5 Leopard comes with new versions of Apache and PHP (Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4), so it is quite easy to setup a MAMP server. Sure there are other ways to do the setup: You can build Apache, MySQL and PHP from sources, you can use MacPorts or you can use pre-build packages like MAMP or XAMPP. But in my opinion, because Apache and PHP are already installed, they are easy way to go and will minimize you work.

Apache

To enable pre-installed PHP, you have to edit httpd.conf file:

sudo vi /private/etc/apache2/httpd.conf

And uncomment next line:

LoadModule php5_module libexec/apache2/libphp5.so

If you want to make other configuration changes, for example define virtual hosts, it’s better to use user’s configuration file:

sudo vi /private/etc/apache2/users/[username].conf

After making changes, restart Apache aka Web Sharing. Go to System Preferences > Sharing and unselect and select again Web Sharing. That’s it. Now you have the Apache and PHP running. If there are any problems, you can examine the Apache error_log. Go to Console > /var/log > apache2 > error_log.

PHP

If you want to make changes to php.ini, do the following. Copy php.ini.default to php.ini:

sudo cp /private/etc/php.ini.default /private/etc/php.ini

And to make changes:

sudo chmod 644 /private/etc/php.ini
sudo vi /private/etc/php.ini
sudo chmod 444 /private/etc/php.ini

After making changes don’t forget to restart Apache.

MySQL

MySQL is a little trickier. It is not pre installed in OS X and in my opinion easiest way is to use binary from MySQL.com. So, download the current version, which is mysql-5.0.45-osx10.4-i686.pkg at the moment and install it. Then install MySQLStartupItem.pkg and copy MySQL.prefPane to OSX/Library/PreferencePanes. It seems to be that current versions preference pane is not quite compatible with OS X 10.5. It shows if the server is running or stopped, but you can’t star or stop with it. MySQL starts when the OS starts, but you can start or stop it manually from console:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

MySQL with default settings use socket in /tmp and pre-installed PHP presumes it to be in /var/mysql, so you have to update the location in php.ini:

mysql.default_socket = /tmp/mysql.sock

Perhaps you could also use a symbolic link from /var/mysql/mysql.sock to tmp/mysql.soc. MySQL GUI Tools are also working nicely with new OS X 10.5.

Mac OS X 10.5

No you should have a MAMP server running nicely. If you want to make host name changes – for example you can use different names for localhost to take advantage Apache’s virtual hosting – edit hosts file:

sudo vi /private/etc/hosts

Setup MAMP (Mac, Apache, MySQL And PHP) on Mac OS X 10.5 Leopard Read More »

Minimal How to Setup LAMP Web Server

Apache

Apache 2.0

Install Apache from Debian stable:

apt-get install apache2

Apache is ready and running. Test that it is workin by pointing browser to www.mysite.com. Read Apache’s security tips.

Apache’s files and directories are:

  • /etc/apache2/sites-available/mysite.com: Your virtual domain configuration.
  • /etc/apache2/sites-enabled/mydomain.com: Symlink to you configuration, when site is enabled with a2ensite mysite.com command.
  • /var/log/apache2/: Logs.
  • /var/www/mysite.com: Your site.

Install Cronolog:

apt-get install cronolog

Make your sites configuration file in /etc/apache2/sites-available/mysite.com:


  ServerAdmin [email protected]
  ServerName www.mysite.com
  ServerAlias mysite.com
  DocumentRoot /var/www/mysite.com
  ErrorLog "|/usr/bin/cronolog /var/log/apache2/%Y/%Y-%m-mysite.com-error.log"
  CustomLog "|/usr/bin/cronolog /var/log/apache2/%Y/%Y-%m-mysite-com-access.log" combined

Make /var/www/mysite.com directory for your sites files. Enable your sites configuration file:

a2ensite mysite.com

Reload Apache:

/etc/init.d/apache2 reload

If you for some reason want to remove the site from Apache configuration:

a2dissite mysite.com

More about installing Apache.

PHP

PHP 5.1

In order to use apt-get to install PHP 5, you need to add one of the dotdeb.org mirrors to /etc/apt/sources.list, like:

deb http://packages.dotdeb.org stable all

And istall PHP:

apt-get update
apt-get install libapache2-mod-php5

Php.ini is in /etc/php5/apache2/php.ini and recommended .ini is in /usr/share/doc/php5-common/examples/php.ini-recommended.

More about installing PHP.

MySQL

MySQL 5.0

Install MySQL also from dotdeb.org as PHP:

apt-get install mysql-server
apt-get install php5-mysql

More about installing MySQL.

Minimal How to Setup LAMP Web Server Read More »

Minimal How to Setup VPS Server

Virtual Private Servers (VPS) come pre installed with operating system. Debian Linux is used in this how to. Debian’s apt packages are real time savers and they require minimum work. First thing to do is to install firewall and ntp service. Make a SSH connection with PuTTY to your VPS to install the programs.

picoFIREWALL

PicoFIREWALL

PicoFIREWALL is a Linux kernels iptable’s configuration script and it requires minimum work to install and configure. Add the following line in your file /etc/apt/sources.list:

deb http://debian.seismo.ethz.ch sarge ethz_sed

Install picoFIREWALL:

apt-get update; apt-get install picofirewall

PicoFIREWALL is now installed and running, but aknowledge that with default settings picoFIREWALL prevents all incoming connections into the server, including SSH. And since you don’t have a console login for the VPS server you have to make some configuration to be able to login again. Edit /etc/picofirewall/open_log.cfg file and add:

0/0,tcp,22

This opens SSH port 22 connection to all ips. You could use your desktop client’s ip and add instead something like:

111.222.111.222,tcp,22

But remember that your internet connection’s ip might change. If you know any computer you have access and whitch ip is not changin, it might be good backup to add that ip as allowed. I don’t know what is the best solution if you only have a changing ip and you don’t want to make port 22 open to everybody. One might think that services like DynDNS is the answer, but these services don’t make different the fact that your connections ip is still changing and kernels iptables operates only on ip address layer and DNS layer is higher layer.

If and when you want to open the http port 80 edit /etc/picofirewall/open_log.cfg file and add:

0/0,tcp,80

After changing picoFIREWALL’s configuration run:

/etc/init.d/picofirewall start

NTP

Ntp

There is no reason why you would not like to have a exact time in your server. So install ntp:

apt-get install ntp
apt-get install ntp-server

To set the time first time you have to stop the ntp service, set the time and start the sevice again:

/etc/init.d/ntp-server stop
ntpdate pool.ntp.org
/etc/init.d/ntp-server start

If you notice that ntpdate won’t change the time of the server, your VPS hardware is propably forcing Linux time synchronization and it is propably not the exact time. Then you have to edit /etc/sysctl.con file and add the line to disable forced synchronization:

xen.independent_wallclock = 1

More info about virtualization’s time synchronization.

Minimal How to Setup VPS Server Read More »

Minimal How to Start a Blog

Planning

Desktop Client

Web Server

  • Choose a server platform: There are two major options for bloggin platform: to use a free service like Blogger or to have have a hosted service with your own domain. The latter option can be a hosted website, virtual private server (VPS) or dedicated server. With a free service you have only littel control over your blog. Hosted website might be the best options for easy setup and maintainance but in vps is the best option having total control over your server and blogging software with usually reasonable price.
  • Order the hosting service: Choosing the hosting service possibly depends if you want to have it in your country or somewhere else. You can start looking options for example with Go Daddy.
  • Register the domain: Usually domain registeration is included in the hosting service.
  • Install and configure software: Linux, firewall, ntp, Apache, MySQL and PHP.

Blogging Software

  • Choose a software: For mainly blogging WordPress is a good choise and for content management system (CMS) there is Drupal. These are both php choises. There are also choises for other paltforms, but for this purpose I would say that php is a agile choise.
  • Install and configure the software: WordPress has a good documentation.
  • Choose or create the theme for the blog: WordPress Themes
  • Start blogging

This is a minimal how to start a blog list. More about them later, but with the list you are ready to go. There are many more things to learn and consider, like writing content, blog networks, search engine optimization (SEO), monetizing blog and so on. Also more about them later.

About topic planning there is not going to be more here for now because, as you can see, ProBlogger is an excellent resourse for that.

Minimal How to Start a Blog Read More »

Scroll to Top