Web design software - 584 CHAPTER 25 INSTALLING POSTGRESQL Step 1.

584 CHAPTER 25 INSTALLING POSTGRESQL Step 1. Create the postgres User Although it s possible to run PostgreSQL as any non-root user for instance, from your home directory, for testing purposes for most typical uses, you ll want to create a special user whose only purpose is to own the PostgreSQL daemon process (known as postmaster) and the database files. When properly configured, it will be impossible for others to log in as this user, thereby ensuring that the server s operation can t be interfered with and that the data files can t be deleted or surreptitiously accessed. While the name of this user is completely up to you, the name postgres is commonly used. Therefore, go ahead and create this user, using either postgres or another name of your choosing: %> useradd postgres Note You need superuser privileges to execute this command. From this point forward, it s presumed that you opted to use the username postgres; if you did not, please substitute any further references in this chapter with the appropriate name. Step 2. Initialize the PostgreSQL Database Next, you must initialize the PostgreSQL database cluster, which involves specifying the location of the database files and creating two initial databases, namely postgres and template1. You accomplish this by using the PostgreSQL command initdb. You should execute this command as the newly created postgres user; however, because this user isn t privileged and the database directory must be created first, you need to first create this directory as a privileged user: %> mkdir /usr/local/pgsql/data Note that this example presumes that /usr/local/pgsql/ is the location in which PostgreSQL has been installed. Keep in mind that you are by no means constrained to hosting the databases within the PostgreSQL installation directory and are free to choose any directory you please. However, for the sake of consistency, from this point forward it s assumed that you chose that directory; therefore, substitute any further references in this chapter with the appropriate name if you chose a different default location. Next, assign the ownership of this data directory to the postgres user created in the previous step: %> chown postgres /usr/local/pgsql/data Now it s time to execute the initdb command, which will create the cluster. However, you should do so as the postgres user, so change over to that user before proceeding. %>su postgres postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Leave a Reply